"use client"; import { zodResolver } from "@hookform/resolvers/zod"; import { Minus, Plus, ShoppingBag, Star, X } from "lucide-react"; import { useMemo, useState } from "react"; import type { ControllerRenderProps } from "react-hook-form"; import { useForm } from "react-hook-form"; import { Controller } from "react-hook-form"; import z from "zod"; import { AspectRatio } from "@/components/ui/aspect-ratio"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardTitle } from "@/components/ui/card"; import { Collapsible, CollapsibleContent } from "@/components/ui/collapsible"; import { Field, FieldLabel } from "@/components/ui/field"; import { Input } from "@/components/ui/input"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import { ScrollArea } from "@/components/ui/scroll-area"; 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 FieldName = keyof FormType; type Option = { id: string; label: string; value: string; stockStatusCode: StockStatusCode; color?: string; }; interface Hinges { label: string; id: string; name: FieldName; options?: Option[]; min?: number; max?: number; } type HingesMap = Record; interface ProductPrice { regular: number; sale?: number; currency: string; discount?: string; } interface ProductFormProps { hinges: HingesMap; onOpenChange: () => void; } interface QuantityProps { field: ControllerRenderProps; max?: number; min?: number; } type Image = { srcset?: string; src: string; sizes?: string; alt: string; }; interface Product { link: string; images: [Image, Image]; name: string; price: ProductPrice; rate: number; hinges?: HingesMap; } type ProductCardProps = Product; interface RadioGroupProps { options?: Array