Files
linux-cloud-router/web/src/BackupSummary.tsx
T

19 lines
660 B
TypeScript

import { Chip } from '@mui/material'
import type { BackupState } from './api.ts'
/** The colour of each result of a backup run. */
const RESULT_COLORS: Record<string, 'success' | 'warning' | 'error' | 'info'> = {
ok: 'success',
warning: 'warning',
failed: 'error',
interrupted: 'error',
running: 'info',
}
/** The result of the last backup run as a chip, or "never" before the first. */
export function BackupChip(props: { state: BackupState | null }) {
return props.state
? <Chip size="small" label={props.state.result} color={RESULT_COLORS[props.state.result] ?? 'default'} />
: <Chip size="small" label="never" variant="outlined" />
}