All files / applications/go-by-transit/src/view/nearbyStops/components StopComponent.tsx

100% Statements 2/2
88.88% Branches 8/9
100% Functions 1/1
100% Lines 2/2

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                                              18x 18x                                          
import { Button } from "@wintermuted/ui-react";
import React from "react";
import type { Arrival } from "../../../api/trimet/interfaces/arrivals";
import type { TrimetRoute } from "../../../api/trimet/interfaces/types";
import type { StopLocationWithDistance } from "../../../state/arrivals/formatStopLocations";
import ArrivalsComponent from "../../arrivals/components/ArrivalsComponent";
import "../../nearby/components/NearbyViewComponent.scss";
import StopsTableHeader from "./StopsTableHeader";
 
interface Props {
  stopLocation?: StopLocationWithDistance;
  locationId: number;
  loading: boolean;
  error?: string;
  arrivals?: Arrival[];
  refresh: () => void;
  nextRefreshAt: number | null;
  now: number;
  showArrivals: boolean;
  onRouteIndicatorClick?: (route: TrimetRoute) => void;
}
 
export default function StopComponent(props: Props) {
  const { error, loading, locationId, refresh, showArrivals } = props;
  return (
    <article className="stop">
      <StopsTableHeader {...props} />
      {loading && !props.stopLocation && (
        <p role="status">Loading stop {locationId}...</p>
      )}
      {error && (
        <div>
          <p role="alert">
            {error}
            {props.arrivals && " Showing the last received arrivals."}
          </p>
          <Button onClick={refresh} disabled={loading}>
            Try again
          </Button>
        </div>
      )}
      {showArrivals && <ArrivalsComponent {...props} />}
    </article>
  );
}