"use client"; import { useActionState, useEffect } from "react"; import { Loader2, Save } from "lucide-react"; import { toast } from "sonner"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { updateNameAction } from "@/lib/appwrite/profile-actions"; import { initialProfileState } from "@/lib/appwrite/profile-types"; export function NameForm({ currentName }: { currentName: string }) { const [state, formAction, isPending] = useActionState(updateNameAction, initialProfileState); useEffect(() => { if (state.ok) toast.success("İsim güncellendi."); else if (state.error) toast.error(state.error); }, [state]); return ( Görünür isim Header'da, davetlerde ve takım listesinde görünecek isim.
{state.fieldErrors?.name && (

{state.fieldErrors.name}

)}
); }