'use client'

import * as React from 'react'
import { Bidding } from '@/db/schema'
import { BiddingInfoCard } from './bidding-info-card'
import { SelectionResultForm } from './selection-result-form'
import { VendorSelectionTable } from './vendor-selection-table'

interface BiddingSelectionDetailContentProps {
  biddingId: number
  bidding: Bidding
}

export function BiddingSelectionDetailContent({
  biddingId,
  bidding
}: BiddingSelectionDetailContentProps) {
  const [refreshKey, setRefreshKey] = React.useState(0)

  const handleRefresh = React.useCallback(() => {
    setRefreshKey(prev => prev + 1)
  }, [])

  return (
    <div className="space-y-6">
      {/* 입찰정보 카드 */}
      <BiddingInfoCard bidding={bidding} />

      {/* 선정결과 폼 */}
      <SelectionResultForm biddingId={biddingId} onSuccess={handleRefresh} />

      {/* 업체선정 테이블 */}
      <VendorSelectionTable
        key={refreshKey}
        biddingId={biddingId}
        bidding={bidding}
        onRefresh={handleRefresh}
      />
    </div>
  )
}
