feat(phase4): SCAT~Rescue 6개 탭 Mock → API 전환 + 하드코딩 제거 #45
@ -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 }))
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
불러오는 중...
Reference in New Issue
Block a user