import { client } from "@/util/api";
import { FlightConciseSchema } from "@/util/types";
import {
NavLink,
Text,
Button,
ScrollArea,
Stack,
Loader,
Center,
} from "@mantine/core";
import { Link, useLocation, useNavigate } from "@remix-run/react";
import { IconPlus } from "@tabler/icons-react";
import { useQuery } from "@tanstack/react-query";
export function FlightsList() {
const location = useLocation();
const page = location.pathname.split("/")[3];
const flights = useQuery({
queryKey: ["flights-list"],
queryFn: async () => await client.get(`/flights`).then((res) => res.data),
});
const navigate = useNavigate();
return (
}
mb="md"
onClick={() => navigate("/logbook/flights/new")}
>
Add
{flights.data ? (
flights.data.map((flight: FlightConciseSchema, index: number) => (
))
) : flights.isLoading ? (
) : (
No Flights
)}
);
}
export function MobileFlightsList() {
const location = useLocation();
const page = location.pathname.split("/")[3];
const flights = useQuery({
queryKey: ["flights-list"],
queryFn: async () => await client.get(`/flights`).then((res) => res.data),
});
const navigate = useNavigate();
return (
{flights.data ? (
flights.data.map((flight: FlightConciseSchema, index: number) => (
))
) : flights.isLoading ? (
) : (
No Flights
)}
}
mt="md"
onClick={() => navigate("/logbook/flights/new")}
>
Add
);
}
export default { FlightsList, MobileFlightsList };