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 | 4x 4x 4x 4x 1x | import { RefreshAction } from "@wintermuted/ui-react";
import _ from "lodash";
import React from "react";
import { getAlertsForRoute } from "../../../api/trimet/alertScopes";
import { Alert } from "../../../api/trimet/interfaces/alertsData";
import "./NearbyRouteDetail.scss";
interface Props {
id: number;
alerts: Alert[];
loading: boolean;
error: boolean;
onRetry: () => void;
}
export default class RouteAlerts extends React.Component<Props> {
public render() {
const { id, alerts, loading, error, onRetry } = this.props;
const scopedAlerts = getAlertsForRoute(alerts || [], id);
Iif (loading && !alerts) {
return <p role="status">Loading route alerts...</p>;
}
return (
<div className="route-alerts-wrapper">
<h3>Route {id} alerts</h3>
<RefreshAction
size="sm"
onRefresh={onRetry}
loading={loading}
error={error}
labels={{
idle: "Refresh",
loading: "Refreshing...",
retry: "Try again",
}}
/>
{error && (
<p role="alert">
{alerts
? "Could not refresh alerts. Showing the last received alerts."
: "Could not load alerts for this route. Try again."}
</p>
)}
{scopedAlerts.length ? (
<ul>
{_.map(scopedAlerts, (alert) => (
<li key={alert.id}>{alert.desc || alert.header_text}</li>
))}
</ul>
) : !loading && !error ? (
<p role="status">No active alerts for this route.</p>
) : null}
</div>
);
}
}
|