diff --git a/src/app/[locale]/[name]/page.tsx b/src/app/[locale]/[name]/page.tsx index 283cb7b..e389693 100644 --- a/src/app/[locale]/[name]/page.tsx +++ b/src/app/[locale]/[name]/page.tsx @@ -17,11 +17,11 @@ import { Switch } from "@/components/ui/switch"; import { TicketPercentIcon } from "lucide-react"; import { MedalStar } from 'iconsax-react' import { useQueryState } from 'next-usequerystate' -import ComboBox, { DropdownOption } from "@/components/combobox/ComboBox"; import clsx from "clsx"; import CategorySmallItemRenderer from "@/components/listview/CategorySmallItemRenderer"; import { motion } from "framer-motion"; import { useTranslation } from "react-i18next"; +import ComboBox, { ComboboxOption } from "@/components/combobox/Combobox"; const categories = new Array(13).fill({ title: "خوراک", icon: "" }); @@ -139,12 +139,12 @@ const MenuIndex = () => { const { t: tMenu } = useTranslation('menu', { keyPrefix: "Menu" }); - const contents: Array = [ + const contents: Array = [ { id: '0', title: tMenu('MenuFilterDrawer.SelectContent.Options.Normal'), label: '' }, { id: '1', title: tMenu('MenuFilterDrawer.SelectContent.Options.Vegan'), label: '' }, ] - const shippings: Array = [ + const shippings: Array = [ { id: '0', title: tMenu('MenuFilterDrawer.SelectDelivery.Options.Courier'), label: '' }, ] diff --git a/src/app/[locale]/dictionaries.ts b/src/app/[locale]/dictionaries.ts index c96bb59..0c8fac4 100644 --- a/src/app/[locale]/dictionaries.ts +++ b/src/app/[locale]/dictionaries.ts @@ -1,9 +1,18 @@ import 'server-only' - + const dictionaries = { - en: () => import('@/dictionaries/en.json').then((module) => module.default), - fa: () => import('@/dictionaries/fa.json').then((module) => module.default), + fa: (namespace: string) => import(`@/dictionaries/fa/${namespace}.json`).then((module) => module.default), + en: (namespace: string) => import(`@/dictionaries/en/${namespace}.json`).then((module) => module.default), +} + +export const getDictionary = async ( + locale: 'en' | 'fa', + namespace: 'common' | 'module' +) => { + try { + return await dictionaries[locale](namespace) + } catch (error) { + console.error(`Failed to load ${locale}/${namespace}.json`, error) + return {} + } } - -export const getDictionary = async (locale: 'en' | 'fa') => - dictionaries[locale]() \ No newline at end of file diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx index 51a436f..1dc3c7b 100644 --- a/src/app/[locale]/layout.tsx +++ b/src/app/[locale]/layout.tsx @@ -18,7 +18,7 @@ export default async function RootLayout({ params, }: Readonly<{ children: React.ReactNode; - params: { locale: string } + params: Promise<{ locale: string }> }>) { const { locale } = await params; if (!i18nConfig.locales.includes(locale)) { diff --git a/src/app/[locale]/profile/edit/page.tsx b/src/app/[locale]/profile/edit/page.tsx index 6e8e3d4..49dad9d 100644 --- a/src/app/[locale]/profile/edit/page.tsx +++ b/src/app/[locale]/profile/edit/page.tsx @@ -2,7 +2,7 @@ import Button from '@/components/button/PrimaryButton'; import { Button as ShadButton } from '@/components/ui/button'; -import ComboBox from '@/components/combobox/ComboBox'; +import ComboBox from '@/components/combobox/Combobox'; import InputField from '@/components/input/InputField'; import { PORFILE_EDIT_PAGE_ELEMENT } from '@/enums'; import { Popover, PopoverTrigger, PopoverContent } from '@radix-ui/react-popover'; diff --git a/src/components/combobox/Combobox.tsx b/src/components/combobox/Combobox.tsx index 55ecd0e..f54549b 100644 --- a/src/components/combobox/Combobox.tsx +++ b/src/components/combobox/Combobox.tsx @@ -3,7 +3,7 @@ import ArrowDownIcon from '../icons/ArrowDownIcon'; import { motion, Variants } from 'framer-motion'; import { SearchNormal } from 'iconsax-react'; -export interface DropdownOption { +export interface ComboboxOption { id: string; title: string; label?: string; @@ -11,14 +11,14 @@ export interface DropdownOption { type Props = { title: string; - options: Array; + options: Array; expanded?: boolean; selectedId: string; searchable?: boolean; onSelectionChange: (e: React.MouseEvent, index: number) => void, } & React.HTMLAttributes -function ComboBox({ title, options, expanded, selectedId, searchable = true, onSelectionChange, ...props }: Props) { +function Combobox({ title, options, expanded, selectedId, searchable = true, onSelectionChange, ...props }: Props) { const [expand, setExpand] = useState(expanded); const [searchValue, setSearchValue] = useState(''); const boxRef = useRef(null); @@ -150,4 +150,4 @@ function ComboBox({ title, options, expanded, selectedId, searchable = true, onS } -export default ComboBox \ No newline at end of file +export default Combobox \ No newline at end of file