This commit is contained in:
@@ -14,21 +14,21 @@ import {
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { z } from "zod";
|
||||
import { userProfileSchema } from "@/lib/validation/zod/user";
|
||||
import { userSchema } from "@/lib/validation/zod/user";
|
||||
import { User } from "next-auth";
|
||||
import { updateUserProfile } from "@/server/actions/user";
|
||||
import { toast } from "sonner";
|
||||
|
||||
function UserForm({ server_user, cb }: { server_user: User; cb?: () => void }) {
|
||||
const form = useForm<z.infer<typeof userProfileSchema>>({
|
||||
resolver: zodResolver(userProfileSchema),
|
||||
const form = useForm<z.infer<typeof userSchema>>({
|
||||
resolver: zodResolver(userSchema),
|
||||
defaultValues: {
|
||||
name: server_user?.name ?? "",
|
||||
},
|
||||
});
|
||||
|
||||
// 2. Define a submit handler.
|
||||
async function onSubmit(values: z.infer<typeof userProfileSchema>) {
|
||||
async function onSubmit(values: z.infer<typeof userSchema>) {
|
||||
// Do something with the form values.
|
||||
// ✅ This will be type-safe and validated.
|
||||
const { success } = await updateUserProfile(values);
|
||||
|
||||
Reference in New Issue
Block a user