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

100% Statements 5/5
100% Branches 2/2
100% Functions 1/1
100% Lines 5/5

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                                                            18x   18x 10x     8x       8x                                      
import cx from "classnames";
import React from "react";
import { TrimetRoute } from "../../../api/trimet/interfaces/types";
import { StopLocationWithDistance } from "../../../state/arrivals/formatStopLocations";
import StopBookmarkControlContainer from "../containers/StopBookmarkControlContainer";
import ReloadIntervalCoordinator from "./ReloadIntervalCoordinator";
import StopInfo from "./StopInfo";
import "./StopsTableHeader.css";
 
interface Props {
  stopLocation?: StopLocationWithDistance;
  refresh: () => void;
  nextRefreshAt: number | null;
  now: number;
  loading: boolean;
  showArrivals: boolean;
  onRouteIndicatorClick?: (route: TrimetRoute) => void;
  locationId: number;
}
 
export default function StopsTableHeader(props: Props) {
  const {
    stopLocation,
    loading,
    showArrivals,
    refresh,
    nextRefreshAt,
    now,
    onRouteIndicatorClick,
    locationId,
  } = props;
 
  if (!stopLocation) {
    return null;
  }
 
  const classNames = cx("nearbyStops-header", {
    "arrivals-hidden": !showArrivals,
  });
 
  return (
    <div className={classNames}>
      <StopInfo stopLocation={stopLocation} onClick={onRouteIndicatorClick} />
      <div className="stop-control-section">
        <StopBookmarkControlContainer
          locationId={locationId}
          stopLocation={stopLocation}
        />
        <ReloadIntervalCoordinator
          refresh={refresh}
          nextRefreshAt={nextRefreshAt}
          now={now}
          loading={loading}
          showArrivals={showArrivals}
        />
      </div>
    </div>
  );
}