CEO 대시보드 API 전환 및 주문 관리 페이지 수정

- CEO 대시보드 mock 데이터 제거, 실제 API 연동
- 대시보드 transformers/types 추가
- 영업 주문 관리 페이지 수정
- 주문 actions 업데이트
This commit is contained in:
2026-01-22 09:47:05 +09:00
parent 81a4d6baf1
commit 6fa69d81f4
11 changed files with 149 additions and 345 deletions

View File

@@ -75,6 +75,59 @@ function calculateChangeRate(current: number, previous: number): number {
// 1. DailyReport 변환
// ============================================
/**
* 운영자금 안정성에 따른 색상 반환
* 참조: AI 리포트 색상 체계 가이드 - 섹션 2.3
*/
function getStabilityColor(stability: string): 'red' | 'green' | 'blue' {
switch (stability) {
case 'stable':
return 'blue'; // 6개월 이상 - 안정적
case 'caution':
return 'green'; // 3-6개월 - 주의 (주황 대신 green 사용, 기존 타입 호환)
case 'warning':
return 'red'; // 3개월 미만 - 경고
default:
return 'blue';
}
}
/**
* 운영자금 안정성 메시지 생성
* - 음수: 현금성 자산 적자 상태
* - 0~3개월: 자금 부족 우려
* - 3~6개월: 자금 관리 필요
* - 6개월 이상: 안정적
*/
function getStabilityMessage(months: number | null, stability: string, cashAsset: number): string {
if (months === null) {
return '월 운영비 데이터가 없어 안정성을 판단할 수 없습니다.';
}
// 현금성 자산이 음수인 경우 (적자 상태)
if (cashAsset < 0 || months < 0) {
return '현금성 자산이 부족한 상태입니다. 긴급 자금 확보가 필요합니다.';
}
// 운영 가능 기간이 거의 없는 경우 (1개월 미만)
if (months < 1) {
return '운영 자금이 거의 소진된 상태입니다. 즉시 자금 확보가 필요합니다.';
}
const monthsText = `${months}개월분`;
switch (stability) {
case 'stable':
return `월 운영비용 대비 ${monthsText}이 확보되어 안정적입니다.`;
case 'caution':
return `월 운영비용 대비 ${monthsText}이 확보되어 있습니다. 자금 관리가 필요합니다.`;
case 'warning':
return `월 운영비용 대비 ${monthsText}만 확보되어 자금 부족 우려가 있습니다.`;
default:
return `월 운영비용 대비 ${monthsText}이 확보되어 있습니다.`;
}
}
/**
* 일일 일보 CheckPoints 생성
* 참조: AI 리포트 색상 체계 가이드 - 섹션 2
@@ -109,15 +162,37 @@ function generateDailyReportCheckPoints(api: DailyReportApiResponse): CheckPoint
});
}
// 현금성 자산 현황
// 현금성 자산 + 운영자금 안정성 현황
const cashAsset = api.cash_asset_total;
const operatingMonths = api.operating_months;
const operatingStability = api.operating_stability;
const stabilityColor = getStabilityColor(operatingStability);
const stabilityMessage = getStabilityMessage(operatingMonths, operatingStability, cashAsset);
// 하이라이트 생성 (음수/적자 상태일 때는 "X개월분" 대신 다른 메시지)
const isDeficit = cashAsset < 0 || (operatingMonths !== null && operatingMonths < 0);
const isAlmostEmpty = operatingMonths !== null && operatingMonths >= 0 && operatingMonths < 1;
const highlights: Array<{ text: string; color: 'red' | 'green' | 'blue' }> = [];
if (isDeficit) {
highlights.push({ text: '긴급 자금 확보 필요', color: 'red' });
} else if (isAlmostEmpty) {
highlights.push({ text: '즉시 자금 확보 필요', color: 'red' });
} else if (operatingMonths !== null && operatingMonths >= 1) {
highlights.push({ text: `${operatingMonths}개월분`, color: stabilityColor });
if (operatingStability === 'stable') {
highlights.push({ text: '안정적', color: 'blue' });
} else if (operatingStability === 'warning') {
highlights.push({ text: '자금 부족 우려', color: 'red' });
}
}
checkPoints.push({
id: 'dr-cash-asset',
type: 'info' as CheckPointType,
message: `총 현금성 자산이 ${formatAmount(cashAsset)}입니다.`,
highlights: [
{ text: formatAmount(cashAsset), color: 'blue' as const },
],
type: isDeficit || isAlmostEmpty ? 'warning' as CheckPointType : 'info' as CheckPointType,
message: `총 현금성 자산이 ${formatAmount(cashAsset)}입니다. ${stabilityMessage}`,
highlights,
});
return checkPoints;

View File

@@ -16,6 +16,9 @@ export interface CurrencyTotals {
balance: number; // 잔액
}
/** 운영자금 안정성 상태 */
export type OperatingStability = 'stable' | 'caution' | 'warning' | 'unknown';
/** GET /api/proxy/daily-report/summary 응답 */
export interface DailyReportApiResponse {
date: string; // "2026-01-20"
@@ -25,6 +28,10 @@ export interface DailyReportApiResponse {
cash_asset_total: number; // 현금성 자산 합계
krw_totals: CurrencyTotals; // 원화 합계
usd_totals: CurrencyTotals; // 달러 합계
// 운영자금 안정성 지표
monthly_operating_expense: number; // 월 운영비 (직전 3개월 평균)
operating_months: number | null; // 운영 가능 개월 수
operating_stability: OperatingStability; // 안정성 상태
}
// ============================================