From ba8cd44a0ed2c613a5f2cee06bfc9bd0f61f21c7 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Fri, 7 Nov 2025 08:39:04 +0000 Subject: (최겸) 입찰/견적 수정사항 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../general-contract-communication-channel.tsx | 362 --------------------- 1 file changed, 362 deletions(-) delete mode 100644 lib/general-contracts/detail/general-contract-communication-channel.tsx (limited to 'lib/general-contracts/detail/general-contract-communication-channel.tsx') diff --git a/lib/general-contracts/detail/general-contract-communication-channel.tsx b/lib/general-contracts/detail/general-contract-communication-channel.tsx deleted file mode 100644 index f5cd79b2..00000000 --- a/lib/general-contracts/detail/general-contract-communication-channel.tsx +++ /dev/null @@ -1,362 +0,0 @@ -'use client' - -import React, { useState, useEffect } from 'react' -import { useSession } from 'next-auth/react' -import { Input } from '@/components/ui/input' -import { Button } from '@/components/ui/button' -import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion' -import { Checkbox } from '@/components/ui/checkbox' -import { Plus, Trash2, Save, LoaderIcon, MessageSquare } from 'lucide-react' -import { updateCommunicationChannel, getCommunicationChannel } from '../service' -import { toast } from 'sonner' - -interface CommunicationChannelProps { - contractType?: string - contractId: number -} - -interface Representative { - id: string - position: string - name: string - telNo: string - email: string - isActive: boolean -} - -export function CommunicationChannel({ contractId }: CommunicationChannelProps) { - const session = useSession() - const [isLoading, setIsLoading] = useState(false) - const [isEnabled, setIsEnabled] = useState(true) - - // 일단 모든 계약종류에서 활성화 - const isDisabled = false - - const [contractorReps, setContractorReps] = useState([]) - const [supplierReps, setSupplierReps] = useState([]) - - // 초기 데이터 로드 - useEffect(() => { - const loadCommunicationChannel = async () => { - try { - const data = await getCommunicationChannel(contractId) - if (data && data.enabled !== undefined) { - setIsEnabled(data.enabled) - setContractorReps(data.contractorRepresentatives || []) - setSupplierReps(data.supplierRepresentatives || []) - } - } catch (error) { - console.error('Error loading communication channel:', error) - - } - } - - loadCommunicationChannel() - }, [contractId]) - - const addContractorRow = () => { - const newId = (contractorReps.length + 1).toString() - setContractorReps([...contractorReps, { - id: newId, - position: '', - name: '', - telNo: '', - email: '', - isActive: false - }]) - } - - const removeContractorRow = () => { - const selectedRows = contractorReps.filter(rep => rep.isActive) - if (selectedRows.length > 0) { - setContractorReps(contractorReps.filter(rep => !rep.isActive)) - } - } - - const addSupplierRow = () => { - const newId = (supplierReps.length + 1).toString() - setSupplierReps([...supplierReps, { - id: newId, - position: '', - name: '', - telNo: '', - email: '', - isActive: false - }]) - } - - const removeSupplierRow = () => { - const selectedRows = supplierReps.filter(rep => rep.isActive) - if (selectedRows.length > 0) { - setSupplierReps(supplierReps.filter(rep => !rep.isActive)) - } - } - - const updateContractorRep = (id: string, field: keyof Representative, value: string | boolean) => { - setContractorReps(contractorReps.map(rep => - rep.id === id ? { ...rep, [field]: value } : rep - )) - } - - const updateSupplierRep = (id: string, field: keyof Representative, value: string | boolean) => { - setSupplierReps(supplierReps.map(rep => - rep.id === id ? { ...rep, [field]: value } : rep - )) - } - - const handleSaveCommunicationChannel = async () => { - const userId = session.data?.user?.id ? Number(session.data.user.id) : null - - if (!userId) { - toast.error('사용자 정보를 찾을 수 없습니다.') - return - } - - try { - setIsLoading(true) - - const communicationData = { - enabled: isEnabled, - contractorRepresentatives: contractorReps, - supplierRepresentatives: supplierReps - } - - await updateCommunicationChannel(contractId, communicationData, userId) - toast.success('커뮤니케이션 채널이 저장되었습니다.') - } catch (error) { - console.error('Error saving communication channel:', error) - toast.error('커뮤니케이션 채널 저장에 실패했습니다.') - } finally { - setIsLoading(false) - } - } - - return ( -
- - {/* Communication Channel 활성화 */} - - -
- - Communication Channel -
-
- -
- {/* 체크박스 */} -
- { - if (!isDisabled) { - setIsEnabled(checked as boolean) - } - }} - /> - Communication Channel 활성화 -
- - {/* Table 1: The Contractor's Representatives */} -
-
-

Table 1: The Contractor 's Representatives

-
- - -
-
- -
- - - - - - - - - - - - - {contractorReps.map((rep) => ( - - - - - - - - - ))} - -
No.PositionNameTel. No.Email
- updateContractorRep(rep.id, 'isActive', checked as boolean)} - disabled={isDisabled || !isEnabled} - /> - {rep.id} - updateContractorRep(rep.id, 'position', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - /> - - updateContractorRep(rep.id, 'name', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - /> - - updateContractorRep(rep.id, 'telNo', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - /> - - updateContractorRep(rep.id, 'email', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - /> -
-
-
- - {/* Table 2: The Supplier's Representatives */} -
-
-

Table 2: The Supplier 's Representatives

-
- - -
-
- -
- - - - - - - - - - - - - {supplierReps.map((rep) => ( - - - - - - - - - ))} - -
No.PositionNameTel. No.Email
- updateSupplierRep(rep.id, 'isActive', checked as boolean)} - disabled={isDisabled || !isEnabled} - /> - {rep.id} - updateSupplierRep(rep.id, 'position', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - /> - - updateSupplierRep(rep.id, 'name', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - /> - - updateSupplierRep(rep.id, 'telNo', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - /> - - updateSupplierRep(rep.id, 'email', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - /> -
-
-
- - {/* 저장 버튼 */} -
- -
-
-
-
-
-
- ) -} -- cgit v1.2.3