diff options
Diffstat (limited to 'lib/pq/pq-review-table-new/vendors-table-columns.tsx')
| -rw-r--r-- | lib/pq/pq-review-table-new/vendors-table-columns.tsx | 114 |
1 files changed, 72 insertions, 42 deletions
diff --git a/lib/pq/pq-review-table-new/vendors-table-columns.tsx b/lib/pq/pq-review-table-new/vendors-table-columns.tsx index e3687f52..ffa15e56 100644 --- a/lib/pq/pq-review-table-new/vendors-table-columns.tsx +++ b/lib/pq/pq-review-table-new/vendors-table-columns.tsx @@ -122,25 +122,54 @@ export function getColumns({ setRowAction, router }: GetColumnsProps): ColumnDef // ----------------------------------------------------------------
const selectColumn: ColumnDef<PQSubmission> = {
id: "select",
- header: ({ table }) => (
- <Checkbox
- checked={
- table.getIsAllPageRowsSelected() ||
- (table.getIsSomePageRowsSelected() && "indeterminate")
- }
- onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
- aria-label="Select all"
- className="translate-y-0.5"
- />
- ),
- cell: ({ row }) => (
- <Checkbox
- checked={row.getIsSelected()}
- onCheckedChange={(value) => row.toggleSelected(!!value)}
- aria-label="Select row"
- className="translate-y-0.5"
- />
- ),
+ header: ({ table }) => {
+ const selectedRows = table.getSelectedRowModel().rows;
+ const isAllSelected = table.getIsAllPageRowsSelected();
+ const isSomeSelected = table.getIsSomePageRowsSelected();
+
+ return (
+ <Checkbox
+ checked={isAllSelected}
+ indeterminate={isSomeSelected && !isAllSelected}
+ onCheckedChange={(value) => {
+ if (value) {
+ // 전체 선택: 첫 번째 행만 선택
+ table.toggleAllRowsSelected(false);
+ if (table.getRowModel().rows.length > 0) {
+ table.getRowModel().rows[0].toggleSelected(true);
+ }
+ } else {
+ // 전체 해제
+ table.toggleAllRowsSelected(false);
+ }
+ }}
+ aria-label="Select all"
+ className="translate-y-0.5"
+ />
+ );
+ },
+ cell: ({ row, table }) => {
+ const selectedRows = table.getSelectedRowModel().rows;
+ const isCurrentlySelected = row.getIsSelected();
+
+ return (
+ <Checkbox
+ checked={isCurrentlySelected}
+ onCheckedChange={(value) => {
+ if (value) {
+ // 체크하려는 경우: 이미 선택된 행이 있으면 모두 해제하고 현재 행만 선택
+ table.toggleAllRowsSelected(false);
+ row.toggleSelected(true);
+ } else {
+ // 체크 해제하는 경우
+ row.toggleSelected(false);
+ }
+ }}
+ aria-label="Select row"
+ className="translate-y-0.5"
+ />
+ );
+ },
size: 40,
enableSorting: false,
enableHiding: false,
@@ -172,7 +201,7 @@ export function getColumns({ setRowAction, router }: GetColumnsProps): ColumnDef cell: ({ row }) => (
<div className="flex flex-col">
<span className="font-medium">{row.getValue("vendorName")}</span>
- <span className="text-xs text-muted-foreground">{row.original.vendorCode ? row.original.vendorCode : "-"}/{row.original.taxId}</span>
+ {/* <span className="text-xs text-muted-foreground">{row.original.vendorCode ? row.original.vendorCode : "-"}/{row.original.taxId}</span> */}
</div>
),
enableSorting: true,
@@ -408,6 +437,26 @@ export function getColumns({ setRowAction, router }: GetColumnsProps): ColumnDef )
},
}
+ const investigationRequestedAtColumn: ColumnDef<PQSubmission> = {
+ accessorKey: "investigationRequestedAt",
+ header: ({ column }) => (
+ <DataTableColumnHeaderSimple column={column} title="실사 의뢰일" />
+ ),
+ cell: ({ row }) => {
+ const investigation = row.original.investigation;
+
+ if (!investigation || !investigation.requestedAt) {
+ return <span className="text-muted-foreground">-</span>;
+ }
+ const dateVal = investigation.requestedAt
+
+ return (
+ <div className="flex items-center gap-2">
+ <span>{dateVal ? formatDate(dateVal, 'KR') : "-"}</span>
+ </div>
+ )
+ },
+ }
const investigationNotesColumn: ColumnDef<PQSubmission> = {
accessorKey: "investigationNotes",
@@ -484,26 +533,7 @@ export function getColumns({ setRowAction, router }: GetColumnsProps): ColumnDef }
- const investigationRequestedAtColumn: ColumnDef<PQSubmission> = {
- accessorKey: "investigationRequestedAt",
- header: ({ column }) => (
- <DataTableColumnHeaderSimple column={column} title="실사 의뢰일" />
- ),
- cell: ({ row }) => {
- const investigation = row.original.investigation;
-
- if (!investigation || !investigation.requestedAt) {
- return <span className="text-muted-foreground">-</span>;
- }
- const dateVal = investigation.requestedAt
- return (
- <div className="flex items-center gap-2">
- <span>{dateVal ? formatDate(dateVal, 'KR') : "-"}</span>
- </div>
- )
- },
- }
const investigationForecastedAtColumn: ColumnDef<PQSubmission> = {
@@ -651,9 +681,9 @@ export function getColumns({ setRowAction, router }: GetColumnsProps): ColumnDef )}
</DropdownMenuItem>
- {/* 방문실사 버튼 - 제품검사평가 또는 방문실사평가인 경우에만 표시 */}
- {pq.investigation &&
- (pq.investigation.investigationMethod === "PRODUCT_INSPECTION" ||
+ {/* 방문실사 버튼 - PQ가 승인됨 상태이고 제품검사평가 또는 방문실사평가인 경우에만 표시 */}
+ {pq.status === "APPROVED" && pq.investigation &&
+ (pq.investigation.investigationMethod === "PRODUCT_INSPECTION" ||
pq.investigation.investigationMethod === "SITE_VISIT_EVAL") && (
<>
<DropdownMenuItem
|
