anoderb commited on
Commit
e651d73
·
1 Parent(s): 287a59e

Fix TypeScript build error: use type-safe record update

Browse files
frontend/app/dashboard/forecast/page.tsx CHANGED
@@ -44,14 +44,18 @@ export default function ForecastPage() {
44
 
45
  // Sync running states from backend, but keep optimistic UI if it's still running
46
  if (s?.running_tasks) {
47
- const backendRunning = Object.fromEntries(Object.entries(s.running_tasks).map(([k, v]) => [Number(k), v]))
 
 
48
  setRunningIds(prev => {
49
- const newState = { ...prev, ...backendRunning }
50
- // Remove items that backend says are not running anymore
51
- Object.keys(prev).forEach(id => {
52
- if (!backendRunning[Number(id)]) delete newState[Number(id)]
 
 
53
  })
54
- return newState
55
  })
56
  }
57
  } catch {}
 
44
 
45
  // Sync running states from backend, but keep optimistic UI if it's still running
46
  if (s?.running_tasks) {
47
+ const backendRunning: Record<number, boolean> = Object.fromEntries(
48
+ Object.entries(s.running_tasks).map(([k, v]) => [Number(k), !!v])
49
+ )
50
  setRunningIds(prev => {
51
+ const merged = { ...prev, ...backendRunning }
52
+ const cleaned: Record<number, boolean> = {}
53
+ // Hanya simpan yang memang masih running di backend
54
+ Object.entries(merged).forEach(([id, val]) => {
55
+ const nid = Number(id)
56
+ if (backendRunning[nid]) cleaned[nid] = true
57
  })
58
+ return cleaned
59
  })
60
  }
61
  } catch {}