diff --git a/src/app/[locale]/(protected)/sales/pricing-management/create/page.tsx b/src/app/[locale]/(protected)/sales/pricing-management/create/page.tsx index 60baae73..a382901b 100644 --- a/src/app/[locale]/(protected)/sales/pricing-management/create/page.tsx +++ b/src/app/[locale]/(protected)/sales/pricing-management/create/page.tsx @@ -1,8 +1,10 @@ /** * 단가 등록 페이지 * - * 경로: /sales/pricing-management/create?itemId=xxx&itemTypeCode=MATERIAL|PRODUCT + * 경로: /sales/pricing-management/create?itemId=xxx * API: POST /api/v1/pricing + * + * item_type_code는 품목 정보에서 자동으로 가져옴 (FG, PT, SM, RM, CS 등) */ import { PricingFormClient } from '@/components/pricing'; @@ -13,14 +15,12 @@ interface CreatePricingPageProps { searchParams: Promise<{ itemId?: string; itemCode?: string; - itemTypeCode?: 'PRODUCT' | 'MATERIAL'; // PRODUCT 또는 MATERIAL (API 등록 시 필요) }>; } export default async function CreatePricingPage({ searchParams }: CreatePricingPageProps) { const params = await searchParams; const itemId = params.itemId || ''; - const itemTypeCode = params.itemTypeCode || 'MATERIAL'; // 품목 정보 조회 const itemInfo = itemId ? await getItemInfo(itemId) : null; @@ -53,10 +53,11 @@ export default async function CreatePricingPage({ searchParams }: CreatePricingP } // 서버 액션: 단가 등록 + // item_type_code는 data.itemType에서 자동으로 가져옴 async function handleSave(data: PricingData) { 'use server'; - const result = await createPricing(data, itemTypeCode); + const result = await createPricing(data); if (!result.success) { throw new Error(result.error || '단가 등록에 실패했습니다.'); diff --git a/src/components/pricing/PricingListClient.tsx b/src/components/pricing/PricingListClient.tsx index 1554017c..88e2bc79 100644 --- a/src/components/pricing/PricingListClient.tsx +++ b/src/components/pricing/PricingListClient.tsx @@ -153,9 +153,8 @@ export function PricingListClient({ // 네비게이션 핸들러 const handleRegister = (item: PricingListItem) => { - // itemTypeCode를 URL 파라미터에 포함 (PRODUCT 또는 MATERIAL) - const itemTypeCode = item.itemTypeCode || 'MATERIAL'; - router.push(`/sales/pricing-management/create?itemId=${item.itemId}&itemCode=${item.itemCode}&itemTypeCode=${itemTypeCode}`); + // item_type_code는 품목 정보에서 자동으로 가져오므로 URL에 포함하지 않음 + router.push(`/sales/pricing-management/create?itemId=${item.itemId}&itemCode=${item.itemCode}`); }; const handleEdit = (item: PricingListItem) => { diff --git a/src/components/pricing/actions.ts b/src/components/pricing/actions.ts index a6e00f8b..1ca4bfea 100644 --- a/src/components/pricing/actions.ts +++ b/src/components/pricing/actions.ts @@ -152,10 +152,11 @@ function transformApiToFrontend(apiData: PriceApiData): PricingData { /** * 프론트엔드 데이터 → API 요청 형식 변환 + * item_type_code는 품목 정보(data.itemType)에서 가져옴 (FG, PT, SM, RM, CS 등) */ -function transformFrontendToApi(data: PricingData, itemTypeCode: 'PRODUCT' | 'MATERIAL' = 'MATERIAL'): Record { +function transformFrontendToApi(data: PricingData): Record { return { - item_type_code: itemTypeCode, + item_type_code: data.itemType, // 품목에서 가져온 실제 item_type 값 사용 item_id: parseInt(data.itemId), purchase_price: data.purchasePrice || null, processing_cost: data.processingCost || null, @@ -252,14 +253,14 @@ export async function getItemInfo(itemId: string): Promise { /** * 단가 등록 + * item_type_code는 data.itemType에서 자동으로 가져옴 */ export async function createPricing( - data: PricingData, - itemTypeCode: 'PRODUCT' | 'MATERIAL' = 'MATERIAL' + data: PricingData ): Promise<{ success: boolean; data?: PricingData; error?: string }> { try { const headers = await getApiHeaders(); - const apiData = transformFrontendToApi(data, itemTypeCode); + const apiData = transformFrontendToApi(data); console.log('[PricingActions] POST pricing request:', apiData); @@ -308,7 +309,7 @@ export async function updatePricing( const apiData = { ...transformFrontendToApi(data), change_reason: changeReason || null, - }; + } as Record; console.log('[PricingActions] PUT pricing request:', apiData); diff --git a/src/components/pricing/types.ts b/src/components/pricing/types.ts index ba8be511..c6cf81d4 100644 --- a/src/components/pricing/types.ts +++ b/src/components/pricing/types.ts @@ -111,7 +111,7 @@ export interface PricingListItem { itemId: string; itemCode: string; itemName: string; - itemType: string; + itemType: string; // FG, PT, SM, RM, CS 등 (API 등록 시 item_type_code로 사용) specification?: string; unit: string; purchasePrice?: number; @@ -122,7 +122,6 @@ export interface PricingListItem { status: PricingStatus | 'not_registered'; currentRevision: number; isFinal: boolean; - itemTypeCode?: 'PRODUCT' | 'MATERIAL'; // API 등록 시 필요 (PRODUCT 또는 MATERIAL) } // ===== 유틸리티 타입 =====