summaryrefslogtreecommitdiff
path: root/components/bidding/manage/bidding-companies-editor.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'components/bidding/manage/bidding-companies-editor.tsx')
-rw-r--r--components/bidding/manage/bidding-companies-editor.tsx48
1 files changed, 10 insertions, 38 deletions
diff --git a/components/bidding/manage/bidding-companies-editor.tsx b/components/bidding/manage/bidding-companies-editor.tsx
index 4992c2ab..a81f0063 100644
--- a/components/bidding/manage/bidding-companies-editor.tsx
+++ b/components/bidding/manage/bidding-companies-editor.tsx
@@ -11,8 +11,7 @@ import {
createBiddingCompanyContact,
deleteBiddingCompanyContact,
getVendorContactsByVendorId,
- updateBiddingCompanyPriceAdjustmentQuestion,
- getBiddingById
+ updateBiddingCompanyPriceAdjustmentQuestion
} from '@/lib/bidding/service'
import { deleteBiddingCompany } from '@/lib/bidding/pre-quote/service'
import { BiddingDetailVendorCreateDialog } from './bidding-detail-vendor-create-dialog'
@@ -54,6 +53,7 @@ interface QuotationVendor {
interface BiddingCompaniesEditorProps {
biddingId: number
+ readonly?: boolean
}
interface VendorContact {
@@ -79,7 +79,7 @@ interface BiddingCompanyContact {
updatedAt: Date
}
-export function BiddingCompaniesEditor({ biddingId }: BiddingCompaniesEditorProps) {
+export function BiddingCompaniesEditor({ biddingId, readonly = false }: BiddingCompaniesEditorProps) {
const [vendors, setVendors] = React.useState<QuotationVendor[]>([])
const [isLoading, setIsLoading] = React.useState(false)
const [addVendorDialogOpen, setAddVendorDialogOpen] = React.useState(false)
@@ -89,10 +89,6 @@ export function BiddingCompaniesEditor({ biddingId }: BiddingCompaniesEditorProp
// 각 업체별 첫 번째 담당자 정보 저장 (vendorId -> 첫 번째 담당자)
const [vendorFirstContacts, setVendorFirstContacts] = React.useState<Map<number, BiddingCompanyContact>>(new Map())
- // 입찰 정보 (단수/복수 낙찰 확인용)
- const [biddingInfo, setBiddingInfo] = React.useState<any>(null)
- const [isLoadingBiddingInfo, setIsLoadingBiddingInfo] = React.useState(false)
-
// 담당자 추가 다이얼로그
const [addContactDialogOpen, setAddContactDialogOpen] = React.useState(false)
const [newContact, setNewContact] = React.useState({
@@ -146,29 +142,6 @@ export function BiddingCompaniesEditor({ biddingId }: BiddingCompaniesEditorProp
}
}, [biddingId])
- // 입찰 정보 로딩
- const loadBiddingInfo = React.useCallback(async () => {
- setIsLoadingBiddingInfo(true)
- try {
- const result = await getBiddingById(biddingId)
- if (result) {
- setBiddingInfo(result)
- } else {
- console.error('Failed to load bidding info')
- setBiddingInfo(null)
- }
- } catch (error) {
- console.error('Failed to load bidding info:', error)
- setBiddingInfo(null)
- } finally {
- setIsLoadingBiddingInfo(false)
- }
- }, [biddingId])
-
- // 단수 입찰 여부 확인 및 업체 추가 제한
- const isSingleAwardBidding = biddingInfo?.awardCount === 'single'
- const canAddVendor = !isSingleAwardBidding || vendors.length === 0
-
// 데이터 로딩
React.useEffect(() => {
const loadVendors = async () => {
@@ -222,8 +195,7 @@ export function BiddingCompaniesEditor({ biddingId }: BiddingCompaniesEditorProp
}
loadVendors()
- loadBiddingInfo()
- }, [biddingId, loadBiddingInfo])
+ }, [biddingId])
// 업체 선택 핸들러 (단일 선택)
const handleVendorSelect = async (vendor: QuotationVendor) => {
@@ -513,10 +485,12 @@ export function BiddingCompaniesEditor({ biddingId }: BiddingCompaniesEditorProp
</p>
<p className="text-sm text-muted-foreground mt-1"> 단수 입찰의 경우 1개 업체만 등록 가능합니다. </p>
</div>
- <Button onClick={() => setAddVendorDialogOpen(true)} className="flex items-center gap-2">
- <Plus className="h-4 w-4" />
- 업체 추가
- </Button>
+ {!readonly && (
+ <Button onClick={() => setAddVendorDialogOpen(true)} className="flex items-center gap-2">
+ <Plus className="h-4 w-4" />
+ 업체 추가
+ </Button>
+ )}
</CardHeader>
<CardContent>
{vendors.length === 0 ? (
@@ -687,8 +661,6 @@ export function BiddingCompaniesEditor({ biddingId }: BiddingCompaniesEditorProp
open={addVendorDialogOpen}
onOpenChange={setAddVendorDialogOpen}
onSuccess={reloadVendors}
- isSingleAwardBidding={isSingleAwardBidding}
- currentVendorCount={vendors.length}
/>
{/* 담당자 추가 다이얼로그 (직접 입력) */}