diff --git a/web/app/routes/logbook.flights/flights-list.tsx b/web/app/routes/logbook.flights/flights-list.tsx index 5dbaac4..14dabe5 100644 --- a/web/app/routes/logbook.flights/flights-list.tsx +++ b/web/app/routes/logbook.flights/flights-list.tsx @@ -1,3 +1,4 @@ +import ErrorDisplay from "@/ui/error-display"; import { useApi } from "@/util/api"; import { FlightConciseSchema } from "@/util/types"; import { @@ -18,6 +19,7 @@ import { IconArrowRightTail, IconPlaneTilt, IconPlus, + IconX, } from "@tabler/icons-react"; import { UseQueryResult, useQuery } from "@tanstack/react-query"; @@ -62,124 +64,135 @@ function FlightsListDisplay({ return ( <> {flights.data ? ( - Object.entries(flights.data) - .reverse() - .map(([year, months]) => ( - <> - - <> - - {Object.entries(months) - .reverse() - .map(([month, days]) => ( - - - {Object.entries(days) - .reverse() - .map(([, logs]) => ( - <> - {logs - .reverse() - .map((flight: FlightConciseSchema) => ( - <> - - - {flight.date} - - - {`${Number( - flight.time_total - ).toFixed(1)} hr`} + Object.entries(flights.data)?.length === 0 ? ( +
+ + +
No flights
+
+
+ ) : ( + Object.entries(flights.data) + .reverse() + .map(([year, months]) => ( + <> + + <> + + {Object.entries(months) + .reverse() + .map(([month, days]) => ( + + + {Object.entries(days) + .reverse() + .map(([, logs]) => ( + <> + {logs + .reverse() + .map((flight: FlightConciseSchema) => ( + <> + + + {flight.date} + + + {`${Number( + flight.time_total + ).toFixed(1)} hr`} + + {flight.waypoint_from || + flight.waypoint_to ? ( + <> + / + + {flight.waypoint_from ? ( + + {flight.waypoint_from} + + ) : ( + "" + )} + {flight.waypoint_from && + flight.waypoint_to ? ( + + ) : null} + {flight.waypoint_to ? ( + + {flight.waypoint_to} + + ) : ( + "" + )} + + + ) : null} + + } + description={ + + {flight.comments + ? flight.comments + : "(No Comment)"} - {flight.waypoint_from || - flight.waypoint_to ? ( - <> - / - - {flight.waypoint_from ? ( - - {flight.waypoint_from} - - ) : ( - "" - )} - {flight.waypoint_from && - flight.waypoint_to ? ( - - ) : null} - {flight.waypoint_to ? ( - - {flight.waypoint_to} - - ) : ( - "" - )} - - - ) : null} - - } - description={ - - {flight.comments - ? flight.comments - : "(No Comment)"} - - } - rightSection={ - flight.aircraft ? ( - - } - color="gray" - size="lg" - > - {flight.aircraft} - - ) : null - } - active={page === flight.id} - /> - - - ))} - - ))} - - ))} - - - - )) + } + rightSection={ + flight.aircraft ? ( + + } + color="gray" + size="lg" + > + {flight.aircraft} + + ) : null + } + active={page === flight.id} + /> + + + ))} + + ))} + + ))} + +
+ + )) + ) ) : flights.isLoading ? (
+ ) : flights.isError ? ( + ) : (
No Flights diff --git a/web/app/routes/logbook/route.tsx b/web/app/routes/logbook/route.tsx index 1b35c26..d76396d 100644 --- a/web/app/routes/logbook/route.tsx +++ b/web/app/routes/logbook/route.tsx @@ -45,8 +45,11 @@ export default function Index() { staleTime: 1000, retry: (failureCount, error: Error) => { return ( - !error || - (error instanceof AxiosError && error.response?.status !== 401) + failureCount < 5 && + (!error || + (error instanceof AxiosError && + error.response?.status !== 401 && + error.response?.status !== 404)) ); }, },