Open History to see the last commit
1import { PROVIDER_DISPLAY_NAMES, type ServerProvider } from "@t3tools/contracts";
2import { memo } from "react";
3import { Alert, AlertDescription, AlertTitle } from "../ui/alert";
4import { CircleAlertIcon } from "lucide-react";
5
6export const ProviderStatusBanner = memo(function ProviderStatusBanner({
7 status,
8}: {
9 status: ServerProvider | null;
10}) {
11 if (!status || status.status === "ready" || status.status === "disabled") {
12 return null;
13 }
14
15 const providerLabel = PROVIDER_DISPLAY_NAMES[status.provider] ?? status.provider;
16 const defaultMessage =
17 status.status === "error"
18 ? `${providerLabel} provider is unavailable.`
19 : `${providerLabel} provider has limited availability.`;
20 const title = `${providerLabel} provider status`;
21
22 return (
23 <div className="pt-3 mx-auto max-w-3xl">
24 <Alert variant={status.status === "error" ? "error" : "warning"}>
25 <CircleAlertIcon />
26 <AlertTitle>{title}</AlertTitle>
27 <AlertDescription className="line-clamp-3" title={status.message ?? defaultMessage}>
28 {status.message ?? defaultMessage}
29 </AlertDescription>
30 </Alert>
31 </div>
32 );
33});