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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
|
"use client"
import * as React from "react"
import { useRouter } from "next/navigation"
import { useForm } from "react-hook-form"
import { zodResolver } from "@hookform/resolvers/zod"
import { Loader2, Plus, Trash2, FileText, Paperclip, CheckCircle2, ChevronRight, ChevronLeft } from "lucide-react"
import { toast } from "sonner"
import { useSession } from "next-auth/react"
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogContent,
DialogTrigger,
DialogDescription,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog"
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
FormDescription,
} from "@/components/ui/form"
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
import { Input } from "@/components/ui/input"
import { Textarea } from "@/components/ui/textarea"
import { Switch } from "@/components/ui/switch"
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table"
import {
Dropzone,
DropzoneDescription,
DropzoneInput,
DropzoneTitle,
DropzoneUploadIcon,
DropzoneZone,
} from "@/components/ui/dropzone"
import {
FileList,
FileListAction,
FileListDescription,
FileListHeader,
FileListIcon,
FileListInfo,
FileListItem,
FileListName,
FileListSize,
} from "@/components/ui/file-list"
import { Checkbox } from "@/components/ui/checkbox"
import { createBidding, type CreateBiddingInput } from "@/lib/bidding/service"
import { getIncotermsForSelection, getPaymentTermsForSelection, getPlaceOfShippingForSelection, getPlaceOfDestinationForSelection } from "@/lib/procurement-select/service"
import { TAX_CONDITIONS } from "@/lib/tax-conditions/types"
import {
createBiddingSchema,
type CreateBiddingSchema
} from "@/lib/bidding/validation"
import {
biddingStatusLabels,
contractTypeLabels,
biddingTypeLabels,
awardCountLabels
} from "@/db/schema"
import { ProjectSelector } from "@/components/ProjectSelector"
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from "@/components/ui/alert-dialog"
// 사양설명회 정보 타입
interface SpecificationMeetingInfo {
meetingDate: string
meetingTime: string
location: string
address: string
contactPerson: string
contactPhone: string
contactEmail: string
agenda: string
materials: string
notes: string
isRequired: boolean
meetingFiles: File[] // 사양설명회 첨부파일
}
// PR 아이템 정보 타입
interface PRItemInfo {
id: string // 임시 ID for UI
prNumber: string
itemCode: string // 기존 itemNumber에서 변경
itemInfo: string
quantity: string
quantityUnit: string
totalWeight: string
weightUnit: string
materialDescription: string
hasSpecDocument: boolean
requestedDeliveryDate: string
specFiles: File[]
isRepresentative: boolean // 대표 아이템 여부
}
// 탭 순서 정의
const TAB_ORDER = ["basic", "schedule", "details", "manager"] as const
type TabType = typeof TAB_ORDER[number]
export function CreateBiddingDialog() {
const router = useRouter()
const [isSubmitting, setIsSubmitting] = React.useState(false)
const { data: session } = useSession()
const [open, setOpen] = React.useState(false)
const [activeTab, setActiveTab] = React.useState<TabType>("basic")
const [showSuccessDialog, setShowSuccessDialog] = React.useState(false) // 추가
const [createdBiddingId, setCreatedBiddingId] = React.useState<number | null>(null) // 추가
const [showCloseConfirmDialog, setShowCloseConfirmDialog] = React.useState(false) // 닫기 확인 다이얼로그 상태
// Procurement 데이터 상태들
const [paymentTermsOptions, setPaymentTermsOptions] = React.useState<Array<{code: string, description: string}>>([])
const [incotermsOptions, setIncotermsOptions] = React.useState<Array<{code: string, description: string}>>([])
const [shippingPlaces, setShippingPlaces] = React.useState<Array<{code: string, description: string}>>([])
const [destinationPlaces, setDestinationPlaces] = React.useState<Array<{code: string, description: string}>>([])
const [procurementLoading, setProcurementLoading] = React.useState(false)
// 사양설명회 정보 상태
const [specMeetingInfo, setSpecMeetingInfo] = React.useState<SpecificationMeetingInfo>({
meetingDate: "",
meetingTime: "",
location: "",
address: "",
contactPerson: "",
contactPhone: "",
contactEmail: "",
agenda: "",
materials: "",
notes: "",
isRequired: false,
meetingFiles: [], // 사양설명회 첨부파일
})
// PR 아이템들 상태 - 기본적으로 하나의 빈 아이템 생성
const [prItems, setPrItems] = React.useState<PRItemInfo[]>([
{
id: `pr-default`,
prNumber: "",
itemCode: "",
itemInfo: "",
quantity: "",
quantityUnit: "EA",
totalWeight: "",
weightUnit: "KG",
materialDescription: "",
hasSpecDocument: false,
requestedDeliveryDate: "",
specFiles: [],
isRepresentative: true, // 첫 번째 아이템은 대표 아이템
}
])
// 파일 첨부를 위해 선택된 아이템 ID
const [selectedItemForFile, setSelectedItemForFile] = React.useState<string | null>(null)
// 입찰 조건 상태 (기본값 설정 포함)
const [biddingConditions, setBiddingConditions] = React.useState({
paymentTerms: "", // 초기값 빈값, 데이터 로드 후 설정
taxConditions: "", // 초기값 빈값, 데이터 로드 후 설정
incoterms: "", // 초기값 빈값, 데이터 로드 후 설정
contractDeliveryDate: "",
shippingPort: "",
destinationPort: "",
isPriceAdjustmentApplicable: false,
sparePartOptions: "",
})
// Procurement 데이터 로드 함수들
const loadPaymentTerms = React.useCallback(async () => {
setProcurementLoading(true);
try {
const data = await getPaymentTermsForSelection();
setPaymentTermsOptions(data);
// 기본값 설정 로직: P008이 있으면 P008로, 없으면 첫 번째 항목으로 설정
const setDefaultPaymentTerms = () => {
const p008Exists = data.some(item => item.code === "P008");
if (p008Exists) {
setBiddingConditions(prev => ({ ...prev, paymentTerms: "P008" }));
}
};
setDefaultPaymentTerms();
} catch (error) {
console.error("Failed to load payment terms:", error);
toast.error("결제조건 목록을 불러오는데 실패했습니다.");
// 에러 시 기본값 초기화
if (biddingConditions.paymentTerms === "P008") {
setBiddingConditions(prev => ({ ...prev, paymentTerms: "" }));
}
} finally {
setProcurementLoading(false);
}
}, [biddingConditions.paymentTerms]);
const loadIncoterms = React.useCallback(async () => {
setProcurementLoading(true);
try {
const data = await getIncotermsForSelection();
setIncotermsOptions(data);
// 기본값 설정 로직: DAP가 있으면 DAP로, 없으면 첫 번째 항목으로 설정
const setDefaultIncoterms = () => {
const dapExists = data.some(item => item.code === "DAP");
if (dapExists) {
setBiddingConditions(prev => ({ ...prev, incoterms: "DAP" }));
}
};
setDefaultIncoterms();
} catch (error) {
console.error("Failed to load incoterms:", error);
toast.error("운송조건 목록을 불러오는데 실패했습니다.");
} finally {
setProcurementLoading(false);
}
}, [biddingConditions.incoterms]);
const loadShippingPlaces = React.useCallback(async () => {
setProcurementLoading(true);
try {
const data = await getPlaceOfShippingForSelection();
setShippingPlaces(data);
} catch (error) {
console.error("Failed to load shipping places:", error);
toast.error("선적지 목록을 불러오는데 실패했습니다.");
} finally {
setProcurementLoading(false);
}
}, []);
const loadDestinationPlaces = React.useCallback(async () => {
setProcurementLoading(true);
try {
const data = await getPlaceOfDestinationForSelection();
setDestinationPlaces(data);
} catch (error) {
console.error("Failed to load destination places:", error);
toast.error("하역지 목록을 불러오는데 실패했습니다.");
} finally {
setProcurementLoading(false);
}
}, []);
// 다이얼로그 열릴 때 procurement 데이터 로드 및 기본값 설정
React.useEffect(() => {
if (open) {
loadPaymentTerms();
loadIncoterms();
loadShippingPlaces();
loadDestinationPlaces();
// 세금조건 기본값 설정 (V1이 있는지 확인하고 설정)
const v1Exists = TAX_CONDITIONS.some(item => item.code === "V1");
if (v1Exists) {
setBiddingConditions(prev => ({ ...prev, taxConditions: "V1" }));
}
}
}, [open, loadPaymentTerms, loadIncoterms, loadShippingPlaces, loadDestinationPlaces])
// 사양설명회 파일 추가
const addMeetingFiles = (files: File[]) => {
setSpecMeetingInfo(prev => ({
...prev,
meetingFiles: [...prev.meetingFiles, ...files]
}))
}
// 사양설명회 파일 제거
const removeMeetingFile = (fileIndex: number) => {
setSpecMeetingInfo(prev => ({
...prev,
meetingFiles: prev.meetingFiles.filter((_, index) => index !== fileIndex)
}))
}
// PR 문서 첨부 여부 자동 계산
const hasPrDocuments = React.useMemo(() => {
return prItems.some(item => item.prNumber.trim() !== "" || item.specFiles.length > 0)
}, [prItems])
const form = useForm<CreateBiddingSchema>({
resolver: zodResolver(createBiddingSchema),
defaultValues: {
revision: 0,
projectId: 0, // 임시 기본값, validation에서 체크
projectName: "",
itemName: "",
title: "",
description: "",
content: "",
contractType: "general",
biddingType: "equipment",
biddingTypeCustom: "",
awardCount: "single",
contractStartDate: "",
contractEndDate: "",
submissionStartDate: "",
submissionEndDate: "",
hasSpecificationMeeting: false,
prNumber: "",
currency: "KRW",
budget: "",
targetPrice: "",
finalBidPrice: "",
status: "bidding_generated",
isPublic: false,
managerName: "",
managerEmail: "",
managerPhone: "",
remarks: "",
},
})
// 현재 탭 인덱스 계산
const currentTabIndex = TAB_ORDER.indexOf(activeTab)
const isLastTab = currentTabIndex === TAB_ORDER.length - 1
const isFirstTab = currentTabIndex === 0
// 다음/이전 탭으로 이동
const goToNextTab = () => {
if (!isLastTab) {
setActiveTab(TAB_ORDER[currentTabIndex + 1])
}
}
const goToPreviousTab = () => {
if (!isFirstTab) {
setActiveTab(TAB_ORDER[currentTabIndex - 1])
}
}
// 탭별 validation 상태 체크
const getTabValidationState = React.useCallback(() => {
const formValues = form.getValues()
const formErrors = form.formState.errors
return {
basic: {
isValid: formValues.title.trim() !== "",
hasErrors: !!(formErrors.title)
},
contract: {
isValid: formValues.contractType &&
formValues.biddingType &&
formValues.awardCount &&
formValues.contractStartDate &&
formValues.contractEndDate &&
formValues.currency,
hasErrors: !!(formErrors.contractType || formErrors.biddingType || formErrors.awardCount || formErrors.contractStartDate || formErrors.contractEndDate || formErrors.currency)
},
schedule: {
isValid: formValues.submissionStartDate &&
formValues.submissionEndDate &&
(!formValues.hasSpecificationMeeting ||
(specMeetingInfo.meetingDate && specMeetingInfo.location && specMeetingInfo.contactPerson)),
hasErrors: !!(formErrors.submissionStartDate || formErrors.submissionEndDate)
},
conditions: {
isValid: biddingConditions.paymentTerms.trim() !== "" &&
biddingConditions.taxConditions.trim() !== "" &&
biddingConditions.incoterms.trim() !== "" &&
biddingConditions.contractDeliveryDate.trim() !== "" &&
biddingConditions.shippingPort.trim() !== "" &&
biddingConditions.destinationPort.trim() !== "",
hasErrors: false
},
details: {
isValid: prItems.length > 0,
hasErrors: false
},
manager: {
isValid: true, // 담당자 정보는 자동 설정되므로 항상 유효
hasErrors: !!(formErrors.managerName || formErrors.managerEmail || formErrors.managerPhone)
}
}
}, [form, specMeetingInfo.meetingDate, specMeetingInfo.location, specMeetingInfo.contactPerson, biddingConditions])
const tabValidation = getTabValidationState()
// 현재 탭이 유효한지 확인
const isCurrentTabValid = () => {
const validation = tabValidation[activeTab as keyof typeof tabValidation]
return validation?.isValid ?? true
}
// 대표 PR 번호 자동 계산
const representativePrNumber = React.useMemo(() => {
const representativeItem = prItems.find(item => item.isRepresentative)
return representativeItem?.prNumber || ""
}, [prItems])
// 대표 품목명 자동 계산 (첫 번째 PR 아이템의 itemInfo)
const representativeItemName = React.useMemo(() => {
const representativeItem = prItems.find(item => item.isRepresentative)
return representativeItem?.itemInfo || ""
}, [prItems])
// hasPrDocument 필드와 prNumber, itemName을 자동으로 업데이트
React.useEffect(() => {
form.setValue("hasPrDocument", hasPrDocuments)
form.setValue("prNumber", representativePrNumber)
form.setValue("itemName", representativeItemName)
}, [hasPrDocuments, representativePrNumber, representativeItemName, form])
// 세션 정보로 담당자 정보 자동 채우기
React.useEffect(() => {
if (session?.user) {
// 담당자명 설정
if (session.user.name) {
form.setValue("managerName", session.user.name)
// 사양설명회 담당자도 동일하게 설정
setSpecMeetingInfo(prev => ({
...prev,
contactPerson: session.user.name || "",
contactEmail: session.user.email || "",
}))
}
// 담당자 이메일 설정
if (session.user.email) {
form.setValue("managerEmail", session.user.email)
}
// 담당자 전화번호는 세션에 있다면 설정 (보통 세션에 전화번호는 없지만, 있다면)
if ('phone' in session.user && session.user.phone) {
form.setValue("managerPhone", session.user.phone as string)
}
}
}, [session, form])
// PR 아이템 추가
const addPRItem = () => {
const newItem: PRItemInfo = {
id: `pr-${Math.random().toString(36).substr(2, 9)}`,
prNumber: "",
itemCode: "",
itemInfo: "",
quantity: "",
quantityUnit: "EA",
totalWeight: "",
weightUnit: "KG",
materialDescription: "",
hasSpecDocument: false,
requestedDeliveryDate: "",
specFiles: [],
isRepresentative: prItems.length === 0, // 첫 번째 아이템은 자동으로 대표 아이템
}
setPrItems(prev => [...prev, newItem])
}
// PR 아이템 제거
const removePRItem = (id: string) => {
// 최소 하나의 아이템은 유지해야 함
if (prItems.length <= 1) {
toast.error("최소 하나의 품목이 필요합니다.")
return
}
setPrItems(prev => {
const filteredItems = prev.filter(item => item.id !== id)
// 만약 대표 아이템을 삭제했다면, 첫 번째 아이템을 대표로 설정
const removedItem = prev.find(item => item.id === id)
if (removedItem?.isRepresentative && filteredItems.length > 0) {
filteredItems[0].isRepresentative = true
}
return filteredItems
})
// 파일 첨부 중인 아이템이면 선택 해제
if (selectedItemForFile === id) {
setSelectedItemForFile(null)
}
}
// PR 아이템 업데이트
const updatePRItem = (id: string, updates: Partial<PRItemInfo>) => {
setPrItems(prev => prev.map(item =>
item.id === id ? { ...item, ...updates } : item
))
}
// 대표 아이템 설정 (하나만 선택 가능)
const setRepresentativeItem = (id: string) => {
setPrItems(prev => prev.map(item => ({
...item,
isRepresentative: item.id === id
})))
}
// 스펙 파일 추가
const addSpecFiles = (itemId: string, files: File[]) => {
updatePRItem(itemId, {
specFiles: [...(prItems.find(item => item.id === itemId)?.specFiles || []), ...files]
})
// 파일 추가 후 선택 해제
setSelectedItemForFile(null)
}
// 스펙 파일 제거
const removeSpecFile = (itemId: string, fileIndex: number) => {
const item = prItems.find(item => item.id === itemId)
if (item) {
const newFiles = item.specFiles.filter((_, index) => index !== fileIndex)
updatePRItem(itemId, { specFiles: newFiles })
}
}
// ✅ 프로젝트 선택 핸들러
const handleProjectSelect = React.useCallback((project: { id: number; code: string; name: string } | null) => {
if (project) {
form.setValue("projectId", project.id)
} else {
form.setValue("projectId", 0)
}
}, [form])
// 다음 버튼 클릭 핸들러
const handleNextClick = () => {
// 현재 탭 validation 체크
if (!isCurrentTabValid()) {
// 특정 탭별 에러 메시지
if (activeTab === "basic") {
toast.error("기본 정보를 모두 입력해주세요 (품목명, 입찰명)")
} else if (activeTab === "contract") {
toast.error("계약 정보를 모두 입력해주세요")
} else if (activeTab === "schedule") {
if (form.watch("hasSpecificationMeeting")) {
toast.error("사양설명회 필수 정보를 입력해주세요 (회의일시, 장소, 담당자)")
} else {
toast.error("제출 시작일시와 마감일시를 입력해주세요")
}
} else if (activeTab === "conditions") {
toast.error("입찰 조건을 모두 입력해주세요 (지급조건, 세금조건, 운송조건, 계약납품일)")
} else if (activeTab === "details") {
toast.error("품목정보, 수량/단위 또는 중량/중량단위를 입력해주세요")
}
return
}
goToNextTab()
}
// 폼 제출
async function onSubmit(data: CreateBiddingSchema) {
// 사양설명회 필수값 검증
if (data.hasSpecificationMeeting) {
const requiredFields = [
{ field: specMeetingInfo.meetingDate, name: "회의일시" },
{ field: specMeetingInfo.location, name: "회의 장소" },
{ field: specMeetingInfo.contactPerson, name: "담당자" }
]
const missingFields = requiredFields.filter(item => !item.field.trim())
if (missingFields.length > 0) {
toast.error(`사양설명회 필수 정보가 누락되었습니다: ${missingFields.map(f => f.name).join(", ")}`)
setActiveTab("schedule")
return
}
}
setIsSubmitting(true)
try {
const userId = session?.user?.id?.toString() || "1"
// 추가 데이터 준비
const extendedData = {
...data,
hasPrDocument: hasPrDocuments, // 자동 계산된 값 사용
prNumber: representativePrNumber, // 대표 아이템의 PR 번호 사용
specificationMeeting: data.hasSpecificationMeeting ? {
...specMeetingInfo,
meetingFiles: specMeetingInfo.meetingFiles
} : null,
prItems: prItems.length > 0 ? prItems : [],
biddingConditions: biddingConditions,
}
const result = await createBidding(extendedData, userId)
if (result.success) {
toast.success((result as { success: true; message: string }).message || "입찰이 성공적으로 생성되었습니다.")
setOpen(false)
router.refresh()
// 생성된 입찰 상세페이지로 이동할지 묻기
if (result.success && 'data' in result && result.data?.id) {
setCreatedBiddingId(result.data.id)
setShowSuccessDialog(true)
}
} else {
const errorMessage = result.success === false && 'error' in result ? result.error : "입찰 생성에 실패했습니다."
toast.error(errorMessage)
}
} catch (error) {
console.error("Error creating bidding:", error)
toast.error("입찰 생성 중 오류가 발생했습니다.")
} finally {
setIsSubmitting(false)
}
}
// 폼 및 상태 초기화 함수
const resetAllStates = React.useCallback(() => {
// 폼 초기화
form.reset({
revision: 0,
projectId: 0,
projectName: "",
itemName: "",
title: "",
description: "",
content: "",
contractType: "general",
biddingType: "equipment",
biddingTypeCustom: "",
awardCount: "single",
contractStartDate: "",
contractEndDate: "",
submissionStartDate: "",
submissionEndDate: "",
hasSpecificationMeeting: false,
prNumber: "",
currency: "KRW",
status: "bidding_generated",
isPublic: false,
managerName: "",
managerEmail: "",
managerPhone: "",
remarks: "",
})
// 추가 상태들 초기화
setSpecMeetingInfo({
meetingDate: "",
meetingTime: "",
location: "",
address: "",
contactPerson: "",
contactPhone: "",
contactEmail: "",
agenda: "",
materials: "",
notes: "",
isRequired: false,
meetingFiles: [],
})
setPrItems([
{
id: `pr-default`,
prNumber: "",
itemCode: "",
itemInfo: "",
quantity: "",
quantityUnit: "EA",
totalWeight: "",
weightUnit: "KG",
materialDescription: "",
hasSpecDocument: false,
requestedDeliveryDate: "",
specFiles: [],
isRepresentative: true, // 첫 번째 아이템은 대표 아이템
}
])
setSelectedItemForFile(null)
setBiddingConditions({
paymentTerms: "",
taxConditions: "",
incoterms: "",
contractDeliveryDate: "",
shippingPort: "",
destinationPort: "",
isPriceAdjustmentApplicable: false,
sparePartOptions: "",
})
setActiveTab("basic")
setShowSuccessDialog(false) // 추가
setCreatedBiddingId(null) // 추가
}, [form])
// 다이얼로그 핸들러
function handleDialogOpenChange(nextOpen: boolean) {
if (!nextOpen) {
// 닫으려 할 때 확인 창을 먼저 띄움
setShowCloseConfirmDialog(true)
} else {
// 열 때는 바로 적용
setOpen(nextOpen)
}
}
// 닫기 확인 핸들러
const handleCloseConfirm = (confirmed: boolean) => {
setShowCloseConfirmDialog(false)
if (confirmed) {
// 사용자가 "예"를 선택한 경우 실제로 닫기
resetAllStates()
setOpen(false)
}
// "아니오"를 선택한 경우는 아무것도 하지 않음 (다이얼로그 유지)
}
// 입찰 생성 버튼 클릭 핸들러 추가
const handleCreateBidding = () => {
// 마지막 탭 validation 체크
if (!isCurrentTabValid()) {
toast.error("필수 정보를 모두 입력해주세요.")
return
}
// 수동으로 폼 제출
form.handleSubmit(onSubmit)()
}
// 성공 다이얼로그 핸들러들
const handleNavigateToDetail = () => {
if (createdBiddingId) {
router.push(`/evcp/bid/${createdBiddingId}`)
}
setShowSuccessDialog(false)
setCreatedBiddingId(null)
}
const handleStayOnPage = () => {
setShowSuccessDialog(false)
setCreatedBiddingId(null)
}
return (
<>
<Dialog open={open} onOpenChange={handleDialogOpenChange}>
<DialogTrigger asChild>
<Button variant="default" size="sm">
<Plus className="mr-2 h-4 w-4" />
신규 입찰
</Button>
</DialogTrigger>
<DialogContent className="max-w-7xl h-[90vh] p-0 flex flex-col">
{/* 고정 헤더 */}
<div className="flex-shrink-0 p-6 border-b">
<DialogHeader>
<DialogTitle>신규 입찰 생성</DialogTitle>
<DialogDescription>
새로운 입찰을 생성합니다. 단계별로 정보를 입력해주세요.
</DialogDescription>
</DialogHeader>
</div>
<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="flex flex-col flex-1 min-h-0"
id="create-bidding-form"
>
{/* 탭 영역 */}
<div className="flex-1 overflow-hidden">
<Tabs value={activeTab} onValueChange={(value) => setActiveTab(value as TabType)} className="h-full flex flex-col">
<div className="px-6">
<div className="flex space-x-1 bg-muted p-1 rounded-lg overflow-x-auto">
<button
type="button"
onClick={() => setActiveTab("basic")}
className={`relative px-3 py-2 text-sm font-medium rounded-md transition-all whitespace-nowrap flex-shrink-0 ${
activeTab === "basic"
? "bg-background text-foreground shadow-sm"
: "text-muted-foreground hover:text-foreground"
}`}
>
기본정보
{!tabValidation.basic.isValid && (
<span className="absolute -top-1 -right-1 h-2 w-2 bg-red-500 rounded-full"></span>
)}
</button>
<button
type="button"
onClick={() => setActiveTab("schedule")}
className={`relative px-3 py-2 text-sm font-medium rounded-md transition-all whitespace-nowrap flex-shrink-0 ${
activeTab === "schedule"
? "bg-background text-foreground shadow-sm"
: "text-muted-foreground hover:text-foreground"
}`}
>
입찰계획
{!tabValidation.schedule.isValid && (
<span className="absolute -top-1 -right-1 h-2 w-2 bg-red-500 rounded-full"></span>
)}
</button>
<button
type="button"
onClick={() => setActiveTab("details")}
className={`relative px-3 py-2 text-sm font-medium rounded-md transition-all whitespace-nowrap flex-shrink-0 ${
activeTab === "details"
? "bg-background text-foreground shadow-sm"
: "text-muted-foreground hover:text-foreground"
}`}
>
세부내역
{!tabValidation.details.isValid && (
<span className="absolute -top-1 -right-1 h-2 w-2 bg-red-500 rounded-full"></span>
)}
</button>
<button
type="button"
onClick={() => setActiveTab("manager")}
className={`relative px-3 py-2 text-sm font-medium rounded-md transition-all whitespace-nowrap flex-shrink-0 ${
activeTab === "manager"
? "bg-background text-foreground shadow-sm"
: "text-muted-foreground hover:text-foreground"
}`}
>
담당자
</button>
</div>
</div>
<div className="flex-1 overflow-y-auto p-6">
{/* 기본 정보 탭 */}
<TabsContent value="basic" className="mt-0 space-y-6">
<Card>
<CardHeader>
<CardTitle>기본 정보 및 계약 정보</CardTitle>
</CardHeader>
<CardContent className="space-y-6">
{/* 프로젝트 선택 */}
<FormField
control={form.control}
name="projectId"
render={({ field }) => (
<FormItem>
<FormLabel>
프로젝트
</FormLabel>
<FormControl>
<ProjectSelector
selectedProjectId={field.value}
onProjectSelect={handleProjectSelect}
placeholder="프로젝트 선택..."
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{/* <div className="grid grid-cols-2 gap-6"> */}
{/* 품목명 */}
{/* <FormField
control={form.control}
name="itemName"
render={({ field }) => (
<FormItem>
<FormLabel>
품목명 <span className="text-red-500">*</span>
</FormLabel>
<FormControl>
<Input
placeholder="품목명"
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/> */}
{/* 리비전 */}
{/* <FormField
control={form.control}
name="revision"
render={({ field }) => (
<FormItem>
<FormLabel>리비전</FormLabel>
<FormControl>
<Input
type="number"
min="0"
{...field}
onChange={(e) => field.onChange(parseInt(e.target.value) || 0)}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/> */}
{/* </div> */}
{/* 입찰명 */}
<FormField
control={form.control}
name="title"
render={({ field }) => (
<FormItem>
<FormLabel>
입찰명 <span className="text-red-500">*</span>
</FormLabel>
<FormControl>
<Input
placeholder="입찰명을 입력하세요"
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{/* 설명 */}
<FormField
control={form.control}
name="description"
render={({ field }) => (
<FormItem>
<FormLabel>설명</FormLabel>
<FormControl>
<Textarea
placeholder="입찰에 대한 설명을 입력하세요"
rows={4}
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{/* 계약 정보 섹션 */}
<div className="grid grid-cols-2 gap-6">
{/* 계약구분 */}
<FormField
control={form.control}
name="contractType"
render={({ field }) => (
<FormItem>
<FormLabel>
계약구분 <span className="text-red-500">*</span>
</FormLabel>
<Select onValueChange={field.onChange} defaultValue={field.value}>
<FormControl>
<SelectTrigger>
<SelectValue placeholder="계약구분 선택" />
</SelectTrigger>
</FormControl>
<SelectContent>
{Object.entries(contractTypeLabels).map(([value, label]) => (
<SelectItem key={value} value={value}>
{label}
</SelectItem>
))}
</SelectContent>
</Select>
<FormMessage />
</FormItem>
)}
/>
{/* 입찰유형 */}
<FormField
control={form.control}
name="biddingType"
render={({ field }) => (
<FormItem>
<FormLabel>
입찰유형 <span className="text-red-500">*</span>
</FormLabel>
<Select onValueChange={field.onChange} defaultValue={field.value}>
<FormControl>
<SelectTrigger>
<SelectValue placeholder="입찰유형 선택" />
</SelectTrigger>
</FormControl>
<SelectContent>
{Object.entries(biddingTypeLabels).map(([value, label]) => (
<SelectItem key={value} value={value}>
{label}
</SelectItem>
))}
</SelectContent>
</Select>
<FormMessage />
</FormItem>
)}
/>
{/* 기타 입찰유형 직접입력 */}
{form.watch("biddingType") === "other" && (
<FormField
control={form.control}
name="biddingTypeCustom"
render={({ field }) => (
<FormItem>
<FormLabel>
기타 입찰유형 <span className="text-red-500">*</span>
</FormLabel>
<FormControl>
<Input
placeholder="직접 입력하세요"
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
)}
</div>
<div className="grid grid-cols-2 gap-6">
{/* 낙찰수 */}
<FormField
control={form.control}
name="awardCount"
render={({ field }) => (
<FormItem>
<FormLabel>
낙찰수 <span className="text-red-500">*</span>
</FormLabel>
<Select onValueChange={field.onChange} defaultValue={field.value}>
<FormControl>
<SelectTrigger>
<SelectValue placeholder="낙찰수 선택" />
</SelectTrigger>
</FormControl>
<SelectContent>
{Object.entries(awardCountLabels).map(([value, label]) => (
<SelectItem key={value} value={value}>
{label}
</SelectItem>
))}
</SelectContent>
</Select>
<FormMessage />
</FormItem>
)}
/>
{/* 계약 시작일 */}
<FormField
control={form.control}
name="contractStartDate"
render={({ field }) => (
<FormItem>
<FormLabel>계약 시작일 <span className="text-red-500">*</span></FormLabel>
<FormControl>
<Input
type="date"
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{/* 계약 종료일 */}
<FormField
control={form.control}
name="contractEndDate"
render={({ field }) => (
<FormItem>
<FormLabel>계약 종료일 <span className="text-red-500">*</span></FormLabel>
<FormControl>
<Input
type="date"
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
{/* 통화 선택만 유지 */}
<FormField
control={form.control}
name="currency"
render={({ field }) => (
<FormItem>
<FormLabel>
통화 <span className="text-red-500">*</span>
</FormLabel>
<Select onValueChange={field.onChange} defaultValue={field.value}>
<FormControl>
<SelectTrigger>
<SelectValue placeholder="통화 선택" />
</SelectTrigger>
</FormControl>
<SelectContent>
<SelectItem value="KRW">KRW (원)</SelectItem>
<SelectItem value="USD">USD (달러)</SelectItem>
<SelectItem value="EUR">EUR (유로)</SelectItem>
<SelectItem value="JPY">JPY (엔)</SelectItem>
</SelectContent>
</Select>
<FormMessage />
</FormItem>
)}
/>
{/* 입찰 조건 섹션 */}
<Card>
<CardHeader>
<CardTitle>입찰 조건</CardTitle>
<p className="text-sm text-muted-foreground">
벤더가 사전견적 시 참고할 입찰 조건을 설정하세요
</p>
</CardHeader>
<CardContent className="space-y-6">
<div className="grid grid-cols-2 gap-6">
<div className="space-y-2">
<label className="text-sm font-medium">
지급조건 <span className="text-red-500">*</span>
</label>
<Select
value={biddingConditions.paymentTerms}
onValueChange={(value) => setBiddingConditions(prev => ({
...prev,
paymentTerms: value
}))}
>
<SelectTrigger>
<SelectValue placeholder="지급조건 선택" />
</SelectTrigger>
<SelectContent>
{paymentTermsOptions.length > 0 ? (
paymentTermsOptions.map((option) => (
<SelectItem key={option.code} value={option.code}>
{option.code} {option.description && `(${option.description})`}
</SelectItem>
))
) : (
<SelectItem value="loading" disabled>
데이터를 불러오는 중...
</SelectItem>
)}
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<label className="text-sm font-medium">
세금조건 <span className="text-red-500">*</span>
</label>
<Select
value={biddingConditions.taxConditions}
onValueChange={(value) => setBiddingConditions(prev => ({
...prev,
taxConditions: value
}))}
>
<SelectTrigger>
<SelectValue placeholder="세금조건 선택" />
</SelectTrigger>
<SelectContent>
{TAX_CONDITIONS.map((condition) => (
<SelectItem key={condition.code} value={condition.code}>
{condition.name}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<label className="text-sm font-medium">
운송조건(인코텀즈) <span className="text-red-500">*</span>
</label>
<Select
value={biddingConditions.incoterms}
onValueChange={(value) => setBiddingConditions(prev => ({
...prev,
incoterms: value
}))}
>
<SelectTrigger>
<SelectValue placeholder="인코텀즈 선택" />
</SelectTrigger>
<SelectContent>
{incotermsOptions.length > 0 ? (
incotermsOptions.map((option) => (
<SelectItem key={option.code} value={option.code}>
{option.code} {option.description && `(${option.description})`}
</SelectItem>
))
) : (
<SelectItem value="loading" disabled>
데이터를 불러오는 중...
</SelectItem>
)}
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<label className="text-sm font-medium">
계약 납품일 <span className="text-red-500">*</span>
</label>
<Input
type="date"
value={biddingConditions.contractDeliveryDate}
onChange={(e) => setBiddingConditions(prev => ({
...prev,
contractDeliveryDate: e.target.value
}))}
/>
</div>
<div className="space-y-2">
<label className="text-sm font-medium">선적지 (선택사항)</label>
<Select
value={biddingConditions.shippingPort}
onValueChange={(value) => setBiddingConditions(prev => ({
...prev,
shippingPort: value
}))}
>
<SelectTrigger>
<SelectValue placeholder="선적지 선택" />
</SelectTrigger>
<SelectContent>
{shippingPlaces.length > 0 ? (
shippingPlaces.map((place) => (
<SelectItem key={place.code} value={place.code}>
{place.code} {place.description && `(${place.description})`}
</SelectItem>
))
) : (
<SelectItem value="loading" disabled>
데이터를 불러오는 중...
</SelectItem>
)}
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<label className="text-sm font-medium">하역지 (선택사항)</label>
<Select
value={biddingConditions.destinationPort}
onValueChange={(value) => setBiddingConditions(prev => ({
...prev,
destinationPort: value
}))}
>
<SelectTrigger>
<SelectValue placeholder="하역지 선택" />
</SelectTrigger>
<SelectContent>
{destinationPlaces.length > 0 ? (
destinationPlaces.map((place) => (
<SelectItem key={place.code} value={place.code}>
{place.code} {place.description && `(${place.description})`}
</SelectItem>
))
) : (
<SelectItem value="loading" disabled>
데이터를 불러오는 중...
</SelectItem>
)}
</SelectContent>
</Select>
</div>
</div>
<div className="flex items-center space-x-2">
<Switch
id="price-adjustment"
checked={biddingConditions.isPriceAdjustmentApplicable}
onCheckedChange={(checked) => setBiddingConditions(prev => ({
...prev,
isPriceAdjustmentApplicable: checked
}))}
/>
<label htmlFor="price-adjustment" className="text-sm font-medium">
연동제 적용 요건 문의
</label>
</div>
<div className="space-y-2">
<label className="text-sm font-medium">스페어파트 옵션</label>
<Textarea
placeholder="스페어파트 관련 옵션을 입력하세요"
value={biddingConditions.sparePartOptions}
onChange={(e) => setBiddingConditions(prev => ({
...prev,
sparePartOptions: e.target.value
}))}
rows={3}
/>
</div>
</CardContent>
</Card>
</CardContent>
</Card>
</TabsContent>
{/* 일정 & 회의 탭 */}
<TabsContent value="schedule" className="mt-0 space-y-6">
<Card>
<CardHeader>
<CardTitle>일정 정보</CardTitle>
</CardHeader>
<CardContent className="space-y-6">
<div className="grid grid-cols-2 gap-6">
{/* 제출시작일시 */}
<FormField
control={form.control}
name="submissionStartDate"
render={({ field }) => (
<FormItem>
<FormLabel>
제출시작일시 <span className="text-red-500">*</span>
</FormLabel>
<FormControl>
<Input
type="datetime-local"
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{/* 제출마감일시 */}
<FormField
control={form.control}
name="submissionEndDate"
render={({ field }) => (
<FormItem>
<FormLabel>
제출마감일시 <span className="text-red-500">*</span>
</FormLabel>
<FormControl>
<Input
type="datetime-local"
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
</CardContent>
</Card>
{/* 사양설명회 */}
<Card>
<CardHeader>
<CardTitle>사양설명회</CardTitle>
</CardHeader>
<CardContent className="space-y-6">
<FormField
control={form.control}
name="hasSpecificationMeeting"
render={({ field }) => (
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-4">
<div className="space-y-0.5">
<FormLabel className="text-base">
사양설명회 실시
</FormLabel>
<FormDescription>
사양설명회를 실시할 경우 상세 정보를 입력하세요
</FormDescription>
</div>
<FormControl>
<Switch
checked={field.value}
onCheckedChange={field.onChange}
/>
</FormControl>
</FormItem>
)}
/>
{/* 사양설명회 정보 (조건부 표시) */}
{form.watch("hasSpecificationMeeting") && (
<div className="space-y-6 p-4 border rounded-lg bg-muted/50">
<div className="grid grid-cols-2 gap-4">
<div>
<label className="text-sm font-medium">
회의일시 <span className="text-red-500">*</span>
</label>
<Input
type="datetime-local"
value={specMeetingInfo.meetingDate}
onChange={(e) => setSpecMeetingInfo(prev => ({ ...prev, meetingDate: e.target.value }))}
className={!specMeetingInfo.meetingDate ? 'border-red-200' : ''}
/>
{!specMeetingInfo.meetingDate && (
<p className="text-sm text-red-500 mt-1">회의일시는 필수입니다</p>
)}
</div>
<div>
<label className="text-sm font-medium">회의시간</label>
<Input
placeholder="예: 14:00 ~ 16:00"
value={specMeetingInfo.meetingTime}
onChange={(e) => setSpecMeetingInfo(prev => ({ ...prev, meetingTime: e.target.value }))}
/>
</div>
</div>
<div>
<label className="text-sm font-medium">
장소 <span className="text-red-500">*</span>
</label>
<Input
placeholder="회의 장소"
value={specMeetingInfo.location}
onChange={(e) => setSpecMeetingInfo(prev => ({ ...prev, location: e.target.value }))}
className={!specMeetingInfo.location ? 'border-red-200' : ''}
/>
{!specMeetingInfo.location && (
<p className="text-sm text-red-500 mt-1">회의 장소는 필수입니다</p>
)}
</div>
<div>
<label className="text-sm font-medium">주소</label>
<Textarea
placeholder="상세 주소"
value={specMeetingInfo.address}
onChange={(e) => setSpecMeetingInfo(prev => ({ ...prev, address: e.target.value }))}
/>
</div>
<div className="grid grid-cols-3 gap-4">
<div>
<label className="text-sm font-medium">
담당자 <span className="text-red-500">*</span>
</label>
<Input
placeholder="담당자명"
value={specMeetingInfo.contactPerson}
onChange={(e) => setSpecMeetingInfo(prev => ({ ...prev, contactPerson: e.target.value }))}
className={!specMeetingInfo.contactPerson ? 'border-red-200' : ''}
/>
{!specMeetingInfo.contactPerson && (
<p className="text-sm text-red-500 mt-1">담당자는 필수입니다</p>
)}
</div>
<div>
<label className="text-sm font-medium">연락처</label>
<Input
placeholder="전화번호"
value={specMeetingInfo.contactPhone}
onChange={(e) => setSpecMeetingInfo(prev => ({ ...prev, contactPhone: e.target.value }))}
/>
</div>
<div>
<label className="text-sm font-medium">이메일</label>
<Input
type="email"
placeholder="이메일"
value={specMeetingInfo.contactEmail}
onChange={(e) => setSpecMeetingInfo(prev => ({ ...prev, contactEmail: e.target.value }))}
/>
</div>
</div>
<div className="grid grid-cols-2 gap-4">
<div>
<label className="text-sm font-medium">회의 안건</label>
<Textarea
placeholder="회의 안건"
value={specMeetingInfo.agenda}
onChange={(e) => setSpecMeetingInfo(prev => ({ ...prev, agenda: e.target.value }))}
/>
</div>
<div>
<label className="text-sm font-medium">준비물 & 특이사항</label>
<Textarea
placeholder="준비물 및 특이사항"
value={specMeetingInfo.materials}
onChange={(e) => setSpecMeetingInfo(prev => ({ ...prev, materials: e.target.value }))}
/>
</div>
</div>
<div className="flex items-center space-x-2">
<Switch
id="required-meeting"
checked={specMeetingInfo.isRequired}
onCheckedChange={(checked) => setSpecMeetingInfo(prev => ({ ...prev, isRequired: checked }))}
/>
<label htmlFor="required-meeting" className="text-sm font-medium">
필수 참석
</label>
</div>
{/* 사양설명회 첨부 파일 */}
<div className="space-y-4">
<label className="text-sm font-medium">사양설명회 관련 첨부 파일</label>
<Dropzone
onDrop={addMeetingFiles}
accept={{
'application/pdf': ['.pdf'],
'application/msword': ['.doc'],
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': ['.docx'],
'application/vnd.ms-excel': ['.xls'],
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': ['.xlsx'],
'image/*': ['.png', '.jpg', '.jpeg'],
}}
multiple
className="border-2 border-dashed border-gray-300 rounded-lg p-6 text-center hover:border-gray-400 transition-colors"
>
<DropzoneZone>
<DropzoneUploadIcon />
<DropzoneTitle>사양설명회 관련 문서 업로드</DropzoneTitle>
<DropzoneDescription>
안내문, 도면, 자료 등을 업로드하세요 (PDF, Word, Excel, 이미지 파일 지원)
</DropzoneDescription>
</DropzoneZone>
<DropzoneInput />
</Dropzone>
{specMeetingInfo.meetingFiles.length > 0 && (
<FileList className="mt-4">
<FileListHeader>
<span>업로드된 파일 ({specMeetingInfo.meetingFiles.length})</span>
</FileListHeader>
{specMeetingInfo.meetingFiles.map((file, fileIndex) => (
<FileListItem key={fileIndex}>
<FileListIcon />
<FileListInfo>
<FileListName>{file.name}</FileListName>
<FileListSize>{file.size}</FileListSize>
</FileListInfo>
<FileListAction>
<Button
type="button"
variant="outline"
size="sm"
onClick={() => removeMeetingFile(fileIndex)}
>
삭제
</Button>
</FileListAction>
</FileListItem>
))}
</FileList>
)}
</div>
</div>
)}
</CardContent>
</Card>
{/* 긴급 입찰 설정 */}
<Card>
<CardHeader>
<CardTitle>긴급 입찰 설정</CardTitle>
</CardHeader>
<CardContent className="space-y-6">
<FormField
control={form.control}
name="isUrgent"
render={({ field }) => (
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-4">
<div className="space-y-0.5">
<FormLabel className="text-base">
긴급 입찰
</FormLabel>
<FormDescription>
긴급 입찰 여부를 설정합니다
</FormDescription>
</div>
<FormControl>
<Switch
checked={field.value}
onCheckedChange={field.onChange}
/>
</FormControl>
</FormItem>
)}
/>
</CardContent>
</Card>
</TabsContent>
{/* 세부내역 탭 */}
<TabsContent value="details" className="mt-0 space-y-6">
<Card>
<CardHeader className="flex flex-row items-center justify-between">
<div>
<CardTitle>세부내역 관리</CardTitle>
<p className="text-sm text-muted-foreground mt-1">
최소 하나의 품목을 입력해야 합니다
</p>
<p className="text-xs text-amber-600 mt-1">
수량/단위 또는 중량/중량단위를 선택해서 입력하세요
</p>
</div>
<Button
type="button"
variant="outline"
onClick={addPRItem}
className="flex items-center gap-2"
>
<Plus className="h-4 w-4" />
아이템 추가
</Button>
</CardHeader>
<CardContent className="space-y-6">
{/* 아이템 테이블 */}
{prItems.length > 0 ? (
<div className="space-y-4">
<div className="border rounded-lg">
<Table>
<TableHeader>
<TableRow>
<TableHead className="w-[60px]">대표</TableHead>
<TableHead className="w-[120px]">PR 번호</TableHead>
<TableHead className="w-[120px]">품목코드</TableHead>
<TableHead>품목정보 *</TableHead>
<TableHead className="w-[80px]">수량</TableHead>
<TableHead className="w-[80px]">단위</TableHead>
<TableHead className="w-[80px]">중량</TableHead>
<TableHead className="w-[80px]">중량단위</TableHead>
<TableHead className="w-[140px]">납품요청일</TableHead>
<TableHead className="w-[80px]">스펙파일</TableHead>
<TableHead className="w-[80px]">액션</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{prItems.map((item, index) => (
<TableRow key={item.id}>
<TableCell>
<div className="flex justify-center">
<Checkbox
checked={item.isRepresentative}
onCheckedChange={() => setRepresentativeItem(item.id)}
/>
</div>
</TableCell>
<TableCell>
<Input
placeholder="PR 번호"
value={item.prNumber}
onChange={(e) => updatePRItem(item.id, { prNumber: e.target.value })}
className="h-8"
/>
</TableCell>
<TableCell>
<Input
placeholder={`ITEM-${index + 1}`}
value={item.itemCode}
onChange={(e) => updatePRItem(item.id, { itemCode: e.target.value })}
className="h-8"
/>
</TableCell>
<TableCell>
<Input
placeholder="품목정보 *"
value={item.itemInfo}
onChange={(e) => updatePRItem(item.id, { itemInfo: e.target.value })}
className="h-8"
/>
</TableCell>
<TableCell>
<Input
type="number"
min="0"
placeholder="수량"
value={item.quantity}
onChange={(e) => updatePRItem(item.id, { quantity: e.target.value })}
className="h-8"
/>
</TableCell>
<TableCell>
<Select
value={item.quantityUnit}
onValueChange={(value) => updatePRItem(item.id, { quantityUnit: value })}
>
<SelectTrigger className="h-8">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="EA">EA</SelectItem>
<SelectItem value="SET">SET</SelectItem>
<SelectItem value="LOT">LOT</SelectItem>
<SelectItem value="M">M</SelectItem>
<SelectItem value="M2">M²</SelectItem>
<SelectItem value="M3">M³</SelectItem>
</SelectContent>
</Select>
</TableCell>
<TableCell>
<Input
type="number"
min="0"
placeholder="중량"
value={item.totalWeight}
onChange={(e) => updatePRItem(item.id, { totalWeight: e.target.value })}
className="h-8"
/>
</TableCell>
<TableCell>
<Select
value={item.weightUnit}
onValueChange={(value) => updatePRItem(item.id, { weightUnit: value })}
>
<SelectTrigger className="h-8">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="KG">KG</SelectItem>
<SelectItem value="TON">TON</SelectItem>
<SelectItem value="G">G</SelectItem>
<SelectItem value="LB">LB</SelectItem>
</SelectContent>
</Select>
</TableCell>
<TableCell>
<Input
type="date"
value={item.requestedDeliveryDate}
onChange={(e) => updatePRItem(item.id, { requestedDeliveryDate: e.target.value })}
className="h-8"
placeholder="납품요청일"
/>
</TableCell>
<TableCell>
<div className="flex items-center gap-2">
<Button
type="button"
variant={selectedItemForFile === item.id ? "default" : "outline"}
size="sm"
onClick={() => setSelectedItemForFile(selectedItemForFile === item.id ? null : item.id)}
className="h-8 w-8 p-0"
>
<Paperclip className="h-4 w-4" />
</Button>
<span className="text-sm">{item.specFiles.length}</span>
</div>
</TableCell>
<TableCell>
<Button
type="button"
variant="outline"
size="sm"
onClick={() => removePRItem(item.id)}
disabled={prItems.length <= 1}
className="h-8 w-8 p-0"
title={prItems.length <= 1 ? "최소 하나의 품목이 필요합니다" : "품목 삭제"}
>
<Trash2 className="h-4 w-4" />
</Button>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
{/* 대표 아이템 정보 표시 */}
{representativePrNumber && (
<div className="flex items-center gap-2 p-3 bg-blue-50 border border-blue-200 rounded-lg">
<CheckCircle2 className="h-4 w-4 text-blue-600" />
<span className="text-sm text-blue-800">
대표 PR 번호: <strong>{representativePrNumber}</strong>
</span>
</div>
)}
{/* 선택된 아이템의 파일 업로드 */}
{selectedItemForFile && (
<div className="space-y-4 p-4 border rounded-lg bg-muted/50">
{(() => {
const selectedItem = prItems.find(item => item.id === selectedItemForFile)
return (
<>
<div className="flex items-center justify-between">
<h6 className="font-medium text-sm">
{selectedItem?.itemInfo || selectedItem?.itemCode || "선택된 아이템"}의 스펙 파일
</h6>
<Button
type="button"
variant="ghost"
size="sm"
onClick={() => setSelectedItemForFile(null)}
>
닫기
</Button>
</div>
<Dropzone
onDrop={(files) => addSpecFiles(selectedItemForFile, files)}
accept={{
'application/pdf': ['.pdf'],
'application/msword': ['.doc'],
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': ['.docx'],
'application/vnd.ms-excel': ['.xls'],
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': ['.xlsx'],
}}
multiple
className="border-2 border-dashed border-gray-300 rounded-lg p-4 text-center hover:border-gray-400 transition-colors"
>
<DropzoneZone>
<DropzoneUploadIcon />
<DropzoneTitle>스펙 문서 업로드</DropzoneTitle>
<DropzoneDescription>
PDF, Word, Excel 파일을 드래그하거나 클릭하여 선택
</DropzoneDescription>
</DropzoneZone>
<DropzoneInput />
</Dropzone>
{selectedItem && selectedItem.specFiles.length > 0 && (
<FileList className="mt-4">
<FileListHeader>
<span>업로드된 파일 ({selectedItem.specFiles.length})</span>
</FileListHeader>
{selectedItem.specFiles.map((file, fileIndex) => (
<FileListItem
key={fileIndex}
className="flex items-center justify-between p-3 border rounded-lg mb-2"
>
<div className="flex items-center gap-3 flex-1">
<FileListIcon className="flex-shrink-0" />
<FileListInfo className="flex items-center gap-3 flex-1">
<FileListName className="font-medium text-gray-700">
{file.name}
</FileListName>
<FileListSize className="text-sm text-gray-500">
{file.size}
</FileListSize>
</FileListInfo>
</div>
<FileListAction className="flex-shrink-0">
<Button
type="button"
variant="outline"
size="sm"
onClick={() => removeSpecFile(selectedItemForFile, fileIndex)}
>
삭제
</Button>
</FileListAction>
</FileListItem>
))}
</FileList>
)}
</>
)
})()}
</div>
)}
</div>
) : (
<div className="text-center py-12 border-2 border-dashed border-gray-300 rounded-lg">
<FileText className="h-12 w-12 text-gray-400 mx-auto mb-4" />
<p className="text-gray-500 mb-2">아직 아이템이 없습니다</p>
<p className="text-sm text-gray-400 mb-4">
PR 아이템이나 수기 아이템을 추가하여 입찰 세부내역을 작성하세요
</p>
<Button
type="button"
variant="outline"
onClick={addPRItem}
className="flex items-center gap-2 mx-auto"
>
<Plus className="h-4 w-4" />
첫 번째 아이템 추가
</Button>
</div>
)}
</CardContent>
</Card>
</TabsContent>
{/* 담당자 & 기타 탭 */}
<TabsContent value="manager" className="mt-0 space-y-6">
{/* 담당자 정보 */}
<Card>
<CardHeader>
<CardTitle>담당자 정보</CardTitle>
</CardHeader>
<CardContent className="space-y-6">
<FormField
control={form.control}
name="managerName"
render={({ field }) => (
<FormItem>
<FormLabel>담당자명</FormLabel>
<FormControl>
<Input
placeholder="담당자명"
{...field}
/>
</FormControl>
<FormDescription>
현재 로그인한 사용자 정보로 자동 설정됩니다.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
<div className="grid grid-cols-2 gap-6">
<FormField
control={form.control}
name="managerEmail"
render={({ field }) => (
<FormItem>
<FormLabel>담당자 이메일</FormLabel>
<FormControl>
<Input
type="email"
placeholder="email@example.com"
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="managerPhone"
render={({ field }) => (
<FormItem>
<FormLabel>담당자 전화번호</FormLabel>
<FormControl>
<Input
placeholder="010-1234-5678"
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
</CardContent>
</Card>
{/* 기타 설정 */}
<Card>
<CardHeader>
<CardTitle>기타 설정</CardTitle>
</CardHeader>
<CardContent className="space-y-6">
<FormField
control={form.control}
name="isPublic"
render={({ field }) => (
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-4">
<div className="space-y-0.5">
<FormLabel className="text-base">
공개 입찰
</FormLabel>
<FormDescription>
공개 입찰 여부를 설정합니다
</FormDescription>
</div>
<FormControl>
<Switch
checked={field.value}
onCheckedChange={field.onChange}
/>
</FormControl>
</FormItem>
)}
/>
<FormField
control={form.control}
name="remarks"
render={({ field }) => (
<FormItem>
<FormLabel>비고</FormLabel>
<FormControl>
<Textarea
placeholder="추가 메모나 특이사항을 입력하세요"
rows={4}
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</CardContent>
</Card>
{/* 입찰 생성 요약 */}
{/* <Card>
<CardHeader>
<CardTitle>입찰 생성 요약</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<div className="grid grid-cols-2 gap-4 text-sm">
<div>
<span className="font-medium">프로젝트:</span>
<p className="text-muted-foreground">
{form.watch("projectName") || "선택되지 않음"}
</p>
</div>
<div>
<span className="font-medium">입찰명:</span>
<p className="text-muted-foreground">
{form.watch("title") || "입력되지 않음"}
</p>
</div>
<div>
<span className="font-medium">계약구분:</span>
<p className="text-muted-foreground">
{contractTypeLabels[form.watch("contractType") as keyof typeof contractTypeLabels] || "선택되지 않음"}
</p>
</div>
<div>
<span className="font-medium">입찰유형:</span>
<p className="text-muted-foreground">
{biddingTypeLabels[form.watch("biddingType") as keyof typeof biddingTypeLabels] || "선택되지 않음"}
</p>
</div>
<div>
<span className="font-medium">사양설명회:</span>
<p className="text-muted-foreground">
{form.watch("hasSpecificationMeeting") ? "실시함" : "실시하지 않음"}
</p>
</div>
<div>
<span className="font-medium">대표 PR 번호:</span>
<p className="text-muted-foreground">
{representativePrNumber || "설정되지 않음"}
</p>
</div>
<div>
<span className="font-medium">세부 아이템:</span>
<p className="text-muted-foreground">
{prItems.length}개 아이템
</p>
</div>
<div>
<span className="font-medium">사양설명회 파일:</span>
<p className="text-muted-foreground">
{specMeetingInfo.meetingFiles.length}개 파일
</p>
</div>
</div>
</CardContent>
</Card> */}
</TabsContent>
</div>
</Tabs>
</div>
{/* 고정 버튼 영역 */}
<div className="flex-shrink-0 border-t bg-background p-6">
<div className="flex justify-between items-center">
<div className="text-sm text-muted-foreground">
{activeTab === "basic" && (
<span>
기본 정보를 입력하세요
{!tabValidation.basic.isValid && (
<span className="text-red-500 ml-2">• 필수 항목이 누락되었습니다</span>
)}
</span>
)}
{activeTab === "contract" && (
<span>
계약 및 가격 정보를 입력하세요
{!tabValidation.contract.isValid && (
<span className="text-red-500 ml-2">• 필수 항목이 누락되었습니다</span>
)}
</span>
)}
{activeTab === "schedule" && (
<span>
일정 및 사양설명회 정보를 입력하세요
{!tabValidation.schedule.isValid && (
<span className="text-red-500 ml-2">• 필수 항목이 누락되었습니다</span>
)}
</span>
)}
{activeTab === "conditions" && (
<span>
입찰 조건을 설정하세요
{!tabValidation.conditions.isValid && (
<span className="text-red-500 ml-2">• 필수 항목이 누락되었습니다</span>
)}
</span>
)}
{activeTab === "details" && (
<span>
최소 하나의 품목을 입력하세요
{!tabValidation.details.isValid && (
<span className="text-red-500 ml-2">• 필수 항목이 누락되었습니다</span>
)}
</span>
)}
{activeTab === "manager" && "담당자 정보를 확인하고 입찰을 생성하세요"}
</div>
<div className="flex gap-3">
<Button
type="button"
variant="outline"
onClick={() => setShowCloseConfirmDialog(true)}
disabled={isSubmitting}
>
취소
</Button>
{/* 이전 버튼 (첫 번째 탭이 아닐 때) */}
{!isFirstTab && (
<Button
type="button"
variant="outline"
onClick={goToPreviousTab}
disabled={isSubmitting}
className="flex items-center gap-2"
>
<ChevronLeft className="h-4 w-4" />
이전
</Button>
)}
{/* 다음/생성 버튼 */}
{isLastTab ? (
// 마지막 탭: 입찰 생성 버튼 (type="button"으로 변경)
<Button
type="button"
onClick={handleCreateBidding}
disabled={isSubmitting}
className="flex items-center gap-2"
>
{isSubmitting && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
입찰 생성
</Button>
) : (
// 이전 탭들: 다음 버튼
<Button
type="button"
onClick={handleNextClick}
disabled={isSubmitting}
className="flex items-center gap-2"
>
다음
<ChevronRight className="h-4 w-4" />
</Button>
)}
</div>
</div>
</div>
</form>
</Form>
</DialogContent>
</Dialog>
{/* 닫기 확인 다이얼로그 */}
<AlertDialog open={showCloseConfirmDialog} onOpenChange={setShowCloseConfirmDialog}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>입찰 생성을 취소하시겠습니까?</AlertDialogTitle>
<AlertDialogDescription>
현재 입력 중인 내용이 모두 삭제되며, 생성되지 않습니다.
정말로 취소하시겠습니까?
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel onClick={() => handleCloseConfirm(false)}>
아니오 (계속 입력)
</AlertDialogCancel>
<AlertDialogAction onClick={() => handleCloseConfirm(true)}>
예 (취소)
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
<AlertDialog open={showSuccessDialog} onOpenChange={setShowSuccessDialog}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>입찰이 성공적으로 생성되었습니다</AlertDialogTitle>
<AlertDialogDescription>
생성된 입찰의 상세페이지로 이동하시겠습니까?
아니면 현재 페이지에 남아있으시겠습니까?
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel onClick={handleStayOnPage}>
현재 페이지에 남기
</AlertDialogCancel>
<AlertDialogAction onClick={handleNavigateToDetail}>
상세페이지로 이동
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</>
)
}
|