/** * 품목 상세 조회 Client Component * * 품목 정보를 읽기 전용으로 표시 */ 'use client'; import { useRouter } from 'next/navigation'; import type { ItemMaster } from '@/types/item'; import { ITEM_TYPE_LABELS, PART_TYPE_LABELS, PART_USAGE_LABELS, PRODUCT_CATEGORY_LABELS } from '@/types/item'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { Label } from '@/components/ui/label'; import { Card, CardContent, CardHeader, CardTitle, } from '@/components/ui/card'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table'; import { ArrowLeft, Edit, Package } from 'lucide-react'; interface ItemDetailClientProps { item: ItemMaster; } /** * 품목 유형별 Badge 반환 */ function getItemTypeBadge(itemType: string) { const badges: Record = { FG: { className: 'bg-purple-50 text-purple-700 border-purple-200' }, PT: { className: 'bg-orange-50 text-orange-700 border-orange-200' }, SM: { className: 'bg-green-50 text-green-700 border-green-200' }, RM: { className: 'bg-blue-50 text-blue-700 border-blue-200' }, CS: { className: 'bg-gray-50 text-gray-700 border-gray-200' }, }; const config = badges[itemType] || { className: '' }; return ( {ITEM_TYPE_LABELS[itemType as keyof typeof ITEM_TYPE_LABELS]} ); } /** * 조립품 품목코드 포맷팅 (하이픈 이후 제거) */ function formatItemCodeForAssembly(item: ItemMaster): string { return item.itemCode; } export default function ItemDetailClient({ item }: ItemDetailClientProps) { const router = useRouter(); return (
{/* 헤더 */}

품목 상세 정보

등록된 품목 정보를 확인합니다

{/* 기본 정보 */} 기본 정보

{formatItemCodeForAssembly(item)}

{item.itemName}

{getItemTypeBadge(item.itemType)}

{item.itemType === "PT" && item.partType && (

{item.partType === 'ASSEMBLY' ? '조립 부품' : item.partType === 'BENDING' ? '절곡 부품' : item.partType === 'PURCHASED' ? '구매 부품' : item.partType}

)} {item.itemType === "PT" && item.partType === "BENDING" && item.partUsage && (

{item.partUsage === "GUIDE_RAIL" ? "가이드레일용" : item.partUsage === "BOTTOM_FINISH" ? "하단마감재용" : item.partUsage === "CASE" ? "케이스용" : item.partUsage === "DOOR" ? "도어용" : item.partUsage === "BRACKET" ? "브라켓용" : item.partUsage === "GENERAL" ? "범용 (공통 부품)" : item.partUsage}

)} {item.itemType !== "FG" && item.partType !== 'ASSEMBLY' && item.specification && (

{item.specification}

)} {item.itemType !== "FG" && (

{item.unit}

)} {/* 버전 정보 */}
V{item.currentRevision || 0}

{(item.revisions?.length || 0)}회

{new Date(item.createdAt).toLocaleDateString('ko-KR')}

{/* 제품(FG) 전용 정보 */} {item.itemType === 'FG' && ( 제품 정보
{item.productCategory && (

{PRODUCT_CATEGORY_LABELS[item.productCategory]}

)} {item.lotAbbreviation && (

{item.lotAbbreviation}

)}
{item.note && (

{item.note}

)}
)} {/* 조립 부품 세부 정보 */} {item.itemType === 'PT' && item.partType === 'ASSEMBLY' && ( 조립 부품 세부 정보
{item.category1 && (

{item.category1 === 'guide_rail' ? '가이드레일' : item.category1 === 'case' ? '케이스' : item.category1 === 'bottom_finish' ? '하단마감재' : item.category1}

)} {item.installationType && (

{item.installationType === 'wall' ? '벽면형 (R)' : item.installationType === 'side' ? '측면형 (S)' : item.installationType === 'steel' ? '스틸 (B)' : item.installationType === 'iron' ? '철재 (T)' : item.installationType}

)} {item.assemblyType && (

{item.assemblyType}

)} {item.material && (

{item.material}

)} {item.assemblyLength && (

{item.assemblyLength}mm

)} {item.sideSpecWidth && item.sideSpecHeight && (

{item.sideSpecWidth} × {item.sideSpecHeight}mm

)}
)} {/* 가이드레일 세부 정보 */} {item.category3 === "가이드레일" && item.guideRailModelType && ( 가이드레일 세부 정보
{item.guideRailModelType && (

{item.guideRailModelType}

)} {item.guideRailModel && (

{item.guideRailModel}

)}
)} {/* BOM 정보 - 절곡 부품은 제외 */} {(item.itemType === 'FG' || (item.itemType === 'PT' && item.partType !== 'BENDING')) && item.bom && item.bom.length > 0 && (
부품 구성 (BOM) 총 {item.bom.length}개 품목
번호 품목코드 품목명 수량 단위 {item.bom.map((line, index) => ( {index + 1} {line.childItemCode}
{line.childItemName} {line.isBending && ( 절곡품 )}
{line.quantity} {line.unit}
))}
)}
); }