// API 응답 타입 interface ApiResponse { success: boolean; message: string; data: T; } // Risk 지표 타입 export interface RiskIndicatorResponse { indicatorId: number; fieldKey: string; fieldName: string; description: string; conditionRed: string; conditionAmber: string; conditionGreen: string; dataType: string; collectionNote: string; } export interface RiskCategoryResponse { categoryCode: string; categoryName: string; indicators: RiskIndicatorResponse[]; } // Compliance 지표 타입 export interface ComplianceIndicatorResponse { indicatorId: number; fieldKey: string; fieldName: string; description: string; conditionRed: string; conditionAmber: string; conditionGreen: string; dataType: string; collectionNote: string; } export interface ComplianceCategoryResponse { category: string; indicatorType: string; indicators: ComplianceIndicatorResponse[]; } // 방법론 변경 이력 타입 export interface MethodologyHistoryResponse { historyId: number; changeDate: string; changeType: string; updateTitle: string; description: string; collectionNote: string; } // 값 변경 이력 타입 export interface ChangeHistoryResponse { rowIndex: number; searchKey: string; lastModifiedDate: string; changedColumnName: string; beforeValue: string; afterValue: string; fieldName: string; narrative: string; prevNarrative: string; sortOrder: number; } // 선박 기본 정보 export interface ShipInfoResponse { imoNo: string; shipName: string; shipStatus: string; nationality: string; shipType: string; dwt: string; gt: string; buildYear: string; mmsiNo: string; callSign: string; shipTypeGroup: string; } // 회사 기본 정보 export interface CompanyInfoResponse { companyCode: string; fullName: string; abbreviation: string; country: string; city: string; status: string; registrationCountry: string; address: string; } // 지표 현재 상태 export interface IndicatorStatusResponse { columnName: string; fieldName: string; category: string; value: string | null; narrative: string | null; sortOrder: number; } const BASE = '/snp-api/api/screening-guide'; async function fetchJson(url: string): Promise { const res = await fetch(url); if (!res.ok) throw new Error(`API Error: ${res.status}`); return res.json(); } export const screeningGuideApi = { getRiskIndicators: (lang = 'KO') => fetchJson>(`${BASE}/risk-indicators?lang=${lang}`), getComplianceIndicators: (lang = 'KO', type = 'SHIP') => fetchJson>(`${BASE}/compliance-indicators?lang=${lang}&type=${type}`), getMethodologyHistory: (lang = 'KO') => fetchJson>(`${BASE}/methodology-history?lang=${lang}`), getShipRiskHistory: (imoNo: string, lang = 'KO') => fetchJson>(`${BASE}/history/ship-risk?imoNo=${imoNo}&lang=${lang}`), getShipComplianceHistory: (imoNo: string, lang = 'KO') => fetchJson>(`${BASE}/history/ship-compliance?imoNo=${imoNo}&lang=${lang}`), getCompanyComplianceHistory: (companyCode: string, lang = 'KO') => fetchJson>(`${BASE}/history/company-compliance?companyCode=${companyCode}&lang=${lang}`), getShipInfo: (imoNo: string) => fetchJson>(`${BASE}/ship-info?imoNo=${imoNo}`), getShipRiskStatus: (imoNo: string, lang = 'KO') => fetchJson>(`${BASE}/ship-risk-status?imoNo=${imoNo}&lang=${lang}`), getShipComplianceStatus: (imoNo: string, lang = 'KO') => fetchJson>(`${BASE}/ship-compliance-status?imoNo=${imoNo}&lang=${lang}`), getCompanyInfo: (companyCode: string) => fetchJson>(`${BASE}/company-info?companyCode=${companyCode}`), getCompanyComplianceStatus: (companyCode: string, lang = 'KO') => fetchJson>(`${BASE}/company-compliance-status?companyCode=${companyCode}&lang=${lang}`), };