"use client"; import { Loader2, MoveLeft } from "lucide-react"; import { useActionState, useEffect } from "react"; import { toast } from "sonner"; import { type UpdateUserFormState, updateUser } from "@/actions/user-actions"; import { Button } from "@/components/ui/button"; import { FloatingLabelInput } from "@/components/ui/floating-label"; import type { UserProfile } from "@/lib/types/user"; // import { // Select, // SelectContent, // SelectGroup, // SelectItem, // SelectLabel, // SelectTrigger, // SelectValue, // } from "@/components/ui/select"; export default function UserUpdateForm({ user }: { user: UserProfile }) { const initialState: UpdateUserFormState = { message: "", fieldErrors: {}, payload: new FormData(), }; const [state, formAction, isPending] = useActionState( updateUser, initialState, ); useEffect(() => { if (state.message) { if (state.fieldErrors) { Object.entries(state.fieldErrors).forEach(([field, errors]) => { errors.forEach((error) => { toast.error(`Error in ${field}: ${error}`); }); }); } else { toast.success("Success", { description: "User updated successfully", closeButton: true, }); } } }, [state]); return (

Update User Information

{/* */}
); }