diff --git a/src/components/templates/TideTablePage.tsx b/src/components/templates/TideTablePage.tsx index f1d2e78..55bc87d 100644 --- a/src/components/templates/TideTablePage.tsx +++ b/src/components/templates/TideTablePage.tsx @@ -1,6 +1,6 @@ import * as React from "react" import type { HeadFC, PageProps } from "gatsby" -import { Card, Center, Container, Group, Image, Text } from "@mantine/core" +import { Card, Center, Container, Group, Image, Table, Text } from "@mantine/core" import TidalData from "../../../data/tides.json"; import { SEO } from "../../components/SEO"; import Layout from "../navigation/Layout"; @@ -8,27 +8,44 @@ import { DateTime } from "luxon"; import { TidesJson_PDFObject, TidesJson_ScheduleObject } from "../../types"; -const Page: React.FC = ({ pageContext }: { pageContext: { pdf: TidesJson_PDFObject } }) => { - const firstDayOfMonth = pageContext.pdf.date; +const Page: React.FC = ({ pageContext }) => { + const { pdf } = pageContext as { pdf: TidesJson_PDFObject }; + const firstDayOfMonth = pdf.date; const monthMatch = firstDayOfMonth.split("-")[0] + firstDayOfMonth.split("-")[1]; const tides = TidalData.schedule.filter((element: TidesJson_ScheduleObject) => { return element.date.startsWith(monthMatch) }); - console.log(tides) return ( - {tides.map((element: TidesJson_ScheduleObject, index: React.Key) => ( - - - {DateTime.fromSQL(element.date).toLocaleString({ weekday: "long", day: "2-digit", month: "long" })} - {element.groups.map(tide => ( - - {DateTime.fromSQL(element.date + " " + tide.time).toLocaleString(DateTime.TIME_SIMPLE)} - {tide.height}m - + + + + Date + Sunrise + Time + Height + Time + Height + Sunset + + + + {tides.map((element: TidesJson_ScheduleObject, index: React.Key) => ( + element.groups.map(tide => ( + + {DateTime.fromSQL(element.date).toLocaleString({ weekday: "long", day: "2-digit" })} + {element.groups.map(tide => ( + <> + {DateTime.fromSQL(element.date + " " + tide.time).toLocaleString(DateTime.TIME_SIMPLE)} + {tide.height} + + ))} + {element.groups.length === 1 ? : null} + + )) ))} - - ))} + +
) }