Files
TREK/client/src/components/Tours/ReadStatusNotice.tsx
T
Maurice 204ee2ef86 chore(ci): give the server test typecheck room, format new client files
The server's src and tests together are past 570,000 lines and the test
typecheck needs about 4.3 GB, over Node's default heap; it now gets 8 GB like
the test jobs. Forty new client files are formatted, and the react-hooks/refs
baseline drops by the one warning a split hook removed.
2026-10-20 18:39:58 +02:00

42 lines
1.5 KiB
TypeScript

import { AlertTriangle, Loader2, RefreshCw, WifiOff } from 'lucide-react';
import { useTranslation } from '../../i18n';
import { fs } from '../shared/DialogShell';
import { CardAction, TourNotice } from './tourParts';
/**
* How a card's online read stands while it has no answer to show (a bike
* tour's ways, a hike's SAC grades): still asking, offline, or failed with a
* way to ask again. Nothing while the answer is there, so the card shows it.
*/
export function ReadStatusNotice({
status,
messages,
onRetry,
}: {
status: string;
messages: { loading: string; offline: string; failed: string };
onRetry: () => void;
}) {
const { t } = useTranslation();
if (status === 'loading')
return (
<span role="status" className="inline-flex items-center gap-1.5 text-content-muted" style={fs(11.5, 'body')}>
<Loader2 size={12} strokeWidth={2} className="animate-spin" />
{messages.loading}
</span>
);
if (status === 'offline')
return <TourNotice icon={<WifiOff size={13} strokeWidth={2} />}>{messages.offline}</TourNotice>;
if (status !== 'failed') return null;
return (
<TourNotice tone="warning" icon={<AlertTriangle size={13} strokeWidth={2} />}>
<span className="flex flex-wrap items-center gap-x-2 gap-y-1">
<span>{messages.failed}</span>
<CardAction icon={<RefreshCw size={12} strokeWidth={2} />} onClick={onRetry}>
{t('common.errorRetry')}
</CardAction>
</span>
</TourNotice>
);
}