"use client"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { Button } from "@/shared/components/ui/button"; import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, } from "@/shared/components/ui/form"; import { Input } from "@/shared/components/ui/input"; import { Switch } from "@/shared/components/ui/switch"; import { ImageUpload } from "@/shared/components/image-upload"; import { TiptapEditor } from "@/shared/components/text-editor"; import { NewsFormValues, newsSchema } from "@/shared/schemas/news"; interface NewsFormProps { defaultValues?: Partial; onSubmitAction: (data: NewsFormValues) => void; isPending?: boolean; onCancelAction?: () => void; } export function NewsForm({ defaultValues, onSubmitAction, isPending = false, onCancelAction, }: NewsFormProps) { const form = useForm({ resolver: zodResolver(newsSchema), defaultValues: { name: defaultValues?.name || "", description: defaultValues?.description || "", thumbnail: defaultValues?.thumbnail || "", is_active: defaultValues?.is_active ?? true, }, }); return (
( Judul )} /> ( Isi Konten )} /> ( Thumbnail field.onChange("")} /> )} /> (
Status
Aktifkan atau nonaktifkan konten
)} />
{onCancelAction && ( )}
); }