import { useState } from 'react'; import { Settings, X } from 'lucide-react'; import { useScrollLock } from '@/lib/useScrollLock'; import { Button } from '@/components/ui/button'; import { Typography } from '@/components/ui/typography'; import { Input } from '@/components/ui/input'; import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell } from '@/components/ui/table'; import { useLabels } from '@/features/settings/useCompanySettings'; import { type QuotationSetting } from '../types'; import type { SettingInput } from '../hooks/useQuotations'; type QuotationSettingsModalProps = { open: boolean; settings: QuotationSetting[]; onAdd: (input: SettingInput) => boolean; onDelete: (id: string) => void; onClose: () => void; }; export function QuotationSettingsModal({ open, settings, onAdd, onDelete, onClose, }: QuotationSettingsModalProps) { useScrollLock(open); // 모달 열린 동안 배경(부모) 스크롤 잠금 const label = useLabels(); // 회사 설정 용어(목표 마진 등) const [targetMargin, setTargetMargin] = useState(''); const [cardUseCount, setCardUseCount] = useState(''); if (!open) return null; // 세팅은 목표 마진율·카드 사용 횟수만. 낙찰 정책은 견적 생성으로 이관, 앵커링은 칸 rate(v1.2)로 대체. const handleAdd = (e: React.FormEvent) => { e.preventDefault(); const ok = onAdd({ targetMargin, cardUseCount }); if (ok) { setTargetMargin(''); setCardUseCount(''); } }; return (
견적 세팅 등록 및 관리
{/* Current settings */}
등록된 견적 세팅 목록
{label('target_margin')} 카드 사용 횟수 삭제 {settings.length === 0 && ( 등록된 견적 세팅이 없습니다. (리스트가 비어 있습니다) )} {settings.map((qs) => ( {qs.target_margin} {qs.card_use_count} ))}
{/* Add form */}
신규 견적 세팅 추가
{label('target_margin')} (%) setTargetMargin(e.target.value)} placeholder="예: 12" />
카드 사용 횟수 setCardUseCount(e.target.value)} placeholder="예: 3" />
{/* Footer */}
); }