summaryrefslogtreecommitdiff
path: root/lib/tech-vendors/table
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tech-vendors/table')
-rw-r--r--lib/tech-vendors/table/tech-vendors-table-columns.tsx9
-rw-r--r--lib/tech-vendors/table/tech-vendors-table.tsx43
-rw-r--r--lib/tech-vendors/table/update-vendor-sheet.tsx21
3 files changed, 59 insertions, 14 deletions
diff --git a/lib/tech-vendors/table/tech-vendors-table-columns.tsx b/lib/tech-vendors/table/tech-vendors-table-columns.tsx
index 093b5547..22e89dd0 100644
--- a/lib/tech-vendors/table/tech-vendors-table-columns.tsx
+++ b/lib/tech-vendors/table/tech-vendors-table-columns.tsx
@@ -230,6 +230,12 @@ export function getColumns({ setRowAction, router }: GetColumnsProps): ColumnDef
className: "bg-slate-800 text-white border-slate-900",
iconColor: "text-white"
};
+ case "PENDING_REVIEW":
+ return {
+ variant: "default",
+ className: "bg-gray-100 text-gray-800 border-gray-300",
+ iconColor: "text-gray-600"
+ };
default:
return {
variant: "default",
@@ -244,7 +250,8 @@ export function getColumns({ setRowAction, router }: GetColumnsProps): ColumnDef
const statusMap: StatusDisplayMap = {
"ACTIVE": "활성 상태",
"INACTIVE": "비활성 상태",
- "BLACKLISTED": "거래 금지"
+ "BLACKLISTED": "거래 금지",
+ "PENDING_REVIEW": "비교 견적",
};
return statusMap[status] || status;
diff --git a/lib/tech-vendors/table/tech-vendors-table.tsx b/lib/tech-vendors/table/tech-vendors-table.tsx
index d6e6f99f..63ca8fcc 100644
--- a/lib/tech-vendors/table/tech-vendors-table.tsx
+++ b/lib/tech-vendors/table/tech-vendors-table.tsx
@@ -13,7 +13,7 @@ import { DataTable } from "@/components/data-table/data-table"
import { DataTableAdvancedToolbar } from "@/components/data-table/data-table-advanced-toolbar"
import { getColumns } from "./tech-vendors-table-columns"
import { getTechVendors, getTechVendorStatusCounts } from "../service"
-import { TechVendor, techVendors } from "@/db/schema/techVendors"
+import { TechVendor, techVendors, TechVendorWithAttachments } from "@/db/schema/techVendors"
import { TechVendorsTableToolbarActions } from "./tech-vendors-table-toolbar-actions"
import { UpdateVendorSheet } from "./update-vendor-sheet"
import { getVendorStatusIcon } from "../utils"
@@ -49,13 +49,14 @@ export function TechVendorsTable({ promises }: TechVendorsTableProps) {
const statusMap: Record<string, string> = {
"ACTIVE": "활성 상태",
"INACTIVE": "비활성 상태",
- "BLACKLISTED": "거래 금지"
+ "BLACKLISTED": "거래 금지",
+ "PENDING_REVIEW": "비교 견적",
};
return statusMap[status] || status;
};
- const filterFields: DataTableFilterField<TechVendor>[] = [
+ const filterFields: DataTableFilterField<TechVendorWithAttachments>[] = [
{
id: "status",
label: "상태",
@@ -69,7 +70,7 @@ export function TechVendorsTable({ promises }: TechVendorsTableProps) {
{ id: "vendorCode", label: "업체 코드" },
]
- const advancedFilterFields: DataTableAdvancedFilterField<TechVendor>[] = [
+ const advancedFilterFields: DataTableAdvancedFilterField<TechVendorWithAttachments>[] = [
{ id: "vendorName", label: "업체명", type: "text" },
{ id: "vendorCode", label: "업체코드", type: "text" },
{ id: "email", label: "이메일", type: "text" },
@@ -85,6 +86,40 @@ export function TechVendorsTable({ promises }: TechVendorsTableProps) {
icon: getVendorStatusIcon(status),
})),
},
+ {
+ id: "techVendorType",
+ label: "벤더 타입",
+ type: "multi-select",
+ options: [
+ { label: "조선", value: "조선" },
+ { label: "해양TOP", value: "해양TOP" },
+ { label: "해양HULL", value: "해양HULL" },
+ ],
+ },
+ {
+ id: "workTypes",
+ label: "Work Type",
+ type: "multi-select",
+ options: [
+ // 조선 workTypes
+ { label: "기장", value: "기장" },
+ { label: "전장", value: "전장" },
+ { label: "선실", value: "선실" },
+ { label: "배관", value: "배관" },
+ { label: "철의", value: "철의" },
+ // 해양TOP workTypes
+ { label: "TM", value: "TM" },
+ { label: "TS", value: "TS" },
+ { label: "TE", value: "TE" },
+ { label: "TP", value: "TP" },
+ // 해양HULL workTypes
+ { label: "HA", value: "HA" },
+ { label: "HE", value: "HE" },
+ { label: "HH", value: "HH" },
+ { label: "HM", value: "HM" },
+ { label: "NC", value: "NC" },
+ ],
+ },
{ id: "createdAt", label: "등록일", type: "date" },
{ id: "updatedAt", label: "수정일", type: "date" },
]
diff --git a/lib/tech-vendors/table/update-vendor-sheet.tsx b/lib/tech-vendors/table/update-vendor-sheet.tsx
index 774299f1..1d05b0c4 100644
--- a/lib/tech-vendors/table/update-vendor-sheet.tsx
+++ b/lib/tech-vendors/table/update-vendor-sheet.tsx
@@ -8,9 +8,6 @@ import {
Activity,
AlertCircle,
AlertTriangle,
- ClipboardList,
- FilePenLine,
- XCircle,
Circle as CircleIcon,
Building,
} from "lucide-react"
@@ -83,6 +80,12 @@ const getStatusConfig = (status: StatusType): StatusConfig => {
className: "text-slate-800",
label: "거래 금지"
};
+ case "PENDING_REVIEW":
+ return {
+ Icon: AlertTriangle,
+ className: "text-slate-800",
+ label: "비교 견적"
+ };
default:
return {
Icon: CircleIcon,
@@ -109,7 +112,7 @@ export function UpdateVendorSheet({ vendor, ...props }: UpdateVendorSheetProps)
phone: vendor?.phone ?? "",
email: vendor?.email ?? "",
website: vendor?.website ?? "",
- techVendorType: vendor?.techVendorType ? vendor.techVendorType.split(',').filter(Boolean) : [],
+ techVendorType: vendor?.techVendorType ? vendor.techVendorType.split(',').map(s => s.trim()).filter(Boolean) as ("조선" | "해양TOP" | "해양HULL")[] : [],
status: vendor?.status ?? "ACTIVE",
},
})
@@ -124,7 +127,7 @@ export function UpdateVendorSheet({ vendor, ...props }: UpdateVendorSheetProps)
phone: vendor?.phone ?? "",
email: vendor?.email ?? "",
website: vendor?.website ?? "",
- techVendorType: vendor?.techVendorType ? vendor.techVendorType.split(',').filter(Boolean) : [],
+ techVendorType: vendor?.techVendorType ? vendor.techVendorType.split(',').map(s => s.trim()).filter(Boolean) as ("조선" | "해양TOP" | "해양HULL")[] : [],
status: vendor?.status ?? "ACTIVE",
});
@@ -157,7 +160,7 @@ export function UpdateVendorSheet({ vendor, ...props }: UpdateVendorSheetProps)
userId: Number(session.user.id), // Add user ID from session
comment: statusComment, // Add comment for status changes
...data, // 모든 데이터 전달 - 서비스 함수에서 필요한 필드만 처리
- techVendorType: data.techVendorType ? data.techVendorType.join(',') : undefined,
+ techVendorType: Array.isArray(data.techVendorType) ? data.techVendorType.join(',') : undefined,
})
if (error) throw new Error(error)
@@ -165,7 +168,7 @@ export function UpdateVendorSheet({ vendor, ...props }: UpdateVendorSheetProps)
toast.success("업체 정보가 업데이트되었습니다!")
form.reset()
props.onOpenChange?.(false)
- } catch (err: any) {
+ } catch (err: unknown) {
toast.error(String(err))
}
})
@@ -312,11 +315,11 @@ export function UpdateVendorSheet({ vendor, ...props }: UpdateVendorSheetProps)
id={`update-${type}`}
checked={field.value?.includes(type as "조선" | "해양TOP" | "해양HULL")}
onChange={(e) => {
- const currentValue = field.value || [];
+ const currentValue = Array.isArray(field.value) ? field.value : [];
if (e.target.checked) {
field.onChange([...currentValue, type]);
} else {
- field.onChange(currentValue.filter((v) => v !== type));
+ field.onChange(currentValue.filter((v: string) => v !== type));
}
}}
className="w-4 h-4"