blob: 7c01fb16460116928034c0640d70adac90d59e43 (
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
|
'use client'
import { useState, useEffect } from 'react'
import { useParams } from 'next/navigation'
import Link from 'next/link'
import { getContractById } from '../service'
import { GeneralContractInfoHeader } from './general-contract-info-header'
import { Alert, AlertDescription } from '@/components/ui/alert'
import { Button } from '@/components/ui/button'
import { AlertCircle, ArrowLeft } from 'lucide-react'
import { Skeleton } from '@/components/ui/skeleton'
import { ContractItemsTable } from './general-contract-items-table'
import { SubcontractChecklist } from './subcontract-checklist'
import { ContractBasicInfo } from './general-contract-basic-info'
import { CommunicationChannel } from './general-contract-communication-channel'
import { Location } from './general-contract-location'
import { FieldServiceRate } from './general-contract-field-service-rate'
import { OffsetDetails } from './general-contract-offset-details'
export default function ContractDetailPage() {
const params = useParams()
const contractId = params?.id ? parseInt(params.id as string) : null
const [contract, setContract] = useState<Record<string, unknown> | null>(null)
const [loading, setLoading] = useState(true)
const [error, setError] = useState<string | null>(null)
useEffect(() => {
const fetchContract = async () => {
try {
setLoading(true)
setError(null)
const contractData = await getContractById(contractId!)
setContract(contractData)
} catch (err) {
console.error('Error fetching contract:', err)
setError('계약 정보를 불러오는 중 오류가 발생했습니다.')
} finally {
setLoading(false)
}
}
if (contractId && !isNaN(contractId)) {
fetchContract()
} else {
setError('유효하지 않은 계약 ID입니다.')
setLoading(false)
}
}, [contractId])
if (loading) {
return (
<div className="container mx-auto py-6 space-y-6">
<Skeleton className="h-8 w-64" />
<div className="grid gap-6">
<div className="grid grid-cols-2 gap-4">
<Skeleton className="h-10 w-full" />
<Skeleton className="h-10 w-full" />
</div>
<div className="grid grid-cols-3 gap-4">
<Skeleton className="h-10 w-full" />
<Skeleton className="h-10 w-full" />
<Skeleton className="h-10 w-full" />
</div>
<Skeleton className="h-32 w-full" />
</div>
</div>
)
}
if (error) {
return (
<div className="container mx-auto py-6">
<Alert variant="destructive">
<AlertCircle className="h-4 w-4" />
<AlertDescription>
{error}
</AlertDescription>
</Alert>
</div>
)
}
return (
<div className="container mx-auto py-6 space-y-6">
<div className="flex items-center justify-between">
<div>
<h1 className="text-3xl font-bold tracking-tight">계약 상세</h1>
<p className="text-muted-foreground">
계약번호: {contract?.contractNumber as string} (Rev.{contract?.revision as number})
</p>
</div>
{/* 계약목록으로 돌아가기 버튼 */}
<Button asChild variant="outline" size="sm">
<Link href="/evcp/general-contracts">
<ArrowLeft className="h-4 w-4 mr-2" />
계약목록으로 돌아가기
</Link>
</Button>
</div>
{/* 계약 정보 헤더 */}
{contract && <GeneralContractInfoHeader contract={contract} />}
{/* 계약 상세 폼 */}
{contract && (
<div className="space-y-6">
{/* ContractBasicInfo */}
<ContractBasicInfo contractId={contract.id as number} />
{/* 품목정보 */}
{/* {!(contract?.contractScope === '단가' || contract?.contractScope === '물량(실적)') && (
<div className="mb-4">
<p className="text-sm text-gray-600 mb-2">
<strong>품목정보 입력 안내:</strong>
<br />
단가/물량 확정 계약의 경우 수량 및 총 계약금액은 별도로 관리됩니다.
</p>
</div>
)} */}
<ContractItemsTable
contractId={contract.id as number}
items={[]}
onItemsChange={() => {}}
onTotalAmountChange={() => {}}
currency="USD"
availableBudget={0}
readOnly={contract?.contractScope === '단가' || contract?.contractScope === '물량(실적)'}
/>
{/* 하도급법 자율점검 체크리스트 */}
<SubcontractChecklist
contractId={contract.id as number}
onDataChange={() => {}}
readOnly={false}
initialData={undefined}
/>
{/* Communication Channel */}
<CommunicationChannel contractId={Number(contract.id)} />
{/* Location */}
<Location contractId={Number(contract.id)} />
{/* Field Service Rate */}
<FieldServiceRate contractId={Number(contract.id)} />
{/* Offset Details */}
<OffsetDetails contractId={Number(contract.id)} />
</div>
)}
</div>
)
}
|