"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { ProductAdmin } from "@/lib/api"; import { Loader2, ChevronDown, ChevronUp } from "lucide-react"; interface ProductFormProps { initialData?: ProductAdmin; onSubmit: (data: any) => Promise; isSubmitting: boolean; } const iconOptions = [ { value: "", label: "선택하세요" }, { value: "Cpu", label: "Cpu (프로세서)" }, { value: "HardDrive", label: "HardDrive (하드웨어)" }, { value: "Monitor", label: "Monitor (디스플레이)" }, { value: "Server", label: "Server (서버)" }, { value: "Wifi", label: "Wifi (무선)" }, { value: "Cable", label: "Cable (케이블)" }, { value: "Cog", label: "Cog (설정)" }, { value: "Zap", label: "Zap (전원)" }, { value: "Gauge", label: "Gauge (센서)" }, { value: "Thermometer", label: "Thermometer (온도)" }, ]; const categoryOptions = [ { value: "", label: "선택하세요" }, { value: "controller", label: "컨트롤러" }, { value: "sensor", label: "센서" }, { value: "display", label: "디스플레이" }, { value: "communication", label: "통신장비" }, { value: "power", label: "전원장치" }, { value: "software", label: "소프트웨어" }, { value: "accessory", label: "악세서리" }, { value: "other", label: "기타" }, ]; export default function ProductForm({ initialData, onSubmit, isSubmitting, }: ProductFormProps) { const router = useRouter(); const [showEnglish, setShowEnglish] = useState(!!initialData?.name_en); const [showJapanese, setShowJapanese] = useState(!!initialData?.name_ja); const [showChinese, setShowChinese] = useState(!!initialData?.name_zh); const [formData, setFormData] = useState({ name_ko: initialData?.name_ko || "", category_ko: initialData?.category_ko || "", description_ko: initialData?.description_ko || "", detail_ko: initialData?.detail_ko || "", name_en: initialData?.name_en || "", category_en: initialData?.category_en || "", description_en: initialData?.description_en || "", detail_en: initialData?.detail_en || "", name_ja: initialData?.name_ja || "", category_ja: initialData?.category_ja || "", description_ja: initialData?.description_ja || "", detail_ja: initialData?.detail_ja || "", name_zh: initialData?.name_zh || "", category_zh: initialData?.category_zh || "", description_zh: initialData?.description_zh || "", detail_zh: initialData?.detail_zh || "", specifications: initialData?.specifications || "", icon: initialData?.icon || "", is_active: initialData?.is_active ?? true, display_order: initialData?.display_order || 0, }); const handleChange = ( e: React.ChangeEvent< HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement > ) => { const { name, value, type } = e.target; setFormData({ ...formData, [name]: type === "checkbox" ? (e.target as HTMLInputElement).checked : type === "number" ? Number(value) : value, }); }; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); await onSubmit(formData); }; return (
{/* Korean (Required) */}

KO 한국어 (필수)