All checks were successful
Deploy to Netlify / Deploy to Netlify (push) Successful in 1m54s
33 lines
815 B
TypeScript
33 lines
815 B
TypeScript
import { Navigate } from "react-router";
|
||
import Error from "~/components/error";
|
||
import Loader from "~/components/loader";
|
||
import { MainLayout } from "~/layout";
|
||
import { AUTH_ERROR, useUser } from "~/lib/api";
|
||
import { forceReload } from "~/lib/utils";
|
||
import RepasPage from "~/components/repas";
|
||
|
||
export default function Repas() {
|
||
const { user, isLoading, error } = useUser();
|
||
|
||
if (isLoading) {
|
||
return <Loader />;
|
||
}
|
||
if (error?.message === AUTH_ERROR) {
|
||
return <Navigate to="/login" replace />;
|
||
}
|
||
if (error) {
|
||
return <Error message={error.message} />;
|
||
}
|
||
|
||
return (
|
||
<MainLayout
|
||
header={
|
||
<h1 className="text-2xl font-bold" onClick={forceReload}>
|
||
Khollisé - {user.className} ⚔️
|
||
</h1>
|
||
}
|
||
>
|
||
<RepasPage />
|
||
</MainLayout>
|
||
);
|
||
}
|