/* eslint-disable react/no-children-prop */ "use client" import * as React from "react" import { useForm } from "@tanstack/react-form" import { toast } from "sonner" import * as z from "zod" import { Button } from "@/registry/new-york-v4/ui/button" import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/registry/new-york-v4/ui/card" import { Field, FieldDescription, FieldError, FieldGroup, FieldLabel, } from "@/registry/new-york-v4/ui/field" import { Input } from "@/registry/new-york-v4/ui/input" import { InputGroup, InputGroupAddon, InputGroupText, InputGroupTextarea, } from "@/registry/new-york-v4/ui/input-group" const formSchema = z.object({ title: z .string() .min(5, "Bug title must be at least 5 characters.") .max(32, "Bug title must be at most 32 characters."), description: z .string() .min(20, "Description must be at least 20 characters.") .max(100, "Description must be at most 100 characters."), }) export default function BugReportForm() { const form = useForm({ defaultValues: { title: "", description: "", }, validators: { onSubmit: formSchema, }, onSubmit: async ({ value }) => { toast("You submitted the following values:", { description: (
            {JSON.stringify(value, null, 2)}
          
), position: "bottom-right", classNames: { content: "flex flex-col gap-2", }, style: { "--border-radius": "calc(var(--radius) + 4px)", } as React.CSSProperties, }) }, }) return ( Bug Report Help us improve by reporting bugs you encounter.
{ e.preventDefault() form.handleSubmit() }} > { const isInvalid = field.state.meta.isTouched && !field.state.meta.isValid return ( Bug Title field.handleChange(e.target.value)} aria-invalid={isInvalid} placeholder="Login button not working on mobile" autoComplete="off" /> {isInvalid && ( )} ) }} /> { const isInvalid = field.state.meta.isTouched && !field.state.meta.isValid return ( Description field.handleChange(e.target.value)} placeholder="I'm having an issue with the login button on mobile." rows={6} className="min-h-24 resize-none" aria-invalid={isInvalid} /> {field.state.value.length}/100 characters Include steps to reproduce, expected behavior, and what actually happened. {isInvalid && ( )} ) }} />
) }