// "use client" // import { zodResolver } from "@hookform/resolvers/zod" // import { useForm } from "react-hook-form" // import { z } from "zod" // import { Button } from "@/app/_components/ui/button" // import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "@/app/_components/ui/form" // import { Input } from "@/app/_components/ui/input" // import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/app/_components/ui/select" // import { useState } from "react" // import { User } from "./column" // import { updateUser } from "../../user-management/action" // import { toast } from "@/app/_hooks/use-toast" // const userFormSchema = z.object({ // email: z.string().email({ message: "Please enter a valid email address" }), // first_name: z.string().nullable(), // last_name: z.string().nullable(), // role: z.enum(["user", "admin", "moderator"]), // }) // type UserFormValues = z.infer // interface UserFormProps { // user: User // } // export function UserForm({ user }: UserFormProps) { // const [isSubmitting, setIsSubmitting] = useState(false) // const form = useForm({ // resolver: zodResolver(userFormSchema), // defaultValues: { // email: user.email, // first_name: user.first_name, // last_name: user.last_name, // role: user.role as "user" | "admin" | "moderator", // }, // }) // async function onSubmit(data: UserFormValues) { // try { // setIsSubmitting(true) // await updateUser(user.id, data) // toast({ // title: "User updated", // description: "The user" + user.email + " has been updated.", // }) // } catch (error) { // toast({ // title: "Failed to update user", // description: "An error occurred while updating the user.", // variant: "destructive", // }) // console.error(error) // } finally { // setIsSubmitting(false) // } // } // return ( //
// // ( // // Email // // // // This is the user's email address. // // // )} // /> //
// ( // // First Name // // // // // // )} // /> // ( // // Last Name // // // // // // )} // /> //
// ( // // Role // // The user's role determines their permissions. // // // )} // /> // // // // ) // }