"use client"; import React from "react"; import { useForm, SubmitHandler, useFieldArray } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { Button } from "@/components/ui/button"; import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { logsSchema } from "@/lib/validations/validation"; import { z } from "zod"; type LogsFormValues = z.infer; const AdminLogPage = () => { const form = useForm({ resolver: zodResolver(logsSchema), defaultValues: { version: "", date: "", bullets: [""], }, }); const { fields, append, remove } = useFieldArray({ control: form.control, name: "bullets" as const, // Ensure this is typed correctly }); const onSubmit: SubmitHandler = async (data) => { const response = await fetch("/api/uploadlogs", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(data), }); if (response.ok) { form.reset(); console.log("Upload successful"); alert("Uploaded"); } else { console.error("Upload failed"); alert("Upload Failed"); } }; return (

Server Logs Form

( Version Name )} /> ( Date )} /> {fields.map((field, index) => ( ( Key Point {index + 1} )} /> ))}
); }; export default AdminLogPage;