diff --git a/frontend/src/pages/CalendarPage.tsx b/frontend/src/pages/CalendarPage.tsx index 16ce0d2..1ec46db 100644 --- a/frontend/src/pages/CalendarPage.tsx +++ b/frontend/src/pages/CalendarPage.tsx @@ -41,9 +41,16 @@ interface SeriesMeta { assets: string[] } +interface BootstrapSeriesResult { + status: string + name?: string + inserted?: number + skipped?: number +} + interface BootstrapStatus { running: boolean - last_result: Record | { error: string } | null + last_result: unknown } // ── Constants ───────────────────────────────────────────────────────────────── @@ -152,8 +159,15 @@ function BootstrapPanel({ onDone }: { onDone: () => void }) { return () => clearInterval(iv) }, [polling]) - const result = bsStatus.last_result - const hasError = result && 'error' in result + const rawResult = bsStatus.last_result as Record | null + const bootstrapError: string | null = + rawResult && typeof (rawResult as { error?: unknown }).error === 'string' + ? (rawResult as { error: string }).error + : null + const bootstrapEntries: [string, BootstrapSeriesResult][] = + rawResult && !bootstrapError + ? (Object.entries(rawResult) as [string, BootstrapSeriesResult][]) + : [] return (
@@ -197,19 +211,19 @@ function BootstrapPanel({ onDone }: { onDone: () => void }) {
)} - {result && !bsStatus.running && ( - hasError ? ( -
Erreur : {'error' in result ? result.error : ''}
+ {rawResult && !bsStatus.running && ( + bootstrapError ? ( +
Erreur : {bootstrapError}
) : (
- {Object.entries(result as Record).map(([sid, r]) => ( + {bootstrapEntries.map(([sid, r]) => (
{sid}{' '} - {r.status === 'ok' ? `+${r.inserted} / skip ${r.skipped}` : 'failed'} + {r.status === 'ok' ? `+${r.inserted ?? 0} / skip ${r.skipped ?? 0}` : 'failed'}
))}