import { useState, useEffect } from 'react'; import { api } from '@common/services/api'; import { useMapStore } from '@common/store/mapStore'; // ─── 타입 ───────────────────────────────────────────────── interface MapBaseItem { mapSn: number; mapKey: string; mapNm: string; mapLevelCd: string | null; mapSrc: string | null; mapDc: string | null; useYn: string; regId: string | null; regNm: string | null; regDtm: string | null; } interface MapBaseForm { mapKey: string; mapNm: string; mapLevelCd: string; mapSrc: string; mapDc: string; useYn: string; } interface Message { type: 'success' | 'error'; text: string; } // ─── 상수 ───────────────────────────────────────────────── const EMPTY_FORM: MapBaseForm = { mapKey: '', mapNm: '', mapLevelCd: '', mapSrc: '', mapDc: '', useYn: 'Y', }; const MAP_LEVEL_OPTIONS = ['S-52', 'S-57', 'S-101', '3D', 'SAT', '기타'] as const; // ─── 모달 ───────────────────────────────────────────────── interface MapBaseModalProps { editItem: MapBaseItem | null; form: MapBaseForm; onFormChange: (form: MapBaseForm) => void; onClose: () => void; onSave: () => Promise; saving: boolean; modalError: string | null; } function MapBaseModal({ editItem, form, onFormChange, onClose, onSave, saving, modalError, }: MapBaseModalProps) { const isEdit = editItem !== null; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); await onSave(); }; const setField = (key: K, value: MapBaseForm[K]) => { onFormChange({ ...form, [key]: value }); }; return (
{/* 모달 헤더 */}

{isEdit ? '지도 수정' : '지도 등록'}

{/* 폼 */}
{/* 지도 이름 */}
setField('mapNm', e.target.value)} placeholder="지도 이름을 입력하세요" className="w-full px-3 py-2 text-caption bg-bg-elevated border border-stroke rounded-md text-fg placeholder-fg-disabled focus:border-color-accent focus:outline-none font-korean" />
{/* 지도 키 */}
setField('mapKey', e.target.value)} placeholder="고유 식별 키 (영문/숫자)" disabled={isEdit} className="w-full px-3 py-2 text-caption bg-bg-elevated border border-stroke rounded-md text-fg placeholder-fg-disabled focus:border-color-accent focus:outline-none font-mono disabled:opacity-50 disabled:cursor-not-allowed" />
{/* 지도 레벨 */}
{/* 파일 소스 */}
setField('mapSrc', e.target.value)} placeholder="타일 URL 또는 파일 경로" className="w-full px-3 py-2 text-caption bg-bg-elevated border border-stroke rounded-md text-fg placeholder-fg-disabled focus:border-color-accent focus:outline-none font-mono" />
{/* 상세 설명 */}