From 0253931b423537d1e1627452cf18e3104235a4cb Mon Sep 17 00:00:00 2001 From: Vitalsine85 Date: Mon, 21 Oct 2024 10:05:39 -0400 Subject: [PATCH 1/2] add back button to login header --- apps/portal/app/routes/login.tsx | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/apps/portal/app/routes/login.tsx b/apps/portal/app/routes/login.tsx index 131263525..2c86f608b 100644 --- a/apps/portal/app/routes/login.tsx +++ b/apps/portal/app/routes/login.tsx @@ -1,4 +1,11 @@ -import { Text } from '@0xintuition/1ui' +import { + Button, + ButtonSize, + ButtonVariant, + Icon, + IconName, + Text, +} from '@0xintuition/1ui' import PrivyLoginButton from '@client/privy-login-button' import { BuiltOnBase } from '@components/built-on-base' @@ -13,7 +20,7 @@ import { LoaderFunctionArgs, redirect, } from '@remix-run/node' -import { Link, useLoaderData, useSubmit } from '@remix-run/react' +import { Link, useLoaderData, useNavigate, useSubmit } from '@remix-run/react' import { getFeatureFlags } from '@server/env' import { verifyPrivyAccessToken } from '@server/privy' import { PATHS } from 'app/consts' @@ -66,12 +73,24 @@ export default function Login() { submit(formData, { method: 'post' }) } + const navigate = useNavigate() + return (
- +
+ + +
From 59635fbae3070d0a82da0aa5a73ace5b94ba757b Mon Sep 17 00:00:00 2001 From: Vitalsine85 Date: Mon, 21 Oct 2024 10:12:06 -0400 Subject: [PATCH 2/2] add action route to clear onboarding cookie --- .../actions+/clear-onboarding-cookie.tsx | 23 +++++++++++++++++++ apps/portal/app/routes/login.tsx | 18 +++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 apps/portal/app/routes/actions+/clear-onboarding-cookie.tsx diff --git a/apps/portal/app/routes/actions+/clear-onboarding-cookie.tsx b/apps/portal/app/routes/actions+/clear-onboarding-cookie.tsx new file mode 100644 index 000000000..ea80d63e6 --- /dev/null +++ b/apps/portal/app/routes/actions+/clear-onboarding-cookie.tsx @@ -0,0 +1,23 @@ +import { ActionFunctionArgs, json } from '@remix-run/node' +import { onboardingModalCookie } from '@server/onboarding' + +export async function action({ request }: ActionFunctionArgs) { + const formData = await request.formData() + if (formData.get('action') === 'clearOnboardingCookie') { + return json( + { success: true }, + { + headers: { + 'Set-Cookie': await onboardingModalCookie.serialize( + {}, + { + expires: new Date(0), + maxAge: 0, + }, + ), + }, + }, + ) + } + return json({ success: false }) +} diff --git a/apps/portal/app/routes/login.tsx b/apps/portal/app/routes/login.tsx index 2c86f608b..50ddec8de 100644 --- a/apps/portal/app/routes/login.tsx +++ b/apps/portal/app/routes/login.tsx @@ -20,7 +20,13 @@ import { LoaderFunctionArgs, redirect, } from '@remix-run/node' -import { Link, useLoaderData, useNavigate, useSubmit } from '@remix-run/react' +import { + Link, + useFetcher, + useLoaderData, + useNavigate, + useSubmit, +} from '@remix-run/react' import { getFeatureFlags } from '@server/env' import { verifyPrivyAccessToken } from '@server/privy' import { PATHS } from 'app/consts' @@ -73,7 +79,15 @@ export default function Login() { submit(formData, { method: 'post' }) } + const fetcher = useFetcher() const navigate = useNavigate() + const handleBackNavigation = () => { + fetcher.submit( + { action: 'clearOnboardingCookie' }, + { method: 'post', action: '/actions/clear-onboarding-cookie' }, + ) + navigate(PATHS.THE_BIG_BANG) + } return (
@@ -82,7 +96,7 @@ export default function Login() {