diff --git a/apps/storefront/src/app/[locale]/(main)/_components/navigation.tsx b/apps/storefront/src/app/[locale]/(main)/_components/navigation.tsx index 42dd2d7..98a48dd 100644 --- a/apps/storefront/src/app/[locale]/(main)/_components/navigation.tsx +++ b/apps/storefront/src/app/[locale]/(main)/_components/navigation.tsx @@ -1,5 +1,6 @@ "use client"; +import { useLocale } from "next-intl"; import { useState } from "react"; import type { Menu } from "@nimara/domain/objects/Menu"; @@ -19,6 +20,7 @@ import type { Maybe } from "@/lib/types"; export const Navigation = ({ menu }: { menu: Maybe }) => { // Close menu manually const [currentMenuItem, setCurrentMenuItem] = useState(""); + const locale = useLocale(); if (!menu || menu?.items?.length === 0) { return null; @@ -36,6 +38,7 @@ export const Navigation = ({ menu }: { menu: Maybe }) => { {item.label} @@ -53,6 +56,7 @@ export const Navigation = ({ menu }: { menu: Maybe }) => { key={child.id} href={child.url} className="group block space-y-1 rounded-md p-3 hover:bg-accent" + locale={locale} >
{child.label} @@ -83,6 +87,7 @@ export const Navigation = ({ menu }: { menu: Maybe }) => { href={child.url} className="group relative min-h-[270px] overflow-hidden rounded-lg bg-accent" onClick={() => setCurrentMenuItem("")} + locale={locale} >

})}

diff --git a/apps/storefront/src/components/footer/footer.tsx b/apps/storefront/src/components/footer/footer.tsx index 71ca6b9..89ae37b 100644 --- a/apps/storefront/src/components/footer/footer.tsx +++ b/apps/storefront/src/components/footer/footer.tsx @@ -1,4 +1,4 @@ -import { getTranslations } from "next-intl/server"; +import { getLocale, getTranslations } from "next-intl/server"; import NimaraLogo from "@/assets/nimara-logo.svg"; import { CACHE_TTL } from "@/config"; @@ -8,7 +8,8 @@ import { getCurrentRegion } from "@/regions/server"; import { cmsMenuService } from "@/services/cms"; export const Footer = async () => { - const [region, t] = await Promise.all([ + const [locale, region, t] = await Promise.all([ + getLocale(), getCurrentRegion(), getTranslations(), ]); @@ -47,6 +48,7 @@ export const Footer = async () => { className="flex justify-start align-middle" href={paths.home.asPath()} title={t("common.go-to-homepage")} + locale={locale} > @@ -73,7 +75,9 @@ export const Footer = async () => {
    {categories?.menu.items.map((item) => (
  • - {item.label} + + {item.label} +
  • ))}
@@ -84,7 +88,9 @@ export const Footer = async () => {
    {pages?.menu.items.map((item) => (
  • - {item.label} + + {item.label} +
  • ))}
diff --git a/apps/storefront/src/lib/server.ts b/apps/storefront/src/lib/server.ts index ff9c855..1456970 100644 --- a/apps/storefront/src/lib/server.ts +++ b/apps/storefront/src/lib/server.ts @@ -1,6 +1,16 @@ import { headers } from "next/headers"; +import { getLocale } from "next-intl/server"; -export const getStoreUrl = async () => - `${(await headers()).get("x-forwarded-proto")}://${(await headers()).get( - "x-forwarded-host", - )}`; +import { localePrefixes } from "@/i18n/routing"; +import { DEFAULT_LOCALE, type Locale } from "@/regions/types"; + +export const getStoreUrl = async () => { + const locale = await getLocale(); + const domain = `${(await headers()).get("x-forwarded-proto")}://${( + await headers() + ).get("x-forwarded-host")}`; + + return locale === DEFAULT_LOCALE + ? domain + : `${domain}${localePrefixes[locale as Exclude]}`; +};