"use client"; import { useMemo, useState, useTransition } from "react"; import { useRouter } from "next/navigation"; import { Building2, Save, TextCursorInput } from "lucide-react"; import { Button, Card, CardContent, Input, Label } from "poyraz-ui/atoms"; import { toast } from "poyraz-ui/molecules"; import { useTranslations } from "@/components/i18n/i18n-provider"; import { LocalizedFields, type LocalizedFieldLocale, type LocalizedFieldValues, } from "@/components/i18n/localized-fields"; import { contentTranslationRegistry } from "@/lib/i18n/content"; import { saveGeneralSettingsAction } from "./actions"; type GeneralSettingsFormProps = { defaultLocale: string; locales: LocalizedFieldLocale[]; initial: { metaTitle: string; shortName: string; workspaceName: string; translations: LocalizedFieldValues; }; }; export function GeneralSettingsForm({ defaultLocale, locales, initial, }: GeneralSettingsFormProps) { const t = useTranslations(); const router = useRouter(); const [pending, startTransition] = useTransition(); const [workspaceName, setWorkspaceName] = useState(initial.workspaceName); const [metaTitle, setMetaTitle] = useState(initial.metaTitle); const [shortName, setShortName] = useState(initial.shortName); const localizedFields = useMemo( () => contentTranslationRegistry.branding.map((field) => ({ ...field, label: field.name === "portalWelcome" ? t("settings.general.fields.portalWelcome") : t("settings.general.fields.portalFooter"), placeholder: field.name === "portalWelcome" ? t("settings.general.placeholders.portalWelcome") : t("settings.general.placeholders.portalFooter"), })), [t], ); function submit(formData: FormData) { startTransition(async () => { const result = await saveGeneralSettingsAction(formData); if (result.errorKey) { toast.error(t(result.errorKey)); return; } toast.success(t("settings.general.messages.saved")); router.refresh(); }); } return (

{t("settings.general.title")}

{t("settings.general.description")}

setWorkspaceName(event.target.value)} minLength={1} maxLength={120} required />

{t("settings.general.help.workspaceName")}

setMetaTitle(event.target.value)} minLength={1} maxLength={80} required />

{t("settings.general.help.metaTitle")}

setShortName(event.target.value)} minLength={1} maxLength={24} required />

{t("settings.general.help.shortName")}

{t("settings.general.help.portalContent")}

); }