import { Settings, Plus } from 'lucide-react'; import { useOverlayRouter } from '@/lib/useOverlayRouter'; import { PageContainer } from '@/components/layout/PageContainer'; import { PageToolbar, SearchInput } from '@/components/layout/PageToolbar'; import { TablePagination } from '@/components/ui/table-pagination'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { useServerList } from '@/lib/useServerList'; import { useQuotations } from '@/features/quotations/hooks/useQuotations'; import { useGetQuotation } from '@/api/generated/quotation/quotation'; import { QuotationTable } from '@/features/quotations/components/QuotationTable'; import { QuotationDetailSheet } from '@/features/quotations/components/QuotationDetailSheet'; import { QuotationCreateModal } from '@/features/quotations/components/QuotationCreateModal'; import { QuotationSettingsModal } from '@/features/quotations/components/QuotationSettingsModal'; import { QUOTATION_STATUS_OPTIONS, QUOTATION_TYPE_OPTIONS } from '@/features/quotations/types'; import type { ListQuotationsParams } from '@/api/generated/model/listQuotationsParams'; export default function QuotationPage() { // 검색/상태·유형 필터/페이지 상태 → 서버 쿼리 파라미터로 변환. const list = useServerList({ pageSize: 10, initialFilters: { status: 'ALL', type: 'ALL' } }); const statusFilter = list.filters.status; const typeFilter = list.filters.type; const statusOptions = QUOTATION_STATUS_OPTIONS; const typeOptions = QUOTATION_TYPE_OPTIONS; const params: ListQuotationsParams = { search: list.debouncedSearch || undefined, status: statusFilter !== 'ALL' ? statusFilter : undefined, type: typeFilter !== 'ALL' ? typeFilter : undefined, page: list.page, size: list.pageSize, }; const { products, partners, cards, quotations, total, quotationSettings, closeQuotation, addSetting, deleteSetting, createQuotation, } = useQuotations(params); const totalPages = list.totalPages(total); const overlay = useOverlayRouter(['detail', 'create', 'settings']); const detailId = overlay.get('detail'); const isCreateOpen = overlay.has('create'); const isSettingsOpen = overlay.has('settings'); // 상세 요약은 리스트에서 find 하지 않고 단건 API 로 받아온다(딥링크 시 리스트 의존 제거). const detailQuery = useGetQuotation(detailId ?? '', { query: { enabled: !!detailId } }); const activeQuotation = detailQuery.data?.quotation ?? null; return ( } > list.setSearch(e.target.value)} onKeyDown={(e) => e.key === 'Enter' && list.submitSearch()} placeholder="견적명 또는 견적 번호로 검색..." />
overlay.open('detail', id)} footer={ } /> {activeQuotation && ( )} {isCreateOpen && ( { const qtId = await createQuotation(input); if (qtId) overlay.open('detail', qtId); // 생성 완료된 실제 qt_id 로 상세(협상현황) 자동 오픈 return !!qtId; }} onClose={overlay.close} /> )} {isSettingsOpen && ( )}
); }