[WEB] feat(OrderManagement): 견적서 기반 수주 등록 기능 추가

- page.tsx: quoteId 파라미터로 견적 데이터 자동 로드
- actions.ts: getQuoteByIdForSelect 함수 추가
- index.ts: getQuoteByIdForSelect export 추가
- quotes/actions.ts: QuotationForSelect, QuotationItem 타입 export
This commit is contained in:
2026-01-27 17:41:16 +09:00
parent 8388f1243a
commit e246459a08
4 changed files with 138 additions and 5 deletions

View File

@@ -1214,6 +1214,50 @@ export async function revertOrderConfirmation(orderId: string): Promise<{
}
}
/**
* 수주 변환용 단일 견적 조회 (ID로 조회)
* 견적 상세페이지에서 수주등록 버튼 클릭 시 사용
*/
export async function getQuoteByIdForSelect(id: string): Promise<{
success: boolean;
data?: QuotationForSelect;
error?: string;
__authError?: boolean;
}> {
try {
const searchParams = new URLSearchParams();
// 품목 포함
searchParams.set('with_items', 'true');
const { response, error } = await serverFetch(
`${process.env.NEXT_PUBLIC_API_URL}/api/v1/quotes/${id}?${searchParams.toString()}`,
{ method: 'GET', cache: 'no-store' }
);
if (error) {
return { success: false, error: error.message, __authError: error.code === 'UNAUTHORIZED' };
}
if (!response) {
return { success: false, error: '견적 조회에 실패했습니다.' };
}
const result: ApiResponse<ApiQuoteForSelect> = await response.json();
if (!response.ok || !result.success) {
return { success: false, error: result.message || '견적 조회에 실패했습니다.' };
}
return {
success: true,
data: transformQuoteForSelect(result.data),
};
} catch (error) {
console.error('[getQuoteByIdForSelect] Error:', error);
return { success: false, error: '서버 오류가 발생했습니다.' };
}
}
/**
* 수주 변환용 확정 견적 목록 조회
* QuotationSelectDialog에서 사용

View File

@@ -14,17 +14,20 @@ export {
getOrderStats,
revertProductionOrder,
revertOrderConfirmation,
getQuoteByIdForSelect,
type Order,
type OrderItem as OrderItemApi,
type OrderFormData as OrderApiFormData,
type OrderItemFormData,
type OrderStats,
type OrderStatus,
type QuotationForSelect,
type QuotationItem,
} from "./actions";
// Components
export { OrderRegistration, type OrderFormData } from "./OrderRegistration";
export { QuotationSelectDialog, type QuotationForSelect, type QuotationItem } from "./QuotationSelectDialog";
export { QuotationSelectDialog } from "./QuotationSelectDialog";
export { ItemAddDialog, type OrderItem } from "./ItemAddDialog";
// 문서 컴포넌트