feat(phase4): SCAT~Rescue 6개 탭 Mock → API 전환 + 하드코딩 제거 #45

병합
htlee feature/scat-api-conversion 에서 develop 로 3 commits 를 머지했습니다 2026-03-01 01:44:02 +09:00
Showing only changes of commit 08b8f16001 - Show all commits

파일 보기

@ -14,6 +14,7 @@ import type { BacktrackPhase, BacktrackVessel, BacktrackConditions, ReplayShip,
import { TOTAL_REPLAY_FRAMES } from '@common/types/backtrack'
import { fetchBacktrackByAcdnt, createBacktrack, fetchPredictionDetail } from '../services/predictionApi'
import type { PredictionDetail } from '../services/predictionApi'
import { api } from '@common/services/api'
export type PredictionModel = 'KOSPS' | 'POSEIDON' | 'OpenDrift'
// eslint-disable-next-line react-refresh/only-export-components
@ -259,27 +260,16 @@ export function OilSpillView() {
const models = Array.from(selectedModels)
const results = await Promise.all(
models.map(async (model) => {
const response = await fetch('http://localhost:3001/api/simulation/run', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model,
lat: incidentCoord.lat,
lon: incidentCoord.lon,
duration_hours: predictionTime,
oil_type: oilType,
spill_amount: spillAmount,
spill_type: spillType
})
const { data } = await api.post<{ trajectory: Array<{ lat: number; lon: number; time: number; particle?: number }> }>('/simulation/run', {
model,
lat: incidentCoord.lat,
lon: incidentCoord.lon,
duration_hours: predictionTime,
oil_type: oilType,
spill_amount: spillAmount,
spill_type: spillType,
})
if (!response.ok) {
throw new Error(`API 오류 (${model}): ${response.status}`)
}
const data = await response.json()
return (data.trajectory as Array<{ lat: number; lon: number; time: number; particle?: number }>)
.map(p => ({ ...p, model }))
return data.trajectory.map(p => ({ ...p, model }))
})
)