svrjs-nextjs-website/app/(auth)/admin/downloads/page.tsx

71 lines
1.8 KiB
TypeScript
Raw Normal View History

2024-06-20 17:37:45 +02:00
"use client";
import { downloadSchema } from "@/lib/validations/validation";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { Button } from "@/components/ui/button";
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
const DownloadPage = () => {
const form = useForm<z.infer<typeof downloadSchema>>({
resolver: zodResolver(downloadSchema),
defaultValues: {
username: "",
},
});
function onSubmit(values: z.infer<typeof downloadSchema>) {
// Do something with the form values.
// ✅ This will be type-safe and validated.
console.log(values);
}
return (
<section id="downloadspage" className="wrapper container">
<h1 className="h2-bold py-6">Download Section</h1>
<div className="flex-start flex-col">
<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="w-full max-w-3xl space-y-4"
>
<FormField
control={form.control}
name="username"
render={({ field }) => (
<FormItem>
<FormLabel>Username</FormLabel>
<FormControl>
<Input placeholder="shadcn" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<Button
type="submit"
className="w-full text-lg rounded-full"
size={"lg"}
>
Submit
</Button>
</form>
</Form>
</div>
</section>
);
};
export default DownloadPage;