"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"; import { chuni_static_avatar } from "@/prisma/schemas/artemis/generated/artemis"; type chunithm = chuni_static_avatar; const AvatarParts = [ { label: "Head", value: "avatarHead", src: "/path/to/head.png" }, { label: "Body", value: "avatarBody", src: "/path/to/body.png" }, { label: "Face", value: "avatarFace", src: "/path/to/face.png" }, { label: "Back", value: "avatarBack", src: "/path/to/back.png" }, ] 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 (
{AvatarParts.map(({ value, src }) => (
{value}
))}
{AvatarParts.map((part) => ( } render={({ field }) => ( {`Avatar ${part.label} Item`} No {part.label.toLowerCase()} item found. {AvatarParts.map((item) => ( { form.setValue( part.value as keyof z.infer< typeof FormSchema >, item.value ); }} > {item.label} ))} )} /> ))}
); }