summaryrefslogtreecommitdiff
path: root/config/vendorInvestigationsColumnsConfig.ts
blob: 3d9a9825366994762ff8fa21dfc74fba684a5e36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
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",
    },
  ]