feat: add Persian fonts, fix UI bugs, improve frontend quality
- Add local Persian fonts: Vazirmatn, Sahel, Shabnam, Lalezar, IranNastaliq - Configure @font-face in globals.css with all font weights - Set Vazirmatn as primary font, Lalezar for headings, Sahel for alt text - Fix Hero image loading with crossOrigin and error fallback - Fix SmartAdvisor disabled button contrast (WCAG compliance) - Add visible labels for form inputs in SmartAdvisor step 1 - Fix UserDashboard null safety for walletBalance - Fix announcement bar hydration mismatch (loading state guard) - Fix UserDashboard null checks for profile fields - Improve overall frontend robustness and data-loading guards
This commit is contained in:
1 parent
40d750ad4b
commit
508356b8d3
1007 files changed
+8093
-64
No files matched your search
@@ -25,15 +25,28 @@ export default function ClientLayout({ children }: { children: React.ReactNode }
|
||||
|
||||
const { fetchProfile } = useUserStore();
|
||||
const fetchSettings = useSettingsStore(state => state.fetchSettings);
|
||||
const isInitialized = useSettingsStore(state => state.isInitialized);
|
||||
|
||||
useEffect(() => {
|
||||
fetchSettings();
|
||||
const token = localStorage.getItem('accessToken');
|
||||
if (token) {
|
||||
fetchProfile().catch(e => console.error("Auth init failed:", e));
|
||||
fetchProfile().catch(e => console.error("Auth init failed:", e));
|
||||
}
|
||||
}, [fetchProfile, fetchSettings]);
|
||||
|
||||
if (!isInitialized) {
|
||||
return (
|
||||
<div className="min-h-screen bg-medical-gray-50 flex flex-col items-center justify-center font-sans" dir="rtl">
|
||||
<div className="flex flex-col items-center gap-4 text-center">
|
||||
<div className="w-12 h-12 border-4 border-canina-blue border-t-transparent rounded-full animate-spin" />
|
||||
<h2 className="text-xl font-black text-medical-gray-900 font-lalezar tracking-wide">در حال بارگذاری اطلاعات سایت...</h2>
|
||||
<p className="text-sm text-medical-gray-500 font-shabnam">لطفاً شکیبا باشید</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Derived currentView from pathname for Header
|
||||
let currentView = "home";
|
||||
if (pathname?.includes("/shop")) currentView = "shop";
|
||||
|
||||
@@ -1,16 +1,82 @@
|
||||
@font-face {
|
||||
font-family: 'Vazirmatn';
|
||||
src: url('/fonts/VazirmatnVariable.woff2') format('woff2 supports variations'),
|
||||
url('/fonts/VazirmatnVariable.woff2') format('woff2-variations');
|
||||
src: url('/fonts/vazirmatn-v33.003/fonts/webfonts/Vazirmatn[wght].woff2') format('woff2-variations'),
|
||||
url('/fonts/vazirmatn-v33.003/fonts/webfonts/Vazirmatn-Regular.woff2') format('woff2');
|
||||
font-weight: 100 900;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Shabnam';
|
||||
src: url('/fonts/shabnam-font-v5.0.1/Shabnam.woff2') format('woff2'),
|
||||
url('/fonts/shabnam-font-v5.0.1/Shabnam.woff') format('woff');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Shabnam';
|
||||
src: url('/fonts/shabnam-font-v5.0.1/Shabnam-Bold.woff2') format('woff2'),
|
||||
url('/fonts/shabnam-font-v5.0.1/Shabnam-Bold.woff') format('woff');
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Shabnam';
|
||||
src: url('/fonts/shabnam-font-v5.0.1/Shabnam-Medium.woff2') format('woff2'),
|
||||
url('/fonts/shabnam-font-v5.0.1/Shabnam-Medium.woff') format('woff');
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Sahel';
|
||||
src: url('/fonts/sahel-font-v3.4.0/Sahel-VF.woff2') format('woff2-variations'),
|
||||
url('/fonts/sahel-font-v3.4.0/Sahel.woff2') format('woff2');
|
||||
font-weight: 100 900;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Lalezar';
|
||||
src: url('/fonts/Lalezar-Font-fontyab.com_/Lalezar-Font/TTF/Lalezar-Regular.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'IranNastaliq';
|
||||
src: url('/fonts/IranNastaliq/IranNastaliq/IranNastaliq.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'IranianSans';
|
||||
src: url('/fonts/A-Iranian-Sans/A-Iranian-Sans/Iranian Sans.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@import "tailwindcss";
|
||||
|
||||
@theme {
|
||||
--font-sans: "Vazirmatn", sans-serif;
|
||||
--font-vazir: "Vazirmatn", sans-serif;
|
||||
--font-shabnam: "Shabnam", sans-serif;
|
||||
--font-sahel: "Sahel", sans-serif;
|
||||
--font-lalezar: "Lalezar", cursive;
|
||||
--font-nastaliq: "IranNastaliq", serif;
|
||||
--font-iranian-sans: "IranianSans", sans-serif;
|
||||
|
||||
/* Brand Colors */
|
||||
--color-canina-blue: #1E4053;
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import Hero from "../components/Hero";
|
||||
import SmartAdvisor from "../components/SmartAdvisor";
|
||||
import FeaturedProducts from "../components/FeaturedProducts";
|
||||
import VetGallery from "../components/VetGallery";
|
||||
import Link from 'next/link';
|
||||
import { toPersian } from "../lib/utils";
|
||||
import { useSettingsStore } from "../lib/store/settingsStore";
|
||||
import api from "../lib/services/api";
|
||||
|
||||
async function getHomeData() {
|
||||
try {
|
||||
const res = await fetch('http://localhost:4000/api/home', { next: { revalidate: 60 } });
|
||||
if (!res.ok) throw new Error('Failed to fetch home data');
|
||||
return res.json();
|
||||
} catch (error) {
|
||||
console.error('Home data fetch error:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
export default function Home() {
|
||||
const getText = useSettingsStore(state => state.getText);
|
||||
const [data, setData] = useState<any>(null);
|
||||
|
||||
useEffect(() => {
|
||||
api.get('/home')
|
||||
.then(res => setData(res.data))
|
||||
.catch(err => console.error('Home data fetch error:', err));
|
||||
}, []);
|
||||
|
||||
export default async function Home() {
|
||||
const data = await getHomeData();
|
||||
const banners = data?.heroBanners || [];
|
||||
const testimonials = data?.vetTestimonials || [];
|
||||
const rules = data?.smartAdvisorRules || [];
|
||||
@@ -30,16 +32,20 @@ export default async function Home() {
|
||||
<VetGallery testimonials={testimonials} />
|
||||
|
||||
{/* Navigation to Sections */}
|
||||
<section className="py-20 bg-medical-gray-50 border-y border-medical-gray-100">
|
||||
<section className="py-20 bg-medical-gray-50 border-y border-medical-gray-100 font-sans">
|
||||
<div className="max-w-7xl mx-auto px-4 grid md:grid-cols-2 gap-8">
|
||||
<Link
|
||||
href="/shop"
|
||||
className="bg-white p-12 rounded-[3.5rem] border border-medical-gray-200 shadow-sm hover:shadow-2xl hover:-translate-y-2 transition-all cursor-pointer group block"
|
||||
>
|
||||
<h3 className="text-3xl font-black text-medical-gray-900 mb-4 group-hover:text-canina-blue transition-colors italic">فروشگاه تخصصی</h3>
|
||||
<p className="text-medical-gray-500 mb-8 leading-relaxed">دسترسی به تمامی محصولات بر اساس علائم بالینی و نیازهای پت شما.</p>
|
||||
<div className="flex items-center gap-2 text-canina-blue font-black tracking-widest uppercase text-xs">
|
||||
کاتالوگ کامل محصولات
|
||||
<h3 className="text-3xl font-black text-medical-gray-900 mb-4 group-hover:text-canina-blue transition-colors font-lalezar tracking-wide">
|
||||
{getText('nav_card_shop_title', "فروشگاه تخصصی")}
|
||||
</h3>
|
||||
<p className="text-medical-gray-500 mb-8 leading-relaxed font-shabnam">
|
||||
{getText('nav_card_shop_desc', "دسترسی به تمامی محصولات بر اساس علائم بالینی و نیازهای پت شما.")}
|
||||
</p>
|
||||
<div className="flex items-center gap-2 text-canina-blue font-black tracking-widest uppercase text-xs font-vazir">
|
||||
{getText('nav_card_shop_cta', "کاتالوگ کامل محصولات")}
|
||||
<span className="text-lg">←</span>
|
||||
</div>
|
||||
</Link>
|
||||
@@ -47,10 +53,14 @@ export default async function Home() {
|
||||
href="/wiki"
|
||||
className="bg-medical-gray-900 p-12 rounded-[3.5rem] text-white hover:shadow-2xl hover:-translate-y-2 transition-all cursor-pointer group block"
|
||||
>
|
||||
<h3 className="text-3xl font-black mb-4 group-hover:text-canina-blue transition-colors italic">دانشنامه علمی</h3>
|
||||
<p className="text-white/60 mb-8 leading-relaxed">آشنایی با ترکیبات نایاب و استانداردهای دارویی محصولات آلمانی کانینا.</p>
|
||||
<div className="flex items-center gap-2 text-canina-blue font-black tracking-widest uppercase text-xs">
|
||||
مطالعه مقالات تخصصی
|
||||
<h3 className="text-3xl font-black mb-4 group-hover:text-canina-blue transition-colors font-lalezar tracking-wide">
|
||||
{getText('nav_card_wiki_title', "دانشنامه علمی")}
|
||||
</h3>
|
||||
<p className="text-white/60 mb-8 leading-relaxed font-shabnam">
|
||||
{getText('nav_card_wiki_desc', "آشنایی با ترکیبات نایاب و استانداردهای دارویی محصولات آلمانی کانینا.")}
|
||||
</p>
|
||||
<div className="flex items-center gap-2 text-canina-blue font-black tracking-widest uppercase text-xs font-vazir">
|
||||
{getText('nav_card_wiki_cta', "مطالعه مقالات تخصصی")}
|
||||
<span className="text-lg">←</span>
|
||||
</div>
|
||||
</Link>
|
||||
@@ -58,7 +68,7 @@ export default async function Home() {
|
||||
</section>
|
||||
|
||||
{/* About Section Teaser */}
|
||||
<section className="py-24 bg-white overflow-hidden">
|
||||
<section className="py-24 bg-white overflow-hidden font-sans">
|
||||
<div className="max-w-7xl mx-auto px-4 grid lg:grid-cols-2 gap-16 lg:gap-24 items-center">
|
||||
<div className="relative">
|
||||
<div className="absolute -top-10 -right-10 w-40 h-40 bg-canina-blue/5 rounded-full blur-3xl" />
|
||||
@@ -68,28 +78,30 @@ export default async function Home() {
|
||||
className="rounded-[3rem] shadow-2xl relative z-10 grayscale-[10%]"
|
||||
/>
|
||||
<div className="absolute -bottom-6 -left-6 bg-canina-blue text-white p-8 rounded-3xl shadow-xl z-20">
|
||||
<div className="text-4xl font-black mb-1 italic">کیفیت</div>
|
||||
<div className="text-xs uppercase tracking-widest font-bold opacity-80">استانداردهای فوقدارویی</div>
|
||||
<div className="text-4xl font-black mb-1 font-lalezar tracking-wide">{getText('quality', "کیفیت")}</div>
|
||||
<div className="text-xs uppercase tracking-widest font-bold opacity-80 font-vazir">{getText('ultra_pharmaceutical', "استانداردهای فوقدارویی")}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-canina-blue text-xs font-bold uppercase tracking-[0.2em] mb-4">میراث ما از آلمان</div>
|
||||
<h2 className="text-3xl lg:text-5xl font-black text-medical-gray-900 leading-[1.2] mb-12">
|
||||
چرا برند آلمانی Canina مرجع دامپزشکان است؟
|
||||
<div className="text-canina-blue text-xs font-bold uppercase tracking-[0.2em] mb-4 font-vazir">
|
||||
{getText('about_label', "میراث ما از آلمان")}
|
||||
</div>
|
||||
<h2 className="text-3xl lg:text-5xl font-black text-medical-gray-900 leading-[1.2] mb-12 font-lalezar tracking-wide">
|
||||
{getText('about_title', "چرا برند آلمانی Canina مرجع دامپزشکان است؟")}
|
||||
</h2>
|
||||
<div className="space-y-6">
|
||||
{[
|
||||
{ title: 'مواد اولیه نایاب', desc: 'استفاده از پودر صدف لبسبز اصل نیوزیلند و مواد ارگانیک با گرید دارویی.' },
|
||||
{ title: 'فاقد مواد نگهدارنده', desc: 'تمامی محصولات ۱۰۰٪ طبیعی و فاقد رنگهای مصنوعی و طعمدهندههای شیمیایی هستند.' },
|
||||
{ title: 'تاییدیه اروپا', desc: 'مطابق با سختگیرانهترین استانداردهای ایمنی مواد غذایی و دارویی در اتحادیه اروپا.' }
|
||||
{ title: getText('about_item1_title', "مواد اولیه نایاب"), desc: getText('about_item1_desc', "استفاده از پودر صدف لبسبز اصل نیوزیلند و مواد ارگانیک با گرید دارویی.") },
|
||||
{ title: getText('about_item2_title', "فاقد مواد نگهدارنده"), desc: getText('about_item2_desc', "تمامی محصولات ۱۰۰٪ طبیعی و فاقد رنگهای مصنوعی و طعمدهندههای شیمیایی هستند.") },
|
||||
{ title: getText('about_item3_title', "تاییدیه اروپا"), desc: getText('about_item3_desc', "مطابق با سختگیرانهترین استانداردهای ایمنی مواد غذایی و دارویی در اتحادیه اروپا.") }
|
||||
].map((item, idx) => (
|
||||
<div key={idx} className="flex gap-4 items-center">
|
||||
<div className="w-12 h-12 rounded-2xl bg-medical-gray-50 flex items-center justify-center flex-shrink-0 text-canina-blue font-bold">
|
||||
<div className="w-12 h-12 rounded-2xl bg-medical-gray-50 flex items-center justify-center flex-shrink-0 text-canina-blue font-black font-lalezar text-xl shadow-sm">
|
||||
{toPersian(idx + 1)}
|
||||
</div>
|
||||
<div>
|
||||
<h4 className="text-lg font-bold text-medical-gray-900 mb-1">{item.title}</h4>
|
||||
<p className="text-sm text-medical-gray-500 leading-relaxed font-medium">{item.desc}</p>
|
||||
<h4 className="text-lg font-bold text-medical-gray-900 mb-1 font-shabnam">{item.title}</h4>
|
||||
<p className="text-sm text-medical-gray-500 leading-relaxed font-medium font-sans">{item.desc}</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
@@ -99,7 +111,7 @@ export default async function Home() {
|
||||
</section>
|
||||
|
||||
{/* Call to Action */}
|
||||
<section className="bg-canina-blue py-20 relative overflow-hidden">
|
||||
<section className="bg-canina-blue py-20 relative overflow-hidden font-sans">
|
||||
<div className="absolute inset-0 opacity-10">
|
||||
<div className="grid grid-cols-10 h-full w-full">
|
||||
{Array.from({length: 100}).map((_, i) => (
|
||||
@@ -108,22 +120,22 @@ export default async function Home() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="max-w-4xl mx-auto px-4 text-center relative z-10">
|
||||
<h2 className="text-3xl lg:text-5xl font-black text-white mb-8 leading-tight">
|
||||
میخواهید بدانید کدام محصول برای پت شما مناسبتر است؟
|
||||
<h2 className="text-3xl lg:text-5xl font-black text-white mb-8 leading-tight font-lalezar tracking-wide">
|
||||
{getText('cta_title', "میخواهید بدانید کدام محصول برای پت شما مناسبتر است؟")}
|
||||
</h2>
|
||||
<p className="text-white/80 text-lg mb-10 leading-relaxed">
|
||||
تیم متخصص دامپزشکی کانینا ایران آماده پاسخگویی به سوالات شماست.
|
||||
<p className="text-white/80 text-lg mb-10 leading-relaxed font-shabnam">
|
||||
{getText('cta_desc', "تیم متخصص دامپزشکی کانینا ایران آماده پاسخگویی به سوالات شماست.")}
|
||||
</p>
|
||||
<div className="flex flex-wrap justify-center gap-4">
|
||||
<button className="bg-white text-canina-blue px-12 py-5 rounded-full font-black text-xl hover:scale-105 transition-transform shadow-2xl shadow-black/20">
|
||||
دریافت رژیم مکمل رایگان
|
||||
<button className="bg-white text-canina-blue px-12 py-5 rounded-full font-black text-xl hover:scale-105 transition-transform shadow-2xl shadow-black/20 font-shabnam">
|
||||
{getText('cta_btn_primary', "دریافت رژیم مکمل رایگان")}
|
||||
</button>
|
||||
<Link
|
||||
href="/shop"
|
||||
className="bg-transparent border-2 border-white text-white px-12 py-5 rounded-full font-black text-xl hover:bg-white hover:text-canina-blue transition-all"
|
||||
>
|
||||
پروانه دامپزشکی و اصالت کالا
|
||||
</Link>
|
||||
<Link
|
||||
href="/shop"
|
||||
className="bg-transparent border-2 border-white text-white px-12 py-5 rounded-full font-black text-xl hover:bg-white hover:text-canina-blue transition-all font-shabnam"
|
||||
>
|
||||
{getText('cta_btn_secondary', "پروانه دامپزشکی و اصالت کالا")}
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
Reference in new issue
Block a user