feat(api): world/system/crew snapshots expose the active + pending task queue (#44)

This commit is contained in:
2026-10-02 19:42:19 +00:00
parent 178de6e4fb
commit 84d1aa8122
7 changed files with 212 additions and 24 deletions
+3 -3
View File
@@ -3,7 +3,7 @@
import { useEffect, useState } from 'react'
import { Badge } from '@/components/ui/badge'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import type { CrewDto } from '@/lib/game/save'
import type { CrewDto, CrewState } from '@/lib/game/save'
// CREW tab — the ship's roster: starting crew plus members found while exploring. Fetches
// /api/crew on mount; Radix unmounts inactive tabs, so opening this tab always refetches
@@ -22,10 +22,10 @@ export function CrewPanel({ narrow }: CrewPanelProps) {
fetch('/api/crew')
.then(async (res) => {
if (!res.ok) throw new Error(`HTTP ${res.status}`)
return (await res.json()) as CrewDto[]
return (await res.json()) as CrewState // { crew, tasks } — the endpoint wraps the roster (JC-7)
})
.then((r) => {
if (!cancelled) setRoster(r)
if (!cancelled) setRoster(r.crew)
})
.catch((err: unknown) => {
if (!cancelled) setError(err instanceof Error ? err.message : String(err))
+3 -3
View File
@@ -17,7 +17,7 @@ import { ShipSystemsPanel } from '@/components/ship-systems'
import { SkillTreePanel } from '@/components/skill-tree'
import { WorldMapPanel } from '@/components/world-map'
import { CREW_CAPACITY } from '@/lib/game/ship-costs'
import type { CrewDto, SystemState } from '@/lib/game/save'
import type { CrewState, SystemState } from '@/lib/game/save'
import type { ShipState } from '@/lib/game/ship'
import type { TechDto } from '@/lib/game/tech'
import pkg from '@/package.json'
@@ -94,10 +94,10 @@ export function MissionControl() {
fetch('/api/crew')
.then(async (res) => {
if (!res.ok) throw new Error(`HTTP ${res.status}`)
return (await res.json()) as CrewDto[]
return (await res.json()) as CrewState // { crew, tasks } — the endpoint wraps the roster (JC-7)
})
.then((c) => {
if (!cancelled) setCrewCount(c.length)
if (!cancelled) setCrewCount(c.crew.length)
})
.catch(() => {})
return () => {