/** * 개소 정보 수정 모달 * * 발주 개소 목록에서 수정 버튼 클릭 시 표시 * - 개소 정보: 층, 부호 * - 오픈사이즈: 가로, 세로 * - 필수 설정: 가이드레일, 전원, 제어기 */ "use client"; import { useState, useEffect } from "react"; import { Dialog, DialogContent, DialogHeader, DialogTitle, } from "../ui/dialog"; import { Button } from "../ui/button"; import { Input } from "../ui/input"; import { NumberInput } from "../ui/number-input"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "../ui/select"; import type { LocationItem } from "./QuoteRegistrationV2"; // ============================================================================= // 상수 // ============================================================================= // 가이드레일 설치 유형 const GUIDE_RAIL_TYPES = [ { value: "wall", label: "벽면형" }, { value: "floor", label: "측면형" }, ]; // 모터 전원 const MOTOR_POWERS = [ { value: "single", label: "단상(220V)" }, { value: "three", label: "삼상(380V)" }, ]; // 연동제어기 const CONTROLLERS = [ { value: "basic", label: "단독" }, { value: "smart", label: "연동" }, { value: "premium", label: "매립형-뒷박스포함" }, ]; // ============================================================================= // Props // ============================================================================= interface LocationEditModalProps { open: boolean; onOpenChange: (open: boolean) => void; location: LocationItem | null; onSave: (locationId: string, updates: Partial) => void; } // ============================================================================= // 컴포넌트 // ============================================================================= export function LocationEditModal({ open, onOpenChange, location, onSave, }: LocationEditModalProps) { // --------------------------------------------------------------------------- // 상태 // --------------------------------------------------------------------------- const [formData, setFormData] = useState({ floor: "", code: "", openWidth: 0, openHeight: 0, guideRailType: "wall", motorPower: "single", controller: "basic", }); // location 변경 시 폼 데이터 초기화 useEffect(() => { if (location) { setFormData({ floor: location.floor, code: location.code, openWidth: location.openWidth, openHeight: location.openHeight, guideRailType: location.guideRailType, motorPower: location.motorPower, controller: location.controller, }); } }, [location]); // --------------------------------------------------------------------------- // 핸들러 // --------------------------------------------------------------------------- const handleFieldChange = (field: string, value: string | number) => { setFormData((prev) => ({ ...prev, [field]: value })); }; const handleSave = () => { if (!location) return; onSave(location.id, { floor: formData.floor, code: formData.code, openWidth: formData.openWidth, openHeight: formData.openHeight, guideRailType: formData.guideRailType, motorPower: formData.motorPower, controller: formData.controller, }); onOpenChange(false); }; const handleCancel = () => { onOpenChange(false); }; // --------------------------------------------------------------------------- // 렌더링 // --------------------------------------------------------------------------- if (!location) return null; return ( 개소 정보 수정
{/* 개소 정보 */}

개소 정보

handleFieldChange("floor", e.target.value)} placeholder="1층" />
handleFieldChange("code", e.target.value)} placeholder="FSS-01" />
{/* 오픈사이즈 */}

오픈사이즈

handleFieldChange("openWidth", value ?? 0)} placeholder="5000" />
handleFieldChange("openHeight", value ?? 0)} placeholder="3000" />

※ 제작사이즈는 오픈사이즈의 280mm를 더한 값으로 자동 계산됩니다.

{/* 필수 설정 */}

필수 설정

{/* 버튼 */}
); }