From fdbac9082c8d967223d41b314fe3fa9e4d12b209 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Tue, 24 May 2022 21:14:42 +0300 Subject: [PATCH] Prompt user to log in if accessing plus logged out --- app/components/Catcher.tsx | 35 +++++++++++++++++++++++++++++++++ app/components/layout/index.tsx | 19 +++++++++--------- app/root.tsx | 3 +-- app/routes/plus/index.tsx | 3 +++ app/styles/common.css | 9 +++++++++ 5 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 app/components/Catcher.tsx diff --git a/app/components/Catcher.tsx b/app/components/Catcher.tsx new file mode 100644 index 000000000..e48e1e26b --- /dev/null +++ b/app/components/Catcher.tsx @@ -0,0 +1,35 @@ +import { useCatch } from "@remix-run/react"; +import { Button } from "~/components/Button"; +import { useUser } from "~/hooks/useUser"; +import { LOG_IN_URL, SENDOU_INK_DISCORD_URL } from "~/utils/urls"; + +export function Catcher() { + const caught = useCatch(); + const user = useUser(); + + switch (caught.status) { + case 401: + return ( +
+ If you need assistance you can ask for help on{" "} + + our Discord + +
+ ) : ( + + )} +