// 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; } 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; } export interface ComplianceCategoryResponse { categoryCode: string; categoryName: string; indicatorType: string; indicators: ComplianceIndicatorResponse[]; } // 방법론 변경 이력 타입 export interface MethodologyHistoryResponse { historyId: number; changeDate: string; changeTypeCode: string; changeType: string; description: 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; nationalityCode: string; nationalityIsoCode: string | null; 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; status: string; parentCompanyCode: string | null; parentCompanyName: string | null; registrationCountry: string; registrationCountryCode: string; registrationCountryIsoCode: string | null; controlCountry: string | null; controlCountryCode: string | null; controlCountryIsoCode: string | null; foundedDate: string | null; email: string | null; phone: string | null; website: string | null; } // 지표 현재 상태 export interface IndicatorStatusResponse { columnName: string; fieldName: string; categoryCode: string; category: string; value: string | null; narrative: string | null; sortOrder: number; } const BASE = '/snp-global/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}`), getMethodologyBanner: (lang = 'KO') => fetchJson>(`${BASE}/methodology-banner?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}`), };