2022-05-30 00:21:42 +00:00
|
|
|
import { type LinksFunction, type LoaderFunction, json } from "@remix-run/node";
|
2023-04-29 05:49:56 +00:00
|
|
|
import { Outlet, useCatch, useMatches } from "@remix-run/react";
|
2022-05-14 10:22:06 +00:00
|
|
|
|
2022-05-30 00:21:42 +00:00
|
|
|
import serverConfig from "~/config/config.server";
|
2023-04-29 16:30:07 +00:00
|
|
|
import type { SessionData } from "~/utils/session.server";
|
2022-05-14 10:22:06 +00:00
|
|
|
import Footer from "~/features/core/components/footer";
|
2022-06-05 22:34:50 +00:00
|
|
|
import ServiceWorkerUpdateNotifier from "~/features/core/components/service-worker-update-notifier";
|
2022-06-12 21:17:22 +00:00
|
|
|
import Notification from "~/features/core/components/notification";
|
2022-06-05 21:11:21 +00:00
|
|
|
import useServiceWorkerRevalidate from "~/features/core/hooks/use-service-worker-revalidate";
|
2022-06-14 23:28:32 +00:00
|
|
|
import useDevice from "~/features/phone-calls/hooks/use-device";
|
2022-05-30 00:21:42 +00:00
|
|
|
import footerStyles from "~/features/core/components/footer.css";
|
|
|
|
import appStyles from "~/styles/app.css";
|
2023-04-29 16:30:07 +00:00
|
|
|
import { getSession } from "~/utils/session.server";
|
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 = {
|
2023-04-29 16:30:07 +00:00
|
|
|
sessionData: SessionData;
|
2022-05-30 00:21:42 +00:00
|
|
|
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 }) => {
|
2023-04-29 16:30:07 +00:00
|
|
|
const session = await getSession(request);
|
|
|
|
|
2022-05-30 00:21:42 +00:00
|
|
|
return json<AppLoaderData>({
|
2023-04-29 16:30:07 +00:00
|
|
|
sessionData: { twilio: session.data.twilio },
|
2022-05-30 00:21:42 +00:00
|
|
|
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() {
|
2022-06-14 23:28:32 +00:00
|
|
|
useDevice();
|
2022-06-05 21:11:21 +00:00
|
|
|
useServiceWorkerRevalidate();
|
2022-05-14 10:22:06 +00:00
|
|
|
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 (
|
2022-06-12 21:17:22 +00:00
|
|
|
<>
|
|
|
|
<div className="h-full w-full overflow-hidden fixed bg-gray-100">
|
|
|
|
<div className="flex flex-col w-full h-full">
|
|
|
|
<ServiceWorkerUpdateNotifier />
|
|
|
|
<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 ? null : <Footer />}
|
2022-05-14 10:22:06 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-12 21:17:22 +00:00
|
|
|
<Notification />
|
|
|
|
</>
|
2022-05-14 10:22:06 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
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>
|
|
|
|
);
|
|
|
|
}
|