"use client"; import { zodResolver } from "@hookform/resolvers/zod"; import clsx from "clsx"; import { ArrowRight, Minus, Plus, ShoppingBag, X } from "lucide-react"; import { useMemo } from "react"; import type { ControllerRenderProps } from "react-hook-form"; import { Controller, useForm } from "react-hook-form"; import z from "zod"; import { Price } from "@/components/shadcnblocks/price"; import { AspectRatio } from "@/components/ui/aspect-ratio"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, } from "@/components/ui/carousel"; import { Dialog, DialogClose, DialogContent, DialogTitle, } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import { Separator } from "@/components/ui/separator"; const STOCK_STATUS = { IN_STOCK: "IN_STOCK", OUT_OF_STOCK: "OUT_OF_STOCK", } as const; type StockStatusCode = keyof typeof STOCK_STATUS; type Image = { src: string; alt: string; }; interface ProductPrice { regular: number; sale?: number; currency: string; } type Option = { id: string; value: string; label: string; thumbnail?: string; stockStatusCode?: StockStatusCode; }; interface Hinges { label: string; id: string; min?: number; max?: number; name: FieldName; options?: Option[]; } type Product = { images: Image[]; name: string; link: string; price: ProductPrice; badges: string[]; hinges: Record; variant: { color: string; size: string; }; }; type FormType = z.infer; type FieldName = keyof FormType; interface ProductImagesProps { images: Image[]; } interface ProductFormProps { hinges: Record; selected: FormType; } interface RadioGroupProps { options?: Array