({ data }: { data: ProfileData })
| 73 | }; |
| 74 | |
| 75 | export function ProfileForm({ data }: { data: ProfileData }) { |
| 76 | const { execute, isExecuting } = useAction(editProfileAction); |
| 77 | |
| 78 | const form = useForm<z.infer<typeof formSchema>>({ |
| 79 | resolver: zodResolver(formSchema), |
| 80 | defaultValues: { |
| 81 | name: data?.name, |
| 82 | status: data?.status ?? "", |
| 83 | bio: data?.bio ?? "", |
| 84 | work: data?.work ?? "", |
| 85 | website: data?.website ?? "", |
| 86 | social_x_link: data?.social_x_link ?? "", |
| 87 | is_public: data?.is_public ?? true, |
| 88 | slug: data?.slug, |
| 89 | }, |
| 90 | }); |
| 91 | |
| 92 | const onSubmit = (data: z.infer<typeof formSchema>) => { |
| 93 | execute({ |
| 94 | name: data.name, |
| 95 | status: data.status || null, |
| 96 | bio: data.bio || null, |
| 97 | work: data.work || null, |
| 98 | website: data.website || null, |
| 99 | social_x_link: data.social_x_link || null, |
| 100 | is_public: data.is_public ?? true, |
| 101 | slug: data.slug, |
| 102 | }); |
| 103 | }; |
| 104 | |
| 105 | return ( |
| 106 | <Form {...form}> |
| 107 | <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6"> |
| 108 | <ScrollArea className="h-[450px] pr-4"> |
| 109 | <div className="space-y-6"> |
| 110 | <FormField |
| 111 | control={form.control} |
| 112 | name="name" |
| 113 | render={({ field }) => ( |
| 114 | <FormItem> |
| 115 | <FormLabel>Name</FormLabel> |
| 116 | <FormControl> |
| 117 | <Input |
| 118 | placeholder="Your name" |
| 119 | {...field} |
| 120 | className="placeholder:text-[#878787] border-border" |
| 121 | /> |
| 122 | </FormControl> |
| 123 | <FormMessage /> |
| 124 | </FormItem> |
| 125 | )} |
| 126 | /> |
| 127 | |
| 128 | <FormField |
| 129 | control={form.control} |
| 130 | name="slug" |
| 131 | render={({ field }) => ( |
| 132 | <FormItem> |
nothing calls this directly
no outgoing calls
no test coverage detected