"use client" import { z } from "zod" import { zodResolver } from "@hookform/resolvers/zod" import { useForm } from "react-hook-form" import { Button } from "@/components/ui/button" import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form" import { Input } from "@/components/ui/input" import { toast } from "@/components/ui/use-toast" import { Popover, PopoverContent, } from "@/components/ui/popover" import GenresTrigger from "./genresTrigger" import GenreCheckbox from "./genreCheckbox" import { randomPublicationTitle } from "app/lib/shortStoryTitleGenerator" const formSchema = z.object({ title: z.string().min(2).max(50), link: z.string(), query_after_days: z.number().min(30), genres: z.array(z.number()), }) export default function PubForm({ genres, createPub }) { const form = useForm>({ resolver: zodResolver(formSchema), defaultValues: { title: "", link: "", query_after_days: 30, genres: [] }, }) function onSubmit(values: z.infer) { // Do something with the form values. // ✅ This will be type-safe and validated. toast({ title: "You submitted the following values:", description: (
					{JSON.stringify(values, null, 2)}
				
), }) createPub(values) console.log(values) } function onErrors(errors) { toast({ title: "You have errors", description: (
					{JSON.stringify(errors, null, 2)}
				
), }) console.log(JSON.stringify(errors)) } const exampleTitle = randomPublicationTitle() const exampleUrl = "www." + exampleTitle.replace(/ /g, '') .toLowerCase() + ".com" return (
( Title )} /> ( Website )} />
( Genres {genres.map((item) => ( { return ( ) }} /> ))} )} /> ( Query after (days) )} />
) }