summaryrefslogtreecommitdiff
path: root/lib/techsales-rfq/table/project-detail-dialog.tsx
blob: b8219d7ff91c0909941f0d5b2741234769a12960 (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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
"use client"

import * as React from "react"
import {
  Dialog,
  DialogContent,
  DialogDescription,
  DialogHeader,
  DialogTitle,
} from "@/components/ui/dialog"
import { Badge } from "@/components/ui/badge"
import { Separator } from "@/components/ui/separator"
import { Button } from "@/components/ui/button"
import { formatDateToQuarter } from "@/lib/utils"

// 프로젝트 스냅샷 타입 정의
interface ProjectSnapshot {
  scDt?: string
  klDt?: string
  lcDt?: string
  dlDt?: string
  dockNo?: string
  dockNm?: string
  projNo?: string
  projNm?: string
  ownerNm?: string
  kunnrNm?: string
  cls1Nm?: string
  projMsrm?: number
  ptypeNm?: string
  sector?: string
  estmPm?: string
}

// 시리즈 스냅샷 타입 정의
interface SeriesSnapshot {
  sersNo?: string
  scDt?: string
  klDt?: string
  lcDt?: string
  dlDt?: string
  dockNo?: string
  dockNm?: string
}

// 기본적인 RFQ 타입 정의 (rfq-table.tsx와 일치)
interface TechSalesRfq {
  id: number
  rfqCode: string | null
  itemId: number
  itemName: string | null
  materialCode: string | null
  dueDate: Date
  rfqSendDate: Date | null
  status: "RFQ Created" | "RFQ Vendor Assignned" | "RFQ Sent" | "Quotation Analysis" | "Closed"
  picCode: string | null
  remark: string | null
  cancelReason: string | null
  createdAt: Date
  updatedAt: Date
  createdBy: number | null
  createdByName: string
  updatedBy: number | null
  updatedByName: string
  sentBy: number | null
  sentByName: string | null
  projectSnapshot: ProjectSnapshot | null
  seriesSnapshot: SeriesSnapshot[] | null
  pspid: string
  projNm: string
  sector: string
  projMsrm: number
  ptypeNm: string
  attachmentCount: number
  quotationCount: number
}

interface ProjectDetailDialogProps {
  open: boolean
  onOpenChange: (open: boolean) => void
  selectedRfq: TechSalesRfq | null
}

export function ProjectDetailDialog({
  open,
  onOpenChange,
  selectedRfq,
}: ProjectDetailDialogProps) {
  if (!selectedRfq) {
    return null
  }

  const projectSnapshot = selectedRfq.projectSnapshot
  const seriesSnapshot = selectedRfq.seriesSnapshot

  return (
    <Dialog open={open} onOpenChange={onOpenChange}>
      <DialogContent className="max-w-4xl w-[80vw] max-h-[80vh] overflow-hidden flex flex-col">
        <DialogHeader className="border-b pb-4">
          <DialogTitle className="flex items-center gap-2">
            프로젝트 상세정보
            <Badge variant="outline">{selectedRfq.pspid}</Badge>
          </DialogTitle>
          <DialogDescription className="space-y-1">
            <div className="flex items-center gap-2 text-base font-medium">
              <span>RFQ:</span>
              <Badge variant="secondary">{selectedRfq.rfqCode || "미할당"}</Badge>
              <span>|</span>
              <span>자재:</span>
              <span className="text-foreground">{selectedRfq.materialCode || "N/A"}</span>
            </div>
            <div className="text-sm text-muted-foreground">
              {selectedRfq.projNm} - {selectedRfq.ptypeNm} ({selectedRfq.itemName || "자재명 없음"})
            </div>
          </DialogDescription>
        </DialogHeader>
        <div className="space-y-6 p-1 overflow-y-auto">
          {/* 기본 프로젝트 정보 */}
          <div className="space-y-4">
            <h3 className="text-lg font-semibold">기본 정보</h3>
            <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
              <div className="space-y-2">
                <div className="text-sm font-medium text-muted-foreground">프로젝트 ID</div>
                <div className="text-sm">{selectedRfq.pspid}</div>
              </div>
              <div className="space-y-2">
                <div className="text-sm font-medium text-muted-foreground">프로젝트명</div>
                <div className="text-sm">{selectedRfq.projNm}</div>
              </div>
              <div className="space-y-2">
                <div className="text-sm font-medium text-muted-foreground">선종</div>
                <div className="text-sm">{selectedRfq.ptypeNm}</div>
              </div>
              <div className="space-y-2">
                <div className="text-sm font-medium text-muted-foreground">척수</div>
                <div className="text-sm">{selectedRfq.projMsrm}</div>
              </div>
              <div className="space-y-2">
                <div className="text-sm font-medium text-muted-foreground">섹터</div>
                <div className="text-sm">{selectedRfq.sector}</div>
              </div>
            </div>
          </div>

          <Separator />

          {/* 프로젝트 스냅샷 정보 */}
          {projectSnapshot && (
            <div className="space-y-4">
              <h3 className="text-lg font-semibold">프로젝트 스냅샷</h3>
              <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-4">
                {projectSnapshot.scDt && (
                  <div className="space-y-2">
                    <div className="text-sm font-medium text-muted-foreground">S/C</div>
                    <div className="text-sm">{formatDateToQuarter(projectSnapshot.scDt)}</div>
                  </div>
                )}
                {projectSnapshot.klDt && (
                  <div className="space-y-2">
                    <div className="text-sm font-medium text-muted-foreground">K/L</div>
                    <div className="text-sm">{formatDateToQuarter(projectSnapshot.klDt)}</div>
                  </div>
                )}
                {projectSnapshot.lcDt && (
                  <div className="space-y-2">
                    <div className="text-sm font-medium text-muted-foreground">L/C</div>
                    <div className="text-sm">{formatDateToQuarter(projectSnapshot.lcDt)}</div>
                  </div>
                )}
                {projectSnapshot.dlDt && (
                  <div className="space-y-2">
                    <div className="text-sm font-medium text-muted-foreground">D/L</div>
                    <div className="text-sm">{formatDateToQuarter(projectSnapshot.dlDt)}</div>
                  </div>
                )}
                {projectSnapshot.dockNo && (
                  <div className="space-y-2">
                    <div className="text-sm font-medium text-muted-foreground">도크번호</div>
                    <div className="text-sm">{projectSnapshot.dockNo}</div>
                  </div>
                )}
                {projectSnapshot.dockNm && (
                  <div className="space-y-2">
                    <div className="text-sm font-medium text-muted-foreground">도크명</div>
                    <div className="text-sm">{projectSnapshot.dockNm}</div>
                  </div>
                )}
                {projectSnapshot.projNo && (
                  <div className="space-y-2">
                    <div className="text-sm font-medium text-muted-foreground">공사번호</div>
                    <div className="text-sm">{projectSnapshot.projNo}</div>
                  </div>
                )}
                {projectSnapshot.projNm && (
                  <div className="space-y-2">
                    <div className="text-sm font-medium text-muted-foreground">공사명</div>
                    <div className="text-sm">{projectSnapshot.projNm}</div>
                  </div>
                )}
                {projectSnapshot.ownerNm && (
                  <div className="space-y-2">
                    <div className="text-sm font-medium text-muted-foreground">선주</div>
                    <div className="text-sm">{projectSnapshot.ownerNm}</div>
                  </div>
                )}
                {projectSnapshot.kunnrNm && (
                  <div className="space-y-2">
                    <div className="text-sm font-medium text-muted-foreground">선주명</div>
                    <div className="text-sm">{projectSnapshot.kunnrNm}</div>
                  </div>
                )}
                {projectSnapshot.cls1Nm && (
                  <div className="space-y-2">
                    <div className="text-sm font-medium text-muted-foreground">선급명</div>
                    <div className="text-sm">{projectSnapshot.cls1Nm}</div>
                  </div>
                )}
                {projectSnapshot.projMsrm && (
                  <div className="space-y-2">
                    <div className="text-sm font-medium text-muted-foreground">척수</div>
                    <div className="text-sm">{projectSnapshot.projMsrm}</div>
                  </div>
                )}
                {projectSnapshot.ptypeNm && (
                  <div className="space-y-2">
                    <div className="text-sm font-medium text-muted-foreground">선종명</div>
                    <div className="text-sm">{projectSnapshot.ptypeNm}</div>
                  </div>
                )}
                {projectSnapshot.sector && (
                  <div className="space-y-2">
                    <div className="text-sm font-medium text-muted-foreground">섹터</div>
                    <div className="text-sm">{projectSnapshot.sector}</div>
                  </div>
                )}
                {projectSnapshot.estmPm && (
                  <div className="space-y-2">
                    <div className="text-sm font-medium text-muted-foreground">견적 PM</div>
                    <div className="text-sm">{projectSnapshot.estmPm}</div>
                  </div>
                )}
              </div>
            </div>
          )}

          {/* 시리즈 스냅샷 정보 */}
          {seriesSnapshot && Array.isArray(seriesSnapshot) && seriesSnapshot.length > 0 && (
            <>
              <Separator />
              <div className="space-y-4">
                <h3 className="text-lg font-semibold">시리즈 정보 스냅샷</h3>
                <div className="space-y-4">
                  {seriesSnapshot.map((series: SeriesSnapshot, index: number) => (
                    <div key={index} className="border rounded-lg p-4 space-y-3">
                      <div className="flex items-center gap-2">
                        <Badge variant="secondary">시리즈 {series.sersNo || index + 1}</Badge>
                      </div>
                      <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
                        {series.scDt && (
                          <div className="space-y-1">
                            <div className="text-xs font-medium text-muted-foreground">S/C</div>
                            <div className="text-sm">{formatDateToQuarter(series.scDt)}</div>
                          </div>
                        )}
                        {series.klDt && (
                          <div className="space-y-1">
                            <div className="text-xs font-medium text-muted-foreground">K/L</div>
                            <div className="text-sm">{formatDateToQuarter(series.klDt)}</div>
                          </div>
                        )}
                        {series.lcDt && (
                          <div className="space-y-1">
                            <div className="text-xs font-medium text-muted-foreground">L/C</div>
                            <div className="text-sm">{formatDateToQuarter(series.lcDt)}</div>
                          </div>
                        )}
                        {series.dlDt && (
                          <div className="space-y-1">
                            <div className="text-xs font-medium text-muted-foreground">D/L</div>
                            <div className="text-sm">{formatDateToQuarter(series.dlDt)}</div>
                          </div>
                        )}
                        {series.dockNo && (
                          <div className="space-y-1">
                            <div className="text-xs font-medium text-muted-foreground">도크번호</div>
                            <div className="text-sm">{series.dockNo}</div>
                          </div>
                        )}
                        {series.dockNm && (
                          <div className="space-y-1">
                            <div className="text-xs font-medium text-muted-foreground">도크명</div>
                            <div className="text-sm">{series.dockNm}</div>
                          </div>
                        )}
                      </div>
                    </div>
                  ))}
                </div>
              </div>
            </>
          )}

          {/* 추가 정보가 없는 경우 */}
          {!projectSnapshot && !seriesSnapshot && (
            <div className="text-center py-8 text-muted-foreground">
              추가 프로젝트 상세정보가 없습니다.
            </div>
          )}
        </div>
        
        {/* 닫기 버튼 */}
        <div className="sticky bottom-0 left-0 z-20 bg-background border-t pt-4 mt-4">
          <div className="flex justify-end">
            <Button variant="outline" onClick={() => onOpenChange(false)}>
              닫기
            </Button>
          </div>
        </div>
      </DialogContent>
    </Dialog>
  )
}