diff --git a/src/components/business/construction/item-management/ItemDetailClient.tsx b/src/components/business/construction/item-management/ItemDetailClient.tsx index 9fecdcdb..00f21ba4 100644 --- a/src/components/business/construction/item-management/ItemDetailClient.tsx +++ b/src/components/business/construction/item-management/ItemDetailClient.tsx @@ -22,10 +22,9 @@ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { IntegratedDetailTemplate } from '@/components/templates/IntegratedDetailTemplate'; import { itemConfig } from './itemConfig'; import { toast } from 'sonner'; -import type { ItemFormData, ItemType, Specification, OrderType, ItemStatus, OrderItem } from './types'; +import type { ItemFormData, ItemType, OrderType, ItemStatus, OrderItem } from './types'; import { ITEM_TYPE_OPTIONS, - SPECIFICATION_OPTIONS, ORDER_TYPE_OPTIONS, STATUS_OPTIONS, UNIT_OPTIONS, @@ -42,8 +41,7 @@ const initialFormData: ItemFormData = { itemNumber: '', itemType: '제품', categoryId: '', - itemName: '', - specification: '인정', + itemName: '', specification: '', unit: 'SET', orderType: '경품발주', status: '사용', @@ -322,22 +320,13 @@ export default function ItemDetailClient({
- + />
diff --git a/src/components/business/construction/item-management/ItemManagementClient.tsx b/src/components/business/construction/item-management/ItemManagementClient.tsx index 27296161..70772bd0 100644 --- a/src/components/business/construction/item-management/ItemManagementClient.tsx +++ b/src/components/business/construction/item-management/ItemManagementClient.tsx @@ -12,7 +12,7 @@ import { UniversalListPage, type UniversalListConfig, type TableColumn, type Fil import { MobileCard } from '@/components/organisms/MobileCard'; import { toast } from 'sonner'; import { DeleteConfirmDialog } from '@/components/ui/confirm-dialog'; -import type { Item, ItemStats, ItemType, Specification, OrderType, ItemStatus } from './types'; +import type { Item, ItemStats, ItemType, OrderType, ItemStatus } from './types'; import { ITEM_TYPE_OPTIONS, SPECIFICATION_OPTIONS, @@ -59,7 +59,7 @@ export default function ItemManagementClient({ const [searchValue, setSearchValue] = useState(''); const [itemTypeFilter, setItemTypeFilter] = useState('all'); const [categoryFilter, setCategoryFilter] = useState('all'); - const [specificationFilter, setSpecificationFilter] = useState('all'); + const [specificationFilter, setSpecificationFilter] = useState('all'); const [orderTypeFilter, setOrderTypeFilter] = useState('all'); const [statusFilter, setStatusFilter] = useState('all'); const [sortBy, setSortBy] = useState<'latest' | 'oldest'>('latest'); @@ -479,7 +479,7 @@ export default function ItemManagementClient({ setCategoryFilter(value as string); break; case 'specification': - setSpecificationFilter(value as Specification | 'all'); + setSpecificationFilter(value as string); break; case 'orderType': setOrderTypeFilter(value as OrderType | 'all'); diff --git a/src/components/business/construction/item-management/actions.ts b/src/components/business/construction/item-management/actions.ts index f7128447..4b971bfb 100644 --- a/src/components/business/construction/item-management/actions.ts +++ b/src/components/business/construction/item-management/actions.ts @@ -37,12 +37,13 @@ function transformToBackendItemType(frontendType: ItemType): string { } /** - * Backend options → Frontend specification 변환 + * Backend attributes.spec → Frontend specification 변환 + * 실제 규격 텍스트 (예: "1∅220V", "면적 18.1m²") */ -function transformSpecification(options: Record | null | undefined): Specification { - const spec = options?.specification; - if (spec === '인정' || spec === '비인정') return spec; - return '인정'; // 기본값 +function transformSpecification(attributes: Record | null | undefined): Specification { + const spec = attributes?.spec; + if (typeof spec === 'string' && spec.trim()) return spec.trim(); + return '-'; } /** @@ -95,6 +96,7 @@ interface ApiItem { category?: { name?: string } | null; unit: string | null; options: Record | null; + attributes: Record | null; is_active: boolean; description: string | null; created_at: string; @@ -110,7 +112,7 @@ function transformItem(apiItem: ApiItem): Item { categoryId: apiItem.category_id ? String(apiItem.category_id) : '', categoryName: apiItem.category?.name || '', unit: apiItem.unit || 'EA', - specification: transformSpecification(apiItem.options), + specification: transformSpecification(apiItem.attributes), orderType: transformOrderType(apiItem.options), status: transformStatus(apiItem.is_active, apiItem.options), createdAt: apiItem.created_at, @@ -141,8 +143,10 @@ function transformItemToApi(data: ItemFormData): Record { unit: data.unit, is_active: data.status === '사용' || data.status === '승인', description: data.note || null, + attributes: { + spec: data.specification || null, + }, options: { - specification: data.specification, orderType: data.orderType, status: data.status, orderItems: data.orderItems, diff --git a/src/components/business/construction/item-management/constants.ts b/src/components/business/construction/item-management/constants.ts index d9c33fd2..a3fe2e47 100644 --- a/src/components/business/construction/item-management/constants.ts +++ b/src/components/business/construction/item-management/constants.ts @@ -11,11 +11,9 @@ export const ITEM_TYPE_OPTIONS: { value: ItemType | 'all'; label: string }[] = [ { value: '공과', label: '공과' }, ]; -// 규격 옵션 -export const SPECIFICATION_OPTIONS: { value: Specification | 'all'; label: string }[] = [ +// 규격 필터 옵션 (규격 있음/없음) +export const SPECIFICATION_OPTIONS: { value: string; label: string }[] = [ { value: 'all', label: '전체' }, - { value: '인정', label: '인정' }, - { value: '비인정', label: '비인정' }, ]; // 구분(발주유형) 옵션 diff --git a/src/components/business/construction/item-management/types.ts b/src/components/business/construction/item-management/types.ts index 22ee6832..5db1ac3f 100644 --- a/src/components/business/construction/item-management/types.ts +++ b/src/components/business/construction/item-management/types.ts @@ -3,8 +3,8 @@ // 물품유형 export type ItemType = '제품' | '부품' | '소모품' | '공과'; -// 규격 -export type Specification = '인정' | '비인정'; +// 규격 (실제 스펙 텍스트, 예: "1∅220V", "면적 18.1m²") +export type Specification = string; // 구분 (발주유형) export type OrderType = '경품발주' | '원자재발주' | '외주발주';