summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/po/table/po-table-columns.tsx95
-rw-r--r--lib/rfqs/table/rfqs-table.tsx2
-rw-r--r--lib/vendors/table/request-vendor-pg-dialog.tsx4
3 files changed, 82 insertions, 19 deletions
diff --git a/lib/po/table/po-table-columns.tsx b/lib/po/table/po-table-columns.tsx
index c2c01136..a13b2acf 100644
--- a/lib/po/table/po-table-columns.tsx
+++ b/lib/po/table/po-table-columns.tsx
@@ -91,16 +91,77 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<Contrac
// 3-1) groupMap: { [groupName]: ColumnDef<ContractDetail>[] }
const groupMap: Record<string, ColumnDef<ContractDetail>[]> = {};
- poColumnsConfig.forEach((cfg) => {
- // Use "_noGroup" if no group is specified
- const groupName = cfg.group || "_noGroup";
+ // (1) JSON config를 읽어서 ColumnDef를 생성하는 부분 (일부 발췌)
+poColumnsConfig.forEach((cfg) => {
+ const groupName = cfg.group || "_noGroup"
+ if (!groupMap[groupName]) {
+ groupMap[groupName] = []
+ }
- if (!groupMap[groupName]) {
- groupMap[groupName] = [];
- }
+ let childCol: ColumnDef<ContractDetail>
+
+ if (cfg.type === "custom" && cfg.customType === "esignStatus") {
+ // ========================================
+ // (2) 전자서명 전용 커스텀 컬럼
+ // ========================================
+ childCol = {
+ id: cfg.id,
+ header: ({ column }) => (
+ <DataTableColumnHeaderSimple column={column} title={cfg.label} />
+ ),
+ // 여기서 row.original.envelopes 등 활용하여 최신 전자서명 상태 표시
+ cell: ({ row }) => {
+ const data = row.original
+ if (!data.envelopes || data.envelopes.length === 0) {
+ return (
+ <div className="text-sm text-gray-500">
+ No E-Sign
+ </div>
+ )
+ }
+
+ // envelopes가 여러 개 있으면 최신(가장 최근 updatedAt) 가져오기
+ const sorted = [...data.envelopes].sort((a, b) => {
+ const dateA = new Date(a.updatedAt)
+ const dateB = new Date(b.updatedAt)
+ return dateB.getTime() - dateA.getTime()
+ })
+ const latest = sorted[0]
- // Child column definition
- const childCol: ColumnDef<ContractDetail> = {
+ // 상태에 따라 다른 UI 색상/아이콘
+ const status = latest.envelopeStatus // "sent", "completed", ...
+ const colorMap: Record<string, string> = {
+ completed: "text-green-600",
+ sent: "text-blue-600",
+ voided: "text-red-600",
+ // ...
+ }
+ const colorClass = colorMap[status] || "text-gray-700"
+
+ return (
+ <Button
+ onClick={() => {
+ // 다이얼로그 열기 등
+ // 예: setRowAction({ row, type: "esign-detail" })
+ setRowAction({ row, type: "esign-detail" })
+ }}
+ className={`underline underline-offset-2 ${colorClass}`}
+ >
+ {status}
+ </Button>
+ )
+ },
+ meta: {
+ excelHeader: cfg.excelHeader,
+ group: cfg.group,
+ type: cfg.type,
+ },
+ }
+ } else {
+ // ========================================
+ // (3) 일반 컬럼 (type: text/date/number 등)
+ // ========================================
+ childCol = {
accessorKey: cfg.id,
enableResizing: true,
header: ({ column }) => (
@@ -112,17 +173,19 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<Contrac
type: cfg.type,
},
cell: ({ row, cell }) => {
- if (cfg.id === "createdAt" || cfg.id === "updatedAt") {
- const dateVal = cell.getValue() as Date;
- return formatDate(dateVal);
+ // 날짜 포맷, 숫자 포맷 등 처리
+ if (cfg.type === "date") {
+ const dateVal = cell.getValue() as Date
+ return formatDate(dateVal)
}
-
- return row.getValue(cfg.id) ?? "";
+ // ...
+ return row.getValue(cfg.id) ?? ""
},
- };
+ }
+ }
- groupMap[groupName].push(childCol);
- });
+ groupMap[groupName].push(childCol)
+})
// ----------------------------------------------------------------
// 3-2) Create actual parent columns (groups) from the groupMap
diff --git a/lib/rfqs/table/rfqs-table.tsx b/lib/rfqs/table/rfqs-table.tsx
index 7d996816..48c04930 100644
--- a/lib/rfqs/table/rfqs-table.tsx
+++ b/lib/rfqs/table/rfqs-table.tsx
@@ -213,7 +213,7 @@ export function RfqsTable({ promises, rfqType = RfqType.PURCHASE }: RfqsTablePro
})
return (
- <div style={{ maxWidth: '80vw' }}>
+ <div style={{ maxWidth: '100vw' }}>
<DataTable
table={table}
floatingBar={<RfqsTableFloatingBar table={table} />}
diff --git a/lib/vendors/table/request-vendor-pg-dialog.tsx b/lib/vendors/table/request-vendor-pg-dialog.tsx
index b417f846..de23ad9b 100644
--- a/lib/vendors/table/request-vendor-pg-dialog.tsx
+++ b/lib/vendors/table/request-vendor-pg-dialog.tsx
@@ -70,7 +70,7 @@ export function RequestPQVendorsDialog({
<DialogTrigger asChild>
<Button variant="outline" size="sm" className="gap-2">
<SendHorizonal className="size-4" aria-hidden="true" />
- Request ({vendors.length})
+ PQ Request ({vendors.length})
</Button>
</DialogTrigger>
) : null}
@@ -114,7 +114,7 @@ export function RequestPQVendorsDialog({
<DrawerTrigger asChild>
<Button variant="outline" size="sm" className="gap-2">
<Check className="size-4" aria-hidden="true" />
- Request ({vendors.length})
+ PQ Request ({vendors.length})
</Button>
</DrawerTrigger>
) : null}