All files / applications/go-by-transit/src/view/bookmarks/component/bookmarkSections/sectionSelector RouteBookmarksInSectionSelector.tsx

100% Statements 3/3
100% Branches 0/0
100% Functions 3/3
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                      14x                     7x                    
import { MultiSelect } from "@wintermuted/ui-react/select";
import React from "react";
import { RouteBookmark } from "../../../../../api/localstorage/routeBookmarks";
 
interface Props {
  routesInSection: RouteBookmark[];
  allRoutes: RouteBookmark[];
  onChange: (value: any, event: any) => void;
}
 
function formatRoutes(routes: RouteBookmark[]) {
  return routes.map(route => ({
    label: `Route ${route.route}: ${route.desc}`,
    value: route.route
  }));
}
 
export default function RouteBookmarksInSectionSelector({
  routesInSection,
  allRoutes,
  onChange
}: Props) {
  return (
    <MultiSelect
      aria-label="Routes in this bookmark section"
      options={formatRoutes(allRoutes)}
      isMulti={true}
      value={formatRoutes(routesInSection)}
      onChange={onChange}
    />
  );
}