shellphone.app/app/routes/__app.tsx

48 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-05-14 22:35:51 +00:00
import { type LoaderFunction, json } from "@remix-run/node";
2022-05-14 10:22:06 +00:00
import { Outlet, useCatch, useMatches } from "@remix-run/react";
import { type SessionData, requireLoggedIn } from "~/utils/auth.server";
2022-05-14 10:22:06 +00:00
import Footer from "~/features/core/components/footer";
2022-05-14 22:35:51 +00:00
2022-05-19 22:55:02 +00:00
export type AppLoaderData = SessionData;
2022-05-14 10:22:06 +00:00
2022-05-19 22:55:02 +00:00
export const loader: LoaderFunction = async ({ request }) => {
const sessionData = await requireLoggedIn(request);
2022-05-14 22:35:51 +00:00
return json<AppLoaderData>(sessionData);
2022-05-19 22:55:02 +00:00
};
2022-05-14 10:22:06 +00:00
export default function __App() {
const matches = useMatches();
const hideFooter = matches.some((match) => match.handle?.hideFooter === true);
2022-05-14 10:22:06 +00:00
return (
<div className="h-full w-full overflow-hidden fixed bg-gray-100">
<div className="flex flex-col w-full h-full">
<div className="flex flex-col flex-1 w-full overflow-y-auto">
<main className="flex flex-col flex-1 my-0 h-full">
<Outlet />
</main>
</div>
{!hideFooter ? <Footer /> : null}
</div>
</div>
);
}
export function CatchBoundary() {
const caught = useCatch();
console.log("caught", caught);
return (
<div className="h-full w-full overflow-hidden fixed bg-gray-100">
<div className="flex flex-col w-full h-full">
<div className="flex flex-col flex-1 w-full overflow-y-auto">
2022-05-19 22:55:02 +00:00
<main className="flex flex-col flex-1 my-0 h-full">{caught.status}</main>
2022-05-14 10:22:06 +00:00
</div>
<Footer />
</div>
</div>
);
}