summaryrefslogtreecommitdiff
path: root/lib/vendors/rfq-history-table/rfq-history-table.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vendors/rfq-history-table/rfq-history-table.tsx')
-rw-r--r--lib/vendors/rfq-history-table/rfq-history-table.tsx172
1 files changed, 114 insertions, 58 deletions
diff --git a/lib/vendors/rfq-history-table/rfq-history-table.tsx b/lib/vendors/rfq-history-table/rfq-history-table.tsx
index 71830303..11a4bf9d 100644
--- a/lib/vendors/rfq-history-table/rfq-history-table.tsx
+++ b/lib/vendors/rfq-history-table/rfq-history-table.tsx
@@ -14,26 +14,38 @@ import { DataTableAdvancedToolbar } from "@/components/data-table/data-table-adv
import { getColumns } from "./rfq-history-table-columns"
import { getRfqHistory } from "../service"
import { RfqHistoryTableToolbarActions } from "./rfq-history-table-toolbar-actions"
-import { RfqItemsTableDialog } from "./rfq-items-table-dialog"
import { getRFQStatusIcon } from "@/lib/tasks/utils"
import { TooltipProvider } from "@/components/ui/tooltip"
+import { useRouter } from "next/navigation"
export interface RfqHistoryRow {
id: number;
+ rfqType: string | null;
+ status: string;
rfqCode: string | null;
+ projectInfo: string | null;
+ packageInfo: string | null;
+ materialInfo: string | null;
+ // 견적정보 세부 필드들
+ currency: string | null;
+ totalAmount: number | null;
+ leadTime: string | null;
+ paymentTerms: string | null;
+ incoterms: string | null;
+ shippingLocation: string | null;
+ contractInfo: string | null;
+ rfqSendDate: Date | null;
+ submittedAt: Date | null;
+ picName: string | null;
+ // 기존 필드들 (호환성을 위해 유지)
projectCode: string | null;
projectName: string | null;
description: string | null;
dueDate: Date;
- status: "DRAFT" | "PUBLISHED" | "EVALUATION" | "AWARDED";
vendorStatus: string;
- totalAmount: number | null;
- currency: string | null;
- leadTime: string | null;
itemCount: number;
tbeResult: string | null;
cbeResult: string | null;
- createdAt: Date;
items: {
rfqId: number;
id: number;
@@ -42,6 +54,7 @@ export interface RfqHistoryRow {
quantity: number | null;
uom: string | null;
}[];
+ actions?: any; // actions 컬럼용
}
interface RfqHistoryTableProps {
@@ -50,68 +63,117 @@ interface RfqHistoryTableProps {
Awaited<ReturnType<typeof getRfqHistory>>,
]
>
+ lng: string
+ vendorId: number
}
-export function VendorRfqHistoryTable({ promises }: RfqHistoryTableProps) {
- const [{ data, pageCount }] = React.use(promises)
+export function VendorRfqHistoryTable({ promises, lng, vendorId }: RfqHistoryTableProps) {
+ const [{ data = [], pageCount = 0 }] = React.use(promises)
+ const router = useRouter()
- const [rowAction, setRowAction] = React.useState<DataTableRowAction<RfqHistoryRow> | null>(null)
+ const [, setRowAction] = React.useState<DataTableRowAction<RfqHistoryRow> | null>(null)
- const [itemsModalOpen, setItemsModalOpen] = React.useState(false);
- const [selectedRfq, setSelectedRfq] = React.useState<RfqHistoryRow | null>(null);
-
- const openItemsModal = React.useCallback((rfqId: number) => {
- const rfq = data.find(r => r.id === rfqId);
- if (rfq) {
- setSelectedRfq(rfq);
- setItemsModalOpen(true);
- }
- }, [data]);
+ const onViewDetails = React.useCallback((rfqId: number) => {
+ router.push(`/${lng}/evcp/rfq-last/${rfqId}`);
+ }, [router, lng]);
const columns = React.useMemo(() => getColumns({
setRowAction,
- openItemsModal,
- }), [setRowAction, openItemsModal]);
+ onViewDetails,
+ }), [setRowAction, onViewDetails]);
const filterFields: DataTableFilterField<RfqHistoryRow>[] = [
{
- id: "rfqCode",
- label: "RFQ Code",
- placeholder: "Filter RFQ Code...",
+ id: "rfqType",
+ label: "견적종류",
+ options: [
+ { label: "ITB", value: "ITB" },
+ { label: "RFQ", value: "RFQ" },
+ { label: "일반", value: "일반" },
+ { label: "정기견적", value: "정기견적" }
+ ],
},
{
id: "status",
- label: "Status",
- options: ["DRAFT", "PUBLISHED", "EVALUATION", "AWARDED"].map((status) => ({
- label: toSentenceCase(status),
- value: status,
- icon: getRFQStatusIcon(status),
- })),
+ label: "견적상태",
+ options: [
+ { label: "ITB 발송", value: "ITB 발송" },
+ { label: "Short List 확정", value: "Short List 확정" },
+ { label: "최종업체선정", value: "최종업체선정" },
+ { label: "견적접수", value: "견적접수" },
+ { label: "견적평가중", value: "견적평가중" },
+ { label: "견적완료", value: "견적완료" }
+ ],
},
+ { id: "rfqCode", label: "견적번호", placeholder: "견적번호로 검색..." },
+ { id: "projectInfo", label: "프로젝트", placeholder: "프로젝트로 검색..." },
+ { id: "packageInfo", label: "PKG No.", placeholder: "PKG로 검색..." },
+ { id: "materialInfo", label: "자재그룹", placeholder: "자재그룹으로 검색..." },
{
- id: "vendorStatus",
- label: "Vendor Status",
- placeholder: "Filter Vendor Status...",
- }
+ id: "currency",
+ label: "통화",
+ options: [
+ { label: "USD", value: "USD" },
+ { label: "KRW", value: "KRW" },
+ { label: "EUR", value: "EUR" },
+ { label: "JPY", value: "JPY" }
+ ],
+ },
+ { id: "paymentTerms", label: "지급조건", placeholder: "지급조건으로 검색..." },
+ { id: "incoterms", label: "Incoterms", placeholder: "Incoterms로 검색..." },
+ { id: "shippingLocation", label: "선적지", placeholder: "선적지로 검색..." },
+ { id: "picName", label: "견적담당자", placeholder: "담당자로 검색..." },
]
const advancedFilterFields: DataTableAdvancedFilterField<RfqHistoryRow>[] = [
- { id: "rfqCode", label: "RFQ Code", type: "text" },
- { id: "projectCode", label: "Project Code", type: "text" },
- { id: "projectName", label: "Project Name", type: "text" },
- {
- id: "status",
- label: "RFQ Status",
+ {
+ id: "rfqType",
+ label: "견적종류",
+ type: "multi-select",
+ options: [
+ { label: "ITB", value: "ITB" },
+ { label: "RFQ", value: "RFQ" },
+ { label: "일반", value: "일반" },
+ { label: "정기견적", value: "정기견적" }
+ ],
+ },
+ {
+ id: "status",
+ label: "견적상태",
+ type: "multi-select",
+ options: [
+ { label: "ITB 발송", value: "ITB 발송" },
+ { label: "Short List 확정", value: "Short List 확정" },
+ { label: "최종업체선정", value: "최종업체선정" },
+ { label: "견적접수", value: "견적접수" },
+ { label: "견적평가중", value: "견적평가중" },
+ { label: "견적완료", value: "견적완료" }
+ ],
+ },
+ { id: "rfqCode", label: "견적번호", type: "text" },
+ { id: "projectInfo", label: "프로젝트", type: "text" },
+ { id: "packageInfo", label: "PKG No.", type: "text" },
+ { id: "materialInfo", label: "자재그룹", type: "text" },
+ {
+ id: "currency",
+ label: "통화",
type: "multi-select",
- options: ["DRAFT", "PUBLISHED", "EVALUATION", "AWARDED"].map((status) => ({
- label: toSentenceCase(status),
- value: status,
- icon: getRFQStatusIcon(status),
- })),
+ options: [
+ { label: "USD", value: "USD" },
+ { label: "KRW", value: "KRW" },
+ { label: "EUR", value: "EUR" },
+ { label: "JPY", value: "JPY" }
+ ],
},
- { id: "vendorStatus", label: "Vendor Status", type: "text" },
- { id: "dueDate", label: "Due Date", type: "date" },
- { id: "createdAt", label: "Created At", type: "date" },
+ { id: "totalAmount", label: "총 견적금액", type: "number" },
+ { id: "leadTime", label: "업체 L/T(W)", type: "text" },
+ { id: "paymentTerms", label: "지급조건", type: "text" },
+ { id: "incoterms", label: "Incoterms", type: "text" },
+ { id: "shippingLocation", label: "선적지", type: "text" },
+ { id: "contractInfo", label: "PO/계약정보", type: "text" },
+ { id: "rfqSendDate", label: "견적요청일", type: "date" },
+ { id: "submittedAt", label: "견적회신일", type: "date" },
+ { id: "picName", label: "견적담당자", type: "text" },
]
const { table } = useDataTable({
@@ -122,13 +184,13 @@ export function VendorRfqHistoryTable({ promises }: RfqHistoryTableProps) {
enablePinning: true,
enableAdvancedFilter: true,
initialState: {
- sorting: [{ id: "createdAt", desc: true }],
+ sorting: [{ id: "rfqSendDate", desc: true }],
columnPinning: { right: ["actions"] },
},
- getRowId: (originalRow) => String(originalRow.id),
- shallow: true,
+ getRowId: (originalRow, index) => originalRow?.id ? String(originalRow.id) : String(index),
+ shallow: false,
clearOnDefault: true,
- })
+ });
return (
<>
@@ -141,15 +203,9 @@ export function VendorRfqHistoryTable({ promises }: RfqHistoryTableProps) {
filterFields={advancedFilterFields}
shallow={false}
>
- <RfqHistoryTableToolbarActions table={table} />
</DataTableAdvancedToolbar>
</DataTable>
- <RfqItemsTableDialog
- open={itemsModalOpen}
- onOpenChange={setItemsModalOpen}
- items={selectedRfq?.items ?? []}
- />
</TooltipProvider>
</>
)