'use client' import React from 'react' import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from '@/components/ui/dialog' import { Badge } from '@/components/ui/badge' import { Separator } from '@/components/ui/separator' import { format } from 'date-fns' import { ko } from 'date-fns/locale' interface PriceAdjustmentData { id: number itemName?: string | null adjustmentReflectionPoint?: string | null majorApplicableRawMaterial?: string | null adjustmentFormula?: string | null rawMaterialPriceIndex?: string | null referenceDate?: Date | string | null comparisonDate?: Date | string | null adjustmentRatio?: string | null notes?: string | null adjustmentConditions?: string | null majorNonApplicableRawMaterial?: string | null adjustmentPeriod?: string | null contractorWriter?: string | null adjustmentDate?: Date | string | null nonApplicableReason?: string | null createdAt: Date | string updatedAt: Date | string } interface PriceAdjustmentDialogProps { open: boolean onOpenChange: (open: boolean) => void data: PriceAdjustmentData | null vendorName: string } export function PriceAdjustmentDialog({ open, onOpenChange, data, vendorName, }: PriceAdjustmentDialogProps) { if (!data) return null // 날짜 포맷팅 헬퍼 const formatDateValue = (date: Date | string | null) => { if (!date) return '-' try { const dateObj = typeof date === 'string' ? new Date(date) : date return format(dateObj, 'yyyy-MM-dd', { locale: ko }) } catch { return '-' } } // 연동제 적용 여부 판단 (majorApplicableRawMaterial이 있으면 적용, majorNonApplicableRawMaterial이 있으면 미적용) const isApplied = !!data.majorApplicableRawMaterial const isNotApplied = !!data.majorNonApplicableRawMaterial return ( 하도급대금등 연동표 {vendorName} {isApplied && ( 연동제 적용 )} {isNotApplied && ( 연동제 미적용 )} 협력업체가 제출한 연동제 적용 정보입니다. {isApplied && " (연동제 적용)"} {isNotApplied && " (연동제 미적용)"}
{/* 기본 정보 */}

기본 정보

{data.itemName || '-'}

{isApplied && ( 예 (연동제 적용) )} {isNotApplied && ( 아니오 (연동제 미적용) )} {!isApplied && !isNotApplied && ( - )}
{isApplied && (

{data.adjustmentReflectionPoint || '-'}

)}
{/* 원재료 정보 */}

원재료 정보

{isApplied && (

{data.majorApplicableRawMaterial || '-'}

)} {isNotApplied && ( <>

{data.majorNonApplicableRawMaterial || '-'}

{data.nonApplicableReason || '-'}

)}
{isApplied && ( <> {/* 연동 공식 및 지표 */}

연동 공식 및 지표

{data.adjustmentFormula || '-'}

{data.rawMaterialPriceIndex || '-'}

{data.referenceDate ? formatDateValue(data.referenceDate) : '-'}

{data.comparisonDate ? formatDateValue(data.comparisonDate) : '-'}

{data.adjustmentRatio && (

{data.adjustmentRatio}%

)}
{/* 조정 조건 및 기타 */}

조정 조건 및 기타

{data.adjustmentConditions || '-'}

{data.adjustmentPeriod || '-'}

{data.adjustmentDate ? formatDateValue(data.adjustmentDate) : '-'}

{data.contractorWriter || '-'}

{data.notes && (

{data.notes}

)}
)} {isNotApplied && ( <>

작성자 정보

{data.contractorWriter || '-'}

)} {/* 메타 정보 */}

작성일: {formatDateValue(data.createdAt)}

수정일: {formatDateValue(data.updatedAt)}

) }