'use client'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@app/components/ui/dropdown-menu'; import { Button } from '@app/components/ui/button'; import { Check, Globe, Languages } from 'lucide-react'; import clsx from 'clsx'; import { useTransition } from 'react'; import { Locale } from '@/i18n/config'; import { setUserLocale } from '@/services/locale'; type Props = { defaultValue: string; items: Array<{ value: string; label: string }>; label: string; }; export default function LocaleSwitcherSelect({ defaultValue, items, label }: Props) { const [isPending, startTransition] = useTransition(); function onChange(value: string) { const locale = value as Locale; startTransition(() => { setUserLocale(locale); }); } const selected = items.find((item) => item.value === defaultValue); return ( {items.map((item) => ( onChange(item.value)} className="flex items-center gap-2" > {item.value === defaultValue && ( )} {item.label} ))} ); }