Get started
Examples

Race course table

Race course table

ItineraryWaypointTable lists the places along a course. Add the cutoff column and the service filter, and runners can read the course at a glance.

src/Course.tsx
/// <reference types="vite/client" />
import { Mountaya } from "@mountaya/client/browser";
import { ItineraryWaypointTable } from "@mountaya/elements-react/elements";
import { MountayaElementsProvider } from "@mountaya/elements-react/headless";
import "@mountaya/elements-react/styles.css";
import { useState } from "react";

const client = new Mountaya({
  credential: { publishableKey: import.meta.env.VITE_MOUNTAYA_PUBLISHABLE_KEY },
});

// One of your published itineraries.
const ITINERARY_ID = "0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21";

// Cut-offs in the course's own time zone, whatever the reader's.
const formatCutoffAt = (iso: string) =>
  new Intl.DateTimeFormat("en-GB", {
    hour: "2-digit",
    minute: "2-digit",
    timeZone: "Europe/Paris",
    weekday: "short",
  }).format(new Date(iso));

export const Course = () => {
  const [filter, setFilter] = useState<readonly string[]>([]);

  return (
    <MountayaElementsProvider client={client}>
      <ItineraryWaypointTable
        columns={["waypoint", "distance", "elevation", "amenities", "cutoff"]}
        filter={filter}
        formatCutoffAt={formatCutoffAt}
        itineraryId={ITINERARY_ID}
        onFilterChange={setFilter}
      />
    </MountayaElementsProvider>
  );
};

Leave out columns and the filter for the default table: waypoint, distance, elevation and services.

Next steps

Last updated