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 --- .../detail/general-contract-location.tsx | 480 --------------------- 1 file changed, 480 deletions(-) delete mode 100644 lib/general-contracts/detail/general-contract-location.tsx (limited to 'lib/general-contracts/detail/general-contract-location.tsx') diff --git a/lib/general-contracts/detail/general-contract-location.tsx b/lib/general-contracts/detail/general-contract-location.tsx deleted file mode 100644 index 5b388895..00000000 --- a/lib/general-contracts/detail/general-contract-location.tsx +++ /dev/null @@ -1,480 +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 { Save, LoaderIcon, MapPin } from 'lucide-react' -import { updateLocation, getLocation } from '../service' -import { toast } from 'sonner' - -interface LocationProps { - contractType?: string - contractId: number -} - -interface LocationData { - country: { - projectManager: string - engineering: string - procurement: string - fabrication: string - assembly: string - test: string - shippingExw: string - shippingFob: string - remark: string - } - location: { - projectManager: string - engineering: string - procurement: string - fabrication: string - assembly: string - test: string - shippingExw: string - shippingFob: string - remark: string - } - subContractor: { - projectManager: string - engineering: string - procurement: string - fabrication: string - assembly: string - test: string - shippingExw: string - shippingFob: string - remark: string - } -} - -export function Location({ contractId }: LocationProps) { - const session = useSession() - const [isLoading, setIsLoading] = useState(false) - const [isEnabled, setIsEnabled] = useState(true) - const [locationData, setLocationData] = useState({ - country: { - projectManager: '', - engineering: '', - procurement: '', - fabrication: '', - assembly: '', - test: '', - shippingExw: '', - shippingFob: '', - remark: '' - }, - location: { - projectManager: '', - engineering: '', - procurement: '', - fabrication: '', - assembly: '', - test: '', - shippingExw: '', - shippingFob: '', - remark: '' - }, - subContractor: { - projectManager: '', - engineering: '', - procurement: '', - fabrication: '', - assembly: '', - test: '', - shippingExw: '', - shippingFob: '', - remark: '' - } - }) - - // 특정 계약종류를 제외한 일반계약은 Default로 표시 - const isDisabled = false // 일단 모든 계약종류에서 활성화 - - // 초기 데이터 로드 - useEffect(() => { - const loadLocationData = async () => { - try { - const data = await getLocation(contractId) - if (data && data.locations) { - setLocationData(data.locations) - setIsEnabled(data.enabled || true) - } else { - // 기본 데이터는 이미 useState에서 설정됨 - } - } catch (error) { - console.error('Error loading location data:', error) - // 기본 데이터는 이미 useState에서 설정됨 - } - } - - loadLocationData() - }, [contractId]) - - const updateLocationData = (rowType: keyof LocationData, field: keyof LocationData['country'], value: string) => { - setLocationData(prev => ({ - ...prev, - [rowType]: { - ...prev[rowType], - [field]: value - } - })) - } - - const handleSaveLocation = async () => { - const userId = session.data?.user?.id ? Number(session.data.user.id) : null - - if (!userId) { - toast.error('사용자 정보를 찾을 수 없습니다.') - return - } - - try { - setIsLoading(true) - - const locationDataToSave = { - enabled: isEnabled, - locations: locationData - } - - await updateLocation(contractId, locationDataToSave, userId) - toast.success('Location 정보가 저장되었습니다.') - } catch (error) { - console.error('Error saving location:', error) - toast.error('Location 정보 저장에 실패했습니다.') - } finally { - setIsLoading(false) - } - } - - return ( -
- - - -
- - Location -
-
- -
- {/* 체크박스 */} -
- { - if (!isDisabled) { - setIsEnabled(checked as boolean) - } - }} - /> - Location 활성화 -
- - {/* Location 테이블 */} -
-

Location

- -
- - - - - - - - - - - - - - - - - {/* Country Row */} - - - - - - - - - - - - - - {/* Location (City) Row */} - - - - - - - - - - - - - - {/* Sub-Contractor Row */} - - - - - - - - - - - - - -
ActivityProject ManagerEngineeringProcurementFabricationAssemblyTest (FAT)Shipping (EXW)Shipping (FOB)Remark
Country - updateLocationData('country', 'projectManager', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가" - /> - - updateLocationData('country', 'engineering', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가" - /> - - updateLocationData('country', 'procurement', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가" - /> - - updateLocationData('country', 'fabrication', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가" - /> - - updateLocationData('country', 'assembly', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가" - /> - - updateLocationData('country', 'test', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가" - /> - - updateLocationData('country', 'shippingExw', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가" - /> - - updateLocationData('country', 'shippingFob', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가" - /> - - updateLocationData('country', 'remark', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - /> -
Location (City) - updateLocationData('location', 'projectManager', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가 내 지역" - /> - - updateLocationData('location', 'engineering', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가 내 지역" - /> - - updateLocationData('location', 'procurement', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가 내 지역" - /> - - updateLocationData('location', 'fabrication', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가 내 지역" - /> - - updateLocationData('location', 'assembly', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가 내 지역" - /> - - updateLocationData('location', 'test', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가 내 지역" - /> - - updateLocationData('location', 'shippingExw', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가 내 지역" - /> - - updateLocationData('location', 'shippingFob', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가 내 지역" - /> - - updateLocationData('location', 'remark', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - /> -
Sub-Contractor
(where applicable)
- updateLocationData('subContractor', 'projectManager', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가 및 지역" - /> - - updateLocationData('subContractor', 'engineering', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가 및 지역" - /> - - updateLocationData('subContractor', 'procurement', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가 및 지역" - /> - - updateLocationData('subContractor', 'fabrication', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가 및 지역" - /> - - updateLocationData('subContractor', 'assembly', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가 및 지역" - /> - - updateLocationData('subContractor', 'test', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가 및 지역" - /> - - updateLocationData('subContractor', 'shippingExw', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가 및 지역" - /> - - updateLocationData('subContractor', 'shippingFob', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - placeholder="국가 및 지역" - /> - - updateLocationData('subContractor', 'remark', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - /> -
-
-
- - {/* 저장 버튼 */} -
- -
-
-
-
-
-
- ) -} \ No newline at end of file -- cgit v1.2.3