From 4f5cfc9f1efce119af0759e9e4b43961de9983d7 Mon Sep 17 00:00:00 2001 From: parsa aghaei Date: Mon, 29 Jun 2026 11:19:21 +0330 Subject: [PATCH] fix: locale sync in header/testimonials, dark mode icon CSS filters, invariant arrow logic --- .../(website)/components/footer/footer.tsx | 4 ++-- .../(website)/components/header/header.tsx | 8 +++++--- .../(routes)/(website)/components/hero/hero.tsx | 4 ++-- .../(website)/components/services/services.tsx | 2 +- .../components/testimonials/testimonials.tsx | 16 +++++----------- src/app/globals.css | 7 +++++++ 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/app/(routes)/(website)/components/footer/footer.tsx b/src/app/(routes)/(website)/components/footer/footer.tsx index 3d1343e..b736973 100644 --- a/src/app/(routes)/(website)/components/footer/footer.tsx +++ b/src/app/(routes)/(website)/components/footer/footer.tsx @@ -54,14 +54,14 @@ export default async function Footer() { {social.alt} ))} diff --git a/src/app/(routes)/(website)/components/header/header.tsx b/src/app/(routes)/(website)/components/header/header.tsx index 860754c..1eb0c91 100644 --- a/src/app/(routes)/(website)/components/header/header.tsx +++ b/src/app/(routes)/(website)/components/header/header.tsx @@ -12,15 +12,17 @@ export default function Header() { const [dict, setDict] = useState(null); const [scrolled, setScrolled] = useState(false); + const selectedLocale = getCookie("selectedLocale") || getCookie("defaultLocale") || "en"; + useEffect(() => { const loadDict = async () => { - const selectedLocale = getCookie("selectedLocale"); - const defaultLocale = getCookie("defaultLocale"); - const d = await getDictionary((selectedLocale || defaultLocale || "en") as any); + const d = await getDictionary(selectedLocale as "en" | "fa"); setDict(d); }; loadDict(); + }, [selectedLocale]); + useEffect(() => { const handleScroll = () => setScrolled(window.scrollY > 50); window.addEventListener("scroll", handleScroll, { passive: true }); handleScroll(); diff --git a/src/app/(routes)/(website)/components/hero/hero.tsx b/src/app/(routes)/(website)/components/hero/hero.tsx index 69cbd3a..81034d1 100644 --- a/src/app/(routes)/(website)/components/hero/hero.tsx +++ b/src/app/(routes)/(website)/components/hero/hero.tsx @@ -57,14 +57,14 @@ export default function Hero({ dict }: HeroProps) { viewport={{ once: true }} whileHover={{ scale: 1.2, rotate: 5 }} whileTap={{ scale: 0.9 }} - className="p-2 rounded-full glass-panel hover:text-primary transition-colors group" + className="p-2 rounded-full glass-panel hover:text-primary transition-colors group dark-invert-img" > {alt} ))} diff --git a/src/app/(routes)/(website)/components/services/services.tsx b/src/app/(routes)/(website)/components/services/services.tsx index 63536cb..30d4038 100644 --- a/src/app/(routes)/(website)/components/services/services.tsx +++ b/src/app/(routes)/(website)/components/services/services.tsx @@ -56,7 +56,7 @@ export default function Services({ dict }: ServicesProps) { {service!.altText} )} diff --git a/src/app/(routes)/(website)/components/testimonials/testimonials.tsx b/src/app/(routes)/(website)/components/testimonials/testimonials.tsx index b5f87a5..6fce376 100644 --- a/src/app/(routes)/(website)/components/testimonials/testimonials.tsx +++ b/src/app/(routes)/(website)/components/testimonials/testimonials.tsx @@ -32,14 +32,8 @@ interface TestimonialsProps { export default function Testimonials({ dict }: TestimonialsProps) { const [currentIndex, setCurrentIndex] = useState(0); const scrollRef = useRef(null); - const [locale, setLocale] = useState("en"); - - useEffect(() => { - const sl = getCookie("selectedLocale"); - const dl = getCookie("defaultLocale"); - setLocale(sl || dl || "en"); - }, []); + const locale = getCookie("selectedLocale") || getCookie("defaultLocale") || "en"; const isRTL = locale === "fa"; const tData = dict.website.homePage.testimonials.data || []; const maxIndex = Math.max(0, tData.length - 3); @@ -137,16 +131,16 @@ export default function Testimonials({ dict }: TestimonialsProps) { {tData.length > 3 && ( <>