"use client"; import { zodResolver } from "@hookform/resolvers/zod"; import { Check, ChevronsUpDown } from "lucide-react"; import { useForm } from "react-hook-form"; import { z } from "zod"; import { cn } from "@/lib/utils"; import { Button } from "@/components/ui/button"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "@/components/ui/command"; import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { toast } from "@/components/ui/use-toast"; const AvatarParts = [ { label: "English", value: "en" }, { label: "French", value: "fr" }, { label: "German", value: "de" }, { label: "Spanish", value: "es" }, { label: "Portuguese", value: "pt" }, { label: "Russian", value: "ru" }, { label: "Japanese", value: "ja" }, { label: "Korean", value: "ko" }, { label: "Chinese", value: "zh" }, ] as const; const FormSchema = z.object({ AvatarHead: z.string({ required_error: "Please select a head item.", }), AvatarBody: z.string({ required_error: "Please select a body item.", }), AvatarFace: z.string({ required_error: "Please select a face item.", }), AvatarBack: z.string({ required_error: "Please select a back item.", }), }); export function AvatarCustomization() { const form = useForm>({ resolver: zodResolver(FormSchema), }); function onSubmit(data: z.infer) { toast({ title: "You submitted the following values:", description: (
          {JSON.stringify(data, null, 2)}
        
), }); } return (
( Avatar Head Item No head item found. {AvatarParts.map((part) => ( { form.setValue("AvatarHead", part.value); }} > {part.label} ))} )} /> ( Avatar Body Item No body item found. {AvatarParts.map((part) => ( { form.setValue("AvatarBody", part.value); }} > {part.label} ))} )} /> ( Avatar Face Item No face item found. {AvatarParts.map((part) => ( { form.setValue("AvatarFace", part.value); }} > {part.label} ))} )} /> ( Avatar Back Item No back item found. {AvatarParts.map((part) => ( { form.setValue("AvatarBack", part.value); }} > {part.label} ))} )} /> ); }