"use client"; import Image from "next/image"; import { useState, useTransition } from "react"; import { Save, User } 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 { updatePortalProfileAction } from "./actions"; export function PortalProfileForm({ initial, }: { initial: { avatarUrl: string; email: string; firstName: string; lastName: string; }; }) { const t = useTranslations(); const [pending, startTransition] = useTransition(); const [firstName, setFirstName] = useState(initial.firstName); const [lastName, setLastName] = useState(initial.lastName); function submit(formData: FormData) { startTransition(async () => { const result = await updatePortalProfileAction(formData); if (result.errorKey) { toast.error(t(result.errorKey)); return; } toast.success(t("settings.profile.messages.saved")); if (result.avatarChanged) { window.location.reload(); } }); } return (

{t("settings.portal.profile.title")}

{t("settings.portal.profile.description")}

{initial.avatarUrl ? ( {t("settings.profile.avatarAlt")} ) : (
)}

{t("settings.profile.help.avatar")}

setFirstName(event.target.value)} maxLength={80} required />
setLastName(event.target.value)} maxLength={120} required />

{t("settings.profile.help.email")}

); }