"use client"; import { useState, useTransition } from "react"; import { Label } from "poyraz-ui/atoms"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "poyraz-ui/molecules"; type LocaleOption = { code: string; nativeName: string; name: string; }; type LocaleSelectFormProps = { label: string; value: string; locales: LocaleOption[]; }; export function LocaleSelectForm({ label, value, locales }: LocaleSelectFormProps) { const [currentLocale, setCurrentLocale] = useState(value); const [pending, startTransition] = useTransition(); function handleChange(locale: string) { setCurrentLocale(locale); startTransition(async () => { await fetch("/api/i18n/locale", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ locale }), }); window.location.reload(); }); } return (
); }