2022-05-30 00:21:42 +00:00
|
|
|
import { type LinksFunction, type LoaderFunction, json } from "@remix-run/node";
|
2022-05-14 10:22:06 +00:00
|
|
|
import { Outlet, useCatch, useMatches } from "@remix-run/react";
|
|
|
|
|
2022-05-30 00:21:42 +00:00
|
|
|
import serverConfig from "~/config/config.server";
|
2022-05-21 19:33:23 +00:00
|
|
|
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-30 00:21:42 +00:00
|
|
|
import footerStyles from "~/features/core/components/footer.css";
|
|
|
|
import appStyles from "~/styles/app.css";
|
2022-05-14 22:35:51 +00:00
|
|
|
|
2022-05-30 00:21:42 +00:00
|
|
|
export const links: LinksFunction = () => [
|
|
|
|
{ rel: "stylesheet", href: appStyles },
|
|
|
|
{ rel: "stylesheet", href: footerStyles },
|
|
|
|
];
|
|
|
|
|
|
|
|
export type AppLoaderData = {
|
|
|
|
sessionData: SessionData;
|
|
|
|
config: { webPushPublicKey: string };
|
|
|
|
};
|
2022-05-14 10:22:06 +00:00
|
|
|
|
2022-05-19 22:55:02 +00:00
|
|
|
export const loader: LoaderFunction = async ({ request }) => {
|
2022-05-21 19:33:23 +00:00
|
|
|
const sessionData = await requireLoggedIn(request);
|
2022-05-14 22:35:51 +00:00
|
|
|
|
2022-05-30 00:21:42 +00:00
|
|
|
return json<AppLoaderData>({
|
|
|
|
sessionData,
|
|
|
|
config: {
|
|
|
|
webPushPublicKey: serverConfig.webPush.publicKey,
|
|
|
|
},
|
|
|
|
});
|
2022-05-19 22:55:02 +00:00
|
|
|
};
|
2022-05-14 10:22:06 +00:00
|
|
|
|
|
|
|
export default function __App() {
|
|
|
|
const matches = useMatches();
|
2022-05-21 19:33:23 +00:00
|
|
|
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>
|
2022-05-30 00:21:42 +00:00
|
|
|
{hideFooter ? null : <Footer />}
|
2022-05-14 10:22:06 +00:00
|
|
|
</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>
|
|
|
|
);
|
|
|
|
}
|