diff --git a/web/app/root.tsx b/web/app/root.tsx
index e831785..536be05 100644
--- a/web/app/root.tsx
+++ b/web/app/root.tsx
@@ -14,6 +14,9 @@ import {
useRouteError,
} from "@remix-run/react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
+
import {
Button,
ColorSchemeScript,
@@ -23,11 +26,9 @@ import {
Stack,
Title,
} from "@mantine/core";
-import { TailfinAppShell } from "./ui/nav/app-shell";
import { IconRocket } from "@tabler/icons-react";
-import Providers from "./providers";
-import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
-import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
+
+import { AuthProvider } from "./util/auth";
export const links: LinksFunction = () => [
...(cssBundleHref ? [{ rel: "stylesheet", href: cssBundleHref }] : []),
@@ -60,7 +61,7 @@ export function ErrorBoundary() {
}
component={Link}
- to="/"
+ to="/logbook"
variant="default"
>
Get me out of here!
@@ -89,10 +90,12 @@ export default function App() {
-
-
-
-
+
+
+
+
+
+
diff --git a/web/app/routes/logbook.flights.$id/route.tsx b/web/app/routes/logbook.flights.$id/route.tsx
index c2514d2..eef6ca6 100644
--- a/web/app/routes/logbook.flights.$id/route.tsx
+++ b/web/app/routes/logbook.flights.$id/route.tsx
@@ -1,12 +1,11 @@
import { client } from "@/util/api";
import { List, Stack, Text } from "@mantine/core";
import { useParams } from "@remix-run/react";
-import { useQuery, useQueryClient } from "@tanstack/react-query";
+import { useQuery } from "@tanstack/react-query";
export default function Flight() {
const params = useParams();
- const queryClient = useQueryClient();
const flight = useQuery({
queryKey: [params.id],
queryFn: async () =>
diff --git a/web/app/routes/logbook.flights/flights-list.tsx b/web/app/routes/logbook.flights/flights-list.tsx
index 06c5bdd..675f343 100644
--- a/web/app/routes/logbook.flights/flights-list.tsx
+++ b/web/app/routes/logbook.flights/flights-list.tsx
@@ -1,20 +1,11 @@
import { client } from "@/util/api";
-import {
- Divider,
- NavLink,
- Text,
- Container,
- Button,
- ScrollArea,
- Stack,
-} from "@mantine/core";
+import { Flight } from "@/util/types";
+import { NavLink, Text, Button, ScrollArea, Stack } from "@mantine/core";
import { Link, useLocation } from "@remix-run/react";
import { IconPlus } from "@tabler/icons-react";
-import { useQuery, useQueryClient } from "@tanstack/react-query";
+import { useQuery } from "@tanstack/react-query";
export function FlightsList() {
- const queryClient = useQueryClient();
-
const flights = useQuery({
queryKey: ["flights-list"],
queryFn: () => client.get(`/flights`).then((res) => res.data),
@@ -30,7 +21,7 @@ export function FlightsList() {
{flights.data ? (
- flights.data.map((flight, index) => (
+ flights.data.map((flight: Flight, index: number) => (
client.get(`/flights`).then((res) => res.data),
@@ -62,7 +51,7 @@ export function MobileFlightsList() {
{flights.data ? (
- flights.data.map((flight, index) => (
+ flights.data.map((flight: Flight, index: number) => (
- {me.data?.username}
+ {user}
);
}
diff --git a/web/app/routes/logbook/route.tsx b/web/app/routes/logbook/route.tsx
index da1a004..6877504 100644
--- a/web/app/routes/logbook/route.tsx
+++ b/web/app/routes/logbook/route.tsx
@@ -1,6 +1,8 @@
import { TailfinAppShell } from "@/ui/nav/app-shell";
+import { useAuth } from "@/util/auth";
import type { MetaFunction } from "@remix-run/node";
-import { Outlet } from "@remix-run/react";
+import { Outlet, useNavigate } from "@remix-run/react";
+import { useEffect } from "react";
export const meta: MetaFunction = () => {
return [
@@ -10,11 +12,20 @@ export const meta: MetaFunction = () => {
};
export default function Index() {
+ const { user, loading } = useAuth();
+ const navigate = useNavigate();
+
+ useEffect(() => {
+ console.log("loading: " + loading);
+ console.log("user: " + user);
+ if (!loading && !user) {
+ navigate("/login");
+ }
+ }, [user, loading, navigate]);
+
return (
-
-
-
-
-
+
+
+
);
}
diff --git a/web/app/routes/login/route.tsx b/web/app/routes/login/route.tsx
index 3e29a10..2ef3c71 100644
--- a/web/app/routes/login/route.tsx
+++ b/web/app/routes/login/route.tsx
@@ -1,5 +1,4 @@
-import { client } from "@/util/api";
-import { useLogin } from "@/util/hooks";
+import { useAuth } from "@/util/auth";
import {
Box,
Button,
@@ -19,7 +18,7 @@ export default function Login() {
},
});
- const signInMutation = useLogin();
+ const { signin } = useAuth();
return (
@@ -29,7 +28,7 @@ export default function Login() {