"use client"; import { zodResolver } from "@hookform/resolvers/zod"; import { ArrowRight, Plus, X } from "lucide-react"; import { Fragment, useState } from "react"; import type { UseFormReturn } from "react-hook-form"; import { useForm } from "react-hook-form"; import { Controller } from "react-hook-form"; import z from "zod"; import { Price, PriceValue } from "@/components/shadcnblocks/price"; import { AspectRatio } from "@/components/ui/aspect-ratio"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, } from "@/components/ui/carousel"; import { Field, FieldLabel } from "@/components/ui/field"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import { cn } from "@/lib/utils"; const STOCK_STATUS = { IN_STOCK: "IN_STOCK", OUT_OF_STOCK: "OUT_OF_STOCK", } as const; type StockStatusCode = keyof typeof STOCK_STATUS; type FormType = z.infer; type FormFieldName = keyof FormType; type Image = { src: string; alt: string; }; interface ProductPrice { regular: number; sale?: number; currency: string; } interface Product { name: string; images: Image[]; link: string; hinges: Record; variantId: string; price: ProductPrice; } type Option = { id: string; value: string; colors?: string[]; label?: string; images?: Image[]; stockStatusCode?: StockStatusCode; }; type Hinge = { label?: string; name: FormFieldName; id: string; options: Array