diff options
Diffstat (limited to 'config/vendorInvestigationsColumnsConfig.ts')
| -rw-r--r-- | config/vendorInvestigationsColumnsConfig.ts | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/config/vendorInvestigationsColumnsConfig.ts b/config/vendorInvestigationsColumnsConfig.ts new file mode 100644 index 00000000..3d9a9825 --- /dev/null +++ b/config/vendorInvestigationsColumnsConfig.ts @@ -0,0 +1,124 @@ +import { vendorInvestigationsView } from "@/db/schema/vendors" + +/** + * Drizzle will infer `contacts` and `possibleItems` as a JSON string or `unknown`. + * We override those with arrays that have the structure we built in the view. + */ +export type ContactItem = { + id: number + contactName: string + contactEmail: string + contactPhone: string | null + contactPosition: string | null + isPrimary: boolean + createdAt: Date + updatedAt: Date +} + +export type PossibleItem = { + id: number + vendorId: number + itemCode: string + createdAt: Date + updatedAt: Date +} + +// Drizzle-based type for the rest of the columns +type VendorInvestigationsViewRaw = typeof vendorInvestigationsView.$inferSelect + +/** + * Combine the Drizzle-inferred type with typed arrays + */ +export interface VendorInvestigationsViewWithContacts + extends Omit< + VendorInvestigationsViewRaw, + "contacts" | "possibleItems" + > { + contacts: ContactItem[] + possibleItems: PossibleItem[] +} + +export interface VendorInvestigationsColumnConfig { + id: keyof VendorInvestigationsViewWithContacts + label: string + group?: string + excelHeader?: string + type?: string + } + + // Example column config for vendorInvestigationsView + export const vendorInvestigationsColumnsConfig: VendorInvestigationsColumnConfig[] = [ + { + id: "investigationId", + label: "Investigation ID", + excelHeader: "Investigation ID", + group: "Investigation", + }, + { + id: "investigationStatus", + label: "Status", + excelHeader: "Status", + group: "Investigation", + }, + { + id: "scheduledStartAt", + label: "Scheduled Start", + excelHeader: "Scheduled Start", + group: "Investigation", + }, + { + id: "scheduledEndAt", + label: "Scheduled End", + excelHeader: "Scheduled End", + group: "Investigation", + }, + { + id: "completedAt", + label: "Completed At", + excelHeader: "Completed At", + group: "Investigation", + }, + { + id: "investigationNotes", + label: "Notes", + excelHeader: "Investigation Notes", + group: "Investigation", + }, + { + id: "vendorName", + label: "Vendor Name", + excelHeader: "Vendor Name", + group: "Vendor Info", + }, + { + id: "vendorCode", + label: "Vendor Code", + excelHeader: "Vendor Code", + group: "Vendor Info", + }, + { + id: "vendorEmail", + label: "Email", + excelHeader: "Email", + group: "Vendor Info", + }, + { + id: "vendorPhone", + label: "Phone", + excelHeader: "Phone", + group: "Vendor Info", + }, + // ... add more as needed ... + { + id: "investigationCreatedAt", + label: "Created At", + excelHeader: "Created At", + // group: "Metadata", + }, + { + id: "investigationUpdatedAt", + label: "Updated At", + excelHeader: "Updated At", + // group: "Metadata", + }, + ]
\ No newline at end of file |
