[feat] negodata: 견적·카드 검색/필터 서버사이드 전환 + 견적 상세 Sheet 리팩터
- 백엔드: quotation 목록 search 파라미터(name/number ILIKE) 추가; card 목록 is_wildcard 탭 필터 + total_nego/total_wild 탭 카운트 추가; status/type 코드 int 비교 보정 - 프론트: cards/quotation 검색·상태·유형 필터·페이지네이션을 useServerList 기반 서버사이드로 전환; 엔터 즉시검색 + 디바운스 500ms·최소 2글자; 죽은 client 필터 훅(useCardFilters/useQuotationFilters) 제거 - generated 파라미터/응답 타입 손보강(listCardsParams.is_wildcard, listQuotationsParams.search, resCardList.total_nego/total_wild) — orval 재생성 시 동일 - 견적 상세 Drawer→Sheet 분리, useOverlayParams→useOverlayRouter, CreateQuotationWizard→QuotationCreateModal Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
c3d96fb7d3
commit
6fa024137f
36 files changed
+1172
-967
No files matched your search
@@ -1,33 +1,43 @@
|
||||
import { Plus, BookOpen } from 'lucide-react';
|
||||
import { useOverlayParams } from '@/lib/useOverlayParams';
|
||||
import { useOverlayRouter } from '@/lib/useOverlayRouter';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { confirm } from '@/lib/confirm';
|
||||
import { PageContainer } from '@/components/layout/PageContainer';
|
||||
import { SearchInput } from '@/components/layout/PageToolbar';
|
||||
import { TablePagination } from '@/components/ui/table-pagination';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { useClientPagination } from '@/lib/useClientPagination';
|
||||
import { useServerList } from '@/lib/useServerList';
|
||||
import { useCards } from '@/features/cards/hooks/useCards';
|
||||
import { useCardFilters } from '@/features/cards/hooks/useCardFilters';
|
||||
import { useGetCard } from '@/api/generated/card/card';
|
||||
import { CardTable } from '@/features/cards/components/CardTable';
|
||||
import { CardFormSheet } from '@/features/cards/components/CardFormSheet';
|
||||
import type { CardTab, NegotiationCard } from '@/features/cards/types';
|
||||
import { mapCardData, type CardTab, type NegotiationCard } from '@/features/cards/types';
|
||||
import type { ListCardsParams } from '@/api/generated/model/listCardsParams';
|
||||
|
||||
export default function CardsPage() {
|
||||
const { cards, createCard, updateCard, deleteCard } = useCards();
|
||||
const { search, setSearch, activeTab, setActiveTab, filtered, counts } = useCardFilters(cards);
|
||||
const { page, setPage, pageSize, totalPages, totalCount, pageItems } = useClientPagination(filtered);
|
||||
// 검색/탭/페이지 상태(재사용 훅) → 서버 쿼리 파라미터로 변환.
|
||||
const list = useServerList({ pageSize: 10, initialFilters: { tab: 'ALL' } });
|
||||
const activeTab = list.filters.tab as CardTab;
|
||||
const params: ListCardsParams = {
|
||||
search: list.debouncedSearch || undefined,
|
||||
is_wildcard: activeTab === 'ALL' ? undefined : activeTab === 'WILD',
|
||||
page: list.page,
|
||||
size: list.pageSize,
|
||||
};
|
||||
const { cards, total, totalNego, totalWild, createCard, updateCard, deleteCard } = useCards(params);
|
||||
const totalPages = list.totalPages(total);
|
||||
|
||||
// 오버레이(폼)를 쿼리스트링으로 → 딥링크·뒤로가기·새로고침 지원.
|
||||
// ?edit=<id> 직접 접근 시 데이터 로드 후 수정 폼이 자동으로 열린다.
|
||||
const overlay = useOverlayParams(['new', 'edit']);
|
||||
const editId = overlay.get('edit');
|
||||
const editing = editId ? cards.find((c) => c.id === editId) ?? null : null;
|
||||
// ?detail=<id> 직접 접근 시 단건 API 로 받아 수정 폼을 연다(현재 페이지에 없어도 동작).
|
||||
const overlay = useOverlayRouter(['new', 'detail']);
|
||||
const editId = overlay.get('detail');
|
||||
const editQuery = useGetCard(editId ?? '', { query: { enabled: !!editId } });
|
||||
const editing: NegotiationCard | null = editQuery.data?.card ? mapCardData(editQuery.data.card) : null;
|
||||
const formMode: 'create' | 'edit' = editId ? 'edit' : 'create';
|
||||
const isFormOpen = overlay.has('new') || !!editing;
|
||||
|
||||
const openCreate = () => overlay.open('new');
|
||||
const openEdit = (card: NegotiationCard) => overlay.open('edit', card.id);
|
||||
const openEdit = (card: NegotiationCard) => overlay.open('detail', card.id);
|
||||
|
||||
const handleDeleteCard = async (id: string, cardName: string) => {
|
||||
if (await confirm({ title: '카드 삭제', description: `[${cardName}]을 삭제하시겠습니까?`, confirmText: '삭제', destructive: true })) {
|
||||
@@ -41,9 +51,9 @@ export default function CardsPage() {
|
||||
};
|
||||
|
||||
const tabs: { id: CardTab; label: string; count: number }[] = [
|
||||
{ id: 'ALL', label: '전체', count: counts.all },
|
||||
{ id: 'CARD', label: '협상카드', count: counts.card },
|
||||
{ id: 'WILD', label: '와일드카드', count: counts.wild },
|
||||
{ id: 'ALL', label: '전체', count: totalNego + totalWild },
|
||||
{ id: 'CARD', label: '협상카드', count: totalNego },
|
||||
{ id: 'WILD', label: '와일드카드', count: totalWild },
|
||||
];
|
||||
|
||||
return (
|
||||
@@ -76,7 +86,7 @@ export default function CardsPage() {
|
||||
<button
|
||||
key={tab.id}
|
||||
id={`card-tab-${tab.id.toLowerCase()}`}
|
||||
onClick={() => setActiveTab(tab.id)}
|
||||
onClick={() => list.setFilter('tab', tab.id)}
|
||||
className={`py-2 px-6 font-bold text-xs tracking-tight border-b-2 transition-all cursor-pointer ${
|
||||
activeTab === tab.id
|
||||
? 'border-primary text-primary'
|
||||
@@ -91,21 +101,22 @@ export default function CardsPage() {
|
||||
{/* Filtering Search Bar */}
|
||||
<SearchInput
|
||||
id="card-search"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
placeholder="전체 카드이름, 카드번호, 코드 및 핵심멘트 검색..."
|
||||
value={list.search}
|
||||
onChange={(e) => list.setSearch(e.target.value)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && list.submitSearch()}
|
||||
placeholder="전체 카드이름, 카드번호, 코드 검색..."
|
||||
/>
|
||||
|
||||
<CardTable
|
||||
data={pageItems}
|
||||
data={cards}
|
||||
onEdit={openEdit}
|
||||
footer={
|
||||
<TablePagination
|
||||
page={page}
|
||||
page={list.page}
|
||||
totalPages={totalPages}
|
||||
totalCount={totalCount}
|
||||
pageSize={pageSize}
|
||||
onPageChange={setPage}
|
||||
totalCount={total}
|
||||
pageSize={list.pageSize}
|
||||
onPageChange={list.setPage}
|
||||
label="전체 카드"
|
||||
unit="개"
|
||||
/>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Plus, Upload } from 'lucide-react';
|
||||
import { useOverlayParams } from '@/lib/useOverlayParams';
|
||||
import { useOverlayRouter } from '@/lib/useOverlayRouter';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { confirm } from '@/lib/confirm';
|
||||
import { PageContainer } from '@/components/layout/PageContainer';
|
||||
@@ -30,16 +30,16 @@ export default function PartnersPage() {
|
||||
const totalPages = list.totalPages(total);
|
||||
|
||||
// 오버레이(폼/엑셀)를 쿼리스트링으로 → 딥링크·뒤로가기·새로고침 지원.
|
||||
// ?edit=<id> 직접 접근 시 데이터 로드 후 수정 폼이 자동으로 열린다.
|
||||
const overlay = useOverlayParams(['new', 'edit', 'modal']);
|
||||
const editId = overlay.get('edit');
|
||||
// ?detail=<id> 직접 접근 시 데이터 로드 후 수정 폼이 자동으로 열린다.
|
||||
const overlay = useOverlayRouter(['new', 'detail', 'modal']);
|
||||
const editId = overlay.get('detail');
|
||||
const modal = overlay.get('modal'); // 'excel' | null
|
||||
const editing = editId ? allPartners.find((p) => p.supplier_id === editId) ?? null : null;
|
||||
const formMode: 'create' | 'edit' = editId ? 'edit' : 'create';
|
||||
const isFormOpen = overlay.has('new') || !!editing;
|
||||
|
||||
const openCreate = () => overlay.open('new');
|
||||
const openEdit = (part: Partner) => overlay.open('edit', part.supplier_id);
|
||||
const openEdit = (part: Partner) => overlay.open('detail', part.supplier_id);
|
||||
|
||||
const handleDeletePartner = async (id: string, partnerName: string) => {
|
||||
if (await confirm({ title: '협력사 삭제', description: `[${partnerName}] 파트너사를 협력사 목록에서 삭제하시겠습니까?`, confirmText: '삭제', destructive: true })) {
|
||||
@@ -73,6 +73,7 @@ export default function PartnersPage() {
|
||||
id="partner-search"
|
||||
value={list.search}
|
||||
onChange={(e) => list.setSearch(e.target.value)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && list.submitSearch()}
|
||||
placeholder="협력사명, 코드 또는 담당자명으로 추적 검색..."
|
||||
/>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useState } from 'react';
|
||||
import { Plus, Upload, TrendingDown } from 'lucide-react';
|
||||
import { useOverlayParams } from '@/lib/useOverlayParams';
|
||||
import { useOverlayRouter } from '@/lib/useOverlayRouter';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { confirm } from '@/lib/confirm';
|
||||
import { PageContainer } from '@/components/layout/PageContainer';
|
||||
@@ -45,17 +45,16 @@ export default function ProductsPage() {
|
||||
// 행 선택(테이블 체크박스 + 최저가 모달 대상)
|
||||
const [selectedIds, setSelectedIds] = useState<string[]>([]);
|
||||
|
||||
// 오버레이(폼/최저가/엑셀)를 쿼리스트링으로 → 딥링크·뒤로가기·새로고침 지원.
|
||||
// ?edit=<id> 직접 접근 시 데이터 로드 후 수정 폼이 자동으로 열린다.
|
||||
const overlay = useOverlayParams(['new', 'edit', 'modal']);
|
||||
const editId = overlay.get('edit');
|
||||
// 딥링크·뒤로가기·새로고침 지원
|
||||
const overlay = useOverlayRouter(['new', 'detail', 'modal']);
|
||||
const editId = overlay.get('detail');
|
||||
const modal = overlay.get('modal'); // 'price' | 'excel' | null
|
||||
const editing = editId ? allProducts.find((p) => p.item_id === editId) ?? null : null;
|
||||
const formMode: 'create' | 'edit' = editId ? 'edit' : 'create';
|
||||
const isFormOpen = overlay.has('new') || !!editing;
|
||||
|
||||
const openCreate = () => overlay.open('new');
|
||||
const openEdit = (prod: Product) => overlay.open('edit', prod.item_id);
|
||||
const openEdit = (prod: Product) => overlay.open('detail', prod.item_id);
|
||||
|
||||
const handleDeleteProduct = async (id: string, prodName: string) => {
|
||||
if (await confirm({ title: '상품 삭제', description: `[${prodName}] 상품 정보를 완전 삭제하시겠습니까?`, confirmText: '삭제', destructive: true })) {
|
||||
@@ -99,6 +98,7 @@ export default function ProductsPage() {
|
||||
id="product-search"
|
||||
value={list.search}
|
||||
onChange={(e) => list.setSearch(e.target.value)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && list.submitSearch()}
|
||||
placeholder="상품명 또는 상품 코드로 통합 검색..."
|
||||
/>
|
||||
|
||||
|
||||
@@ -1,43 +1,54 @@
|
||||
import { Settings, Plus } from 'lucide-react';
|
||||
import { useOverlayParams } from '@/lib/useOverlayParams';
|
||||
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 { useClientPagination } from '@/lib/useClientPagination';
|
||||
import { useServerList } from '@/lib/useServerList';
|
||||
import { useQuotations } from '@/features/quotations/hooks/useQuotations';
|
||||
import { useQuotationFilters } from '@/features/quotations/hooks/useQuotationFilters';
|
||||
import { useGetQuotation } from '@/api/generated/quotation/quotation';
|
||||
import { QuotationTable } from '@/features/quotations/components/QuotationTable';
|
||||
import { QuotationDetailDrawer } from '@/features/quotations/components/QuotationDetailDrawer';
|
||||
import { CreateQuotationWizard } from '@/features/quotations/components/CreateQuotationWizard';
|
||||
import { QuotationDetailSheet } from '@/features/quotations/components/QuotationDetailSheet';
|
||||
import { QuotationCreateModal } from '@/features/quotations/components/QuotationCreateModal';
|
||||
import { QuotationSettingsModal } from '@/features/quotations/components/QuotationSettingsModal';
|
||||
import { QUOTATION_STATUS_FILTERS } from '@/features/quotations/types';
|
||||
import { QUOTATION_STATUS_FILTERS, QUOTATION_STATUS_CODE, QUOTATION_TYPE_CODE } 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 params: ListQuotationsParams = {
|
||||
search: list.debouncedSearch || undefined,
|
||||
status: statusFilter !== 'ALL' ? String(QUOTATION_STATUS_CODE[statusFilter] ?? '') : undefined,
|
||||
type: typeFilter !== 'ALL' ? String(QUOTATION_TYPE_CODE[typeFilter] ?? '') : undefined,
|
||||
page: list.page,
|
||||
size: list.pageSize,
|
||||
};
|
||||
|
||||
const {
|
||||
products,
|
||||
partners,
|
||||
cards,
|
||||
quotations,
|
||||
total,
|
||||
quotationSettings,
|
||||
stopNegotiation,
|
||||
addSetting,
|
||||
deleteSetting,
|
||||
createQuotation,
|
||||
} = useQuotations();
|
||||
} = useQuotations(params);
|
||||
const totalPages = list.totalPages(total);
|
||||
|
||||
const { search, setSearch, statusFilter, setStatusFilter, typeFilter, setTypeFilter, filtered } =
|
||||
useQuotationFilters(quotations);
|
||||
const { page, setPage, pageSize, totalPages, totalCount, pageItems } = useClientPagination(filtered);
|
||||
|
||||
// 오버레이(상세/생성/세팅)를 쿼리스트링으로 → 딥링크·뒤로가기·새로고침 지원.
|
||||
// ?detail=<id> 로 직접 접근하면 데이터 로드 후 상세가 자동으로 열린다.
|
||||
const overlay = useOverlayParams(['detail', 'create', 'settings']);
|
||||
const overlay = useOverlayRouter(['detail', 'create', 'settings']);
|
||||
const detailId = overlay.get('detail');
|
||||
const isCreateOpen = overlay.has('create');
|
||||
const isSettingsOpen = overlay.has('settings');
|
||||
|
||||
const activeQuotation = quotations.find((e) => e.id === detailId) ?? null;
|
||||
// 상세 요약은 리스트에서 find 하지 않고 단건 API 로 받아온다(딥링크 시 리스트 의존 제거).
|
||||
const detailQuery = useGetQuotation(detailId ?? '', { query: { enabled: !!detailId } });
|
||||
const activeQuotation = detailQuery.data?.quotation ?? null;
|
||||
|
||||
return (
|
||||
<PageContainer>
|
||||
@@ -66,13 +77,14 @@ export default function QuotationPage() {
|
||||
>
|
||||
<SearchInput
|
||||
id="quotation-search"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
placeholder="견적명 또는 견적 번호로 실시간 서치..."
|
||||
value={list.search}
|
||||
onChange={(e) => list.setSearch(e.target.value)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && list.submitSearch()}
|
||||
placeholder="견적명 또는 견적 번호로 검색..."
|
||||
/>
|
||||
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<Select value={statusFilter} onValueChange={(v) => setStatusFilter(v as string)}>
|
||||
<Select value={statusFilter} onValueChange={(v) => list.setFilter('status', v as string)}>
|
||||
<SelectTrigger id="quotation-status-filter" className="font-bold">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
@@ -84,7 +96,7 @@ export default function QuotationPage() {
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
<Select value={typeFilter} onValueChange={(v) => setTypeFilter(v as string)}>
|
||||
<Select value={typeFilter} onValueChange={(v) => list.setFilter('type', v as string)}>
|
||||
<SelectTrigger id="quotation-type-filter">
|
||||
<SelectValue>
|
||||
{(value) => (value === 'ALL' ? '전체 유형' : value === 'RE_NEGOTIATION' ? '재협상' : '재견적')}
|
||||
@@ -100,16 +112,16 @@ export default function QuotationPage() {
|
||||
</PageToolbar>
|
||||
|
||||
<QuotationTable
|
||||
data={pageItems}
|
||||
data={quotations}
|
||||
products={products}
|
||||
onOpenDetail={(id) => overlay.open('detail', id)}
|
||||
footer={
|
||||
<TablePagination
|
||||
page={page}
|
||||
page={list.page}
|
||||
totalPages={totalPages}
|
||||
totalCount={totalCount}
|
||||
pageSize={pageSize}
|
||||
onPageChange={setPage}
|
||||
totalCount={total}
|
||||
pageSize={list.pageSize}
|
||||
onPageChange={list.setPage}
|
||||
label="전체 견적"
|
||||
unit="건"
|
||||
/>
|
||||
@@ -117,19 +129,16 @@ export default function QuotationPage() {
|
||||
/>
|
||||
|
||||
{activeQuotation && (
|
||||
<QuotationDetailDrawer
|
||||
key={activeQuotation.id}
|
||||
estimate={activeQuotation}
|
||||
products={products}
|
||||
partners={partners}
|
||||
quotationSettings={quotationSettings}
|
||||
<QuotationDetailSheet
|
||||
key={activeQuotation.qt_id}
|
||||
quotation={activeQuotation}
|
||||
onStop={stopNegotiation}
|
||||
onClose={overlay.close}
|
||||
/>
|
||||
)}
|
||||
|
||||
{isCreateOpen && (
|
||||
<CreateQuotationWizard
|
||||
<QuotationCreateModal
|
||||
open
|
||||
products={products}
|
||||
partners={partners}
|
||||
|
||||
Reference in new issue
Block a user