Handle totals with no flights
This commit is contained in:
parent
f0d8af101b
commit
9e4520b218
@ -1,3 +1,4 @@
|
|||||||
|
import ErrorDisplay from "@/ui/error-display";
|
||||||
import { useApi } from "@/util/api";
|
import { useApi } from "@/util/api";
|
||||||
import { FlightConciseSchema } from "@/util/types";
|
import { FlightConciseSchema } from "@/util/types";
|
||||||
import {
|
import {
|
||||||
@ -18,6 +19,7 @@ import {
|
|||||||
IconArrowRightTail,
|
IconArrowRightTail,
|
||||||
IconPlaneTilt,
|
IconPlaneTilt,
|
||||||
IconPlus,
|
IconPlus,
|
||||||
|
IconX,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { UseQueryResult, useQuery } from "@tanstack/react-query";
|
import { UseQueryResult, useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
@ -62,6 +64,14 @@ function FlightsListDisplay({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{flights.data ? (
|
{flights.data ? (
|
||||||
|
Object.entries(flights.data)?.length === 0 ? (
|
||||||
|
<Center h="calc(100vh - 95px - 50px)">
|
||||||
|
<Stack align="center">
|
||||||
|
<IconX size="3rem" />
|
||||||
|
<Center>No flights</Center>
|
||||||
|
</Stack>
|
||||||
|
</Center>
|
||||||
|
) : (
|
||||||
Object.entries(flights.data)
|
Object.entries(flights.data)
|
||||||
.reverse()
|
.reverse()
|
||||||
.map(([year, months]) => (
|
.map(([year, months]) => (
|
||||||
@ -176,10 +186,13 @@ function FlightsListDisplay({
|
|||||||
</NavLink>
|
</NavLink>
|
||||||
</>
|
</>
|
||||||
))
|
))
|
||||||
|
)
|
||||||
) : flights.isLoading ? (
|
) : flights.isLoading ? (
|
||||||
<Center h="calc(100vh - 95px - 50px)">
|
<Center h="calc(100vh - 95px - 50px)">
|
||||||
<Loader />
|
<Loader />
|
||||||
</Center>
|
</Center>
|
||||||
|
) : flights.isError ? (
|
||||||
|
<ErrorDisplay error={flights.error?.message} />
|
||||||
) : (
|
) : (
|
||||||
<Center h="calc(100vh - 95px - 50px)">
|
<Center h="calc(100vh - 95px - 50px)">
|
||||||
<Text p="sm">No Flights</Text>
|
<Text p="sm">No Flights</Text>
|
||||||
|
@ -45,8 +45,11 @@ export default function Index() {
|
|||||||
staleTime: 1000,
|
staleTime: 1000,
|
||||||
retry: (failureCount, error: Error) => {
|
retry: (failureCount, error: Error) => {
|
||||||
return (
|
return (
|
||||||
!error ||
|
failureCount < 5 &&
|
||||||
(error instanceof AxiosError && error.response?.status !== 401)
|
(!error ||
|
||||||
|
(error instanceof AxiosError &&
|
||||||
|
error.response?.status !== 401 &&
|
||||||
|
error.response?.status !== 404))
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user