summaryrefslogtreecommitdiff
path: root/lib/bidding/selection/vendor-selection-table.tsx
blob: 40f13ec19ba3ed0d6a709684ff45beab9f69ff58 (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
'use client'

import * as React from 'react'
import { Bidding } from '@/db/schema'
import { BiddingDetailVendorTableContent } from '../detail/table/bidding-detail-vendor-table'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import { getBiddingDetailData } from '../detail/service'

interface VendorSelectionTableProps {
  biddingId: number
  bidding: Bidding
  onRefresh: () => void
  readOnly?: boolean
}

export function VendorSelectionTable({ biddingId, bidding, onRefresh, readOnly = false }: VendorSelectionTableProps) {
  const [vendors, setVendors] = React.useState<any[]>([])
  const [loading, setLoading] = React.useState(true)

  React.useEffect(() => {
    const loadData = async () => {
      try {
        setLoading(true)
        const data = await getBiddingDetailData(biddingId)
        setVendors(data.quotationVendors)
      } catch (error) {
        console.error('Failed to load vendors:', error)
      } finally {
        setLoading(false)
      }
    }

    loadData()
  }, [biddingId])

  if (loading) {
    return (
      <Card>
        <CardHeader>
          <CardTitle>업체선정</CardTitle>
        </CardHeader>
        <CardContent>
          <div className="flex items-center justify-center py-8">
            <div className="text-sm text-muted-foreground">로딩 중...</div>
          </div>
        </CardContent>
      </Card>
    )
  }

  return (
    <Card>
      <CardHeader>
        <CardTitle>업체선정</CardTitle>
      </CardHeader>
      <CardContent>
        <BiddingDetailVendorTableContent
          biddingId={biddingId}
          bidding={bidding}
          vendors={vendors}
          onRefresh={onRefresh}
          onOpenSelectionReasonDialog={() => {}}
          readOnly={readOnly}
        />
      </CardContent>
    </Card>
  )
}