Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | 17x 10x 7x 2x 17x | import {
Alert,
Card,
CardBody,
CardHeader,
RefreshAction,
} from "@wintermuted/ui-react";
import React from "react";
import FontAwesome from "react-fontawesome";
import type { Alert as IAlert } from "@overworld/trimet-client";
import type { AlertFeedState } from "./types";
export interface SystemAlertsCardProps extends AlertFeedState {
systemAlertsData: IAlert[] | undefined;
}
function getSystemAlerts({
systemAlertsData,
loading,
error,
onRefresh,
loadingContent,
}: SystemAlertsCardProps) {
if (loading && !systemAlertsData) {
return loadingContent;
}
return (
<>
{error && (
<p role="alert">
{systemAlertsData
? "Could not refresh system alerts. Showing the last received alerts."
: "Could not load system alerts. Try again."}
</p>
)}
{systemAlertsData?.length ? (
systemAlertsData.map((alert) => (
<Alert key={alert.id} tone="warning">
<h3>{alert.header_text}</h3>
{alert.desc && <p>{alert.desc}</p>}
{alert.info_link_url && (
<p style={{ marginBottom: 0 }}>
<a href={alert.info_link_url}>More Info</a>
</p>
)}
</Alert>
))
) : !error ? (
<p role="status">No system alerts right now.</p>
) : null}
<RefreshAction
size="sm"
onRefresh={onRefresh}
loading={loading}
error={error}
labels={{
idle: "Refresh",
loading: "Refreshing...",
retry: "Try again",
}}
/>
</>
);
}
export function SystemAlertsCard(props: SystemAlertsCardProps) {
return (
<Card>
<CardHeader as="h5">
<FontAwesome name="bell" />
System Alerts
</CardHeader>
<CardBody>{getSystemAlerts(props)}</CardBody>
</Card>
);
}
|