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-offset-details.tsx | 314 --------------------- 1 file changed, 314 deletions(-) delete mode 100644 lib/general-contracts/detail/general-contract-offset-details.tsx (limited to 'lib/general-contracts/detail/general-contract-offset-details.tsx') diff --git a/lib/general-contracts/detail/general-contract-offset-details.tsx b/lib/general-contracts/detail/general-contract-offset-details.tsx deleted file mode 100644 index af4f2ef2..00000000 --- a/lib/general-contracts/detail/general-contract-offset-details.tsx +++ /dev/null @@ -1,314 +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 { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' -import { Plus, Trash2, Save, LoaderIcon, RotateCcw } from 'lucide-react' -import { getOffsetDetails, updateOffsetDetails } from '../service' -import { toast } from 'sonner' - -interface OffsetDetailsProps { - contractId: number - contractType?: string -} - -interface OffsetDetailItem { - id: string - project: string - poNumber: string - poItemDescription: string - offsetReason: string - contractCurrency: string - contractAmount: string - offsetDate: string - remark: string -} - -export function OffsetDetails({ contractId }: OffsetDetailsProps) { - const session = useSession() - const [isLoading, setIsLoading] = useState(false) - const [isEnabled, setIsEnabled] = useState(true) - - // 특정 계약종류를 제외한 일반계약은 Default로 표시 - const isDisabled = false - - const [offsetDetails, setOffsetDetails] = useState([]) - - // 회입/상계사유 옵션 - const offsetReasonOptions = [ - '판매자 사양불만족', - '납기지연', - '품질불량', - '계약조건변경', - '기타' - ] - - // 초기 데이터 로드 - useEffect(() => { - const loadOffsetDetails = async () => { - try { - const data = await getOffsetDetails(contractId) - if (data && data.enabled !== undefined) { - setIsEnabled(data.enabled) - setOffsetDetails(data.offsetDetails || []) - } else { - } - } catch (error) { - console.error('회입/상계내역 데이터 로드 실패:', error) - toast.error('회입/상계내역 데이터를 불러오는데 실패했습니다.') - } - } - - loadOffsetDetails() - }, [contractId]) - - const addOffsetDetailRow = () => { - const newRow: OffsetDetailItem = { - id: Date.now().toString(), - project: '', - poNumber: '', - poItemDescription: '', - offsetReason: '', - contractCurrency: 'KRW', - contractAmount: '', - offsetDate: '', - remark: '' - } - setOffsetDetails([...offsetDetails, newRow]) - } - - const removeOffsetDetailRow = (id: string) => { - setOffsetDetails(offsetDetails.filter(item => item.id !== id)) - } - - const updateOffsetDetailData = (id: string, field: keyof OffsetDetailItem, value: string) => { - setOffsetDetails(prev => - prev.map(item => - item.id === id ? { ...item, [field]: value } : item - ) - ) - } - - const handleSaveOffsetDetails = async () => { - if (!session.data?.user?.id) { - toast.error('로그인이 필요합니다.') - return - } - - setIsLoading(true) - try { - const offsetDetailsData = { - enabled: isEnabled, - offsetDetails: offsetDetails - } - - await updateOffsetDetails(contractId, offsetDetailsData, Number(session.data.user.id)) - toast.success('회입/상계내역이 성공적으로 저장되었습니다.') - } catch (error) { - console.error('회입/상계내역 저장 실패:', error) - toast.error('회입/상계내역 저장에 실패했습니다.') - } finally { - setIsLoading(false) - } - } - - return ( -
- - - -
- - 회입/상계내역 -
-
- -
- {/* 체크박스 */} -
- { - if (!isDisabled) { - setIsEnabled(checked as boolean) - } - }} - /> - 회입/상계내역 활성화 -
- - {/* 회입/상계내역 테이블 */} -
-
-

회입/상계내역

-
- - -
-
- -
- - - - - - - - - - - - - - - - - {offsetDetails.map((item, index) => ( - - - - - - - - - - - - - ))} - -
No.프로젝트발주번호발주품목(Description)회입/상계사유계약통화계약금액회입/상계일비고Action
{index + 1} - updateOffsetDetailData(item.id, 'project', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - /> - - updateOffsetDetailData(item.id, 'poNumber', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - /> - - updateOffsetDetailData(item.id, 'poItemDescription', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - /> - - - - updateOffsetDetailData(item.id, 'contractCurrency', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - /> - - updateOffsetDetailData(item.id, 'contractAmount', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - /> - - updateOffsetDetailData(item.id, 'offsetDate', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - /> - - updateOffsetDetailData(item.id, 'remark', e.target.value)} - disabled={isDisabled || !isEnabled} - className="border-0 bg-transparent p-0 h-auto" - /> - - -
-
-
- - {/* 저장 버튼 */} -
- -
-
-
-
-
-
- ) -} -- cgit v1.2.3