'use client'; import React from 'react'; import { useForm, SubmitHandler } from 'react-hook-form'; import { zodResolver } from '@hookform/resolvers/zod'; import { z } from '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 { UploadButton, UploadDropzone } from '@/lib/uploadthing'; import { modsSchema } from '@/lib/validations/validation'; const AdminPage = () => { const form = useForm>({ resolver: zodResolver(modsSchema), }); const onSubmit: SubmitHandler> = async (data) => { const response = await fetch('/api/uploadmods', { 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 (

Admin Upload Section

( File Name )} /> ( Version )} /> ( Download Link { field.onChange(res[0].url); }} onUploadError={(error: Error) => { alert(`ERROR! ${error.message}`); }} /> )} /> ( File Size )} />
); }; export default AdminPage;