From a23b7a6358a88b18b49f618115719d72d64b64d0 Mon Sep 17 00:00:00 2001 From: jsun969 Date: Sun, 18 Feb 2024 21:37:38 +1030 Subject: [PATCH 1/3] fix(signin): redirect to home page after sign in with email --- src/app/(account)/signin/page.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/(account)/signin/page.tsx b/src/app/(account)/signin/page.tsx index 332bb7d7..5690b6ed 100644 --- a/src/app/(account)/signin/page.tsx +++ b/src/app/(account)/signin/page.tsx @@ -6,6 +6,7 @@ import FancyRectangle from '@/components/FancyRectangle'; import { useSignIn } from '@clerk/clerk-react'; import { zodResolver } from '@hookform/resolvers/zod'; import Link from 'next/link'; +import { useRouter } from 'next/navigation'; import { useForm } from 'react-hook-form'; import { FcGoogle } from 'react-icons/fc'; import { z } from 'zod'; @@ -25,6 +26,8 @@ export default function SignInPage() { resolver: zodResolver(signInSchema), }); + const router = useRouter(); + const handleSignIn = form.handleSubmit(async ({ email, password }) => { if (!isLoaded) return; try { @@ -35,6 +38,7 @@ export default function SignInPage() { if (result.status === 'complete') { await setActive({ session: result.createdSessionId }); + router.push('/'); } else { console.log(result); } From 1fa6ebd295a28fc1b08c7fdefba28129612a1f90 Mon Sep 17 00:00:00 2001 From: jsun969 Date: Sun, 18 Feb 2024 21:38:33 +1030 Subject: [PATCH 2/3] fix(header): two buttons when user haven't finished sign in --- src/components/Header.tsx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 9972d5a0..ea3e8824 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -156,15 +156,16 @@ export default function Header() { Continue Signing Up )} - {!checkUserPaid.data?.paid && ( - - )} + {checkUserExists.data?.exists && + !checkUserPaid.data?.paid && ( + + )} Date: Sun, 18 Feb 2024 21:39:05 +1030 Subject: [PATCH 3/3] fix(header): disable payment check when user not exist --- src/components/Header.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/Header.tsx b/src/components/Header.tsx index ea3e8824..ad7ffcd5 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -28,7 +28,12 @@ export default function Header() { }); const checkUserPaid = useSWR<{ paid: boolean }>(['payment'], fetcher.get.query, { - isPaused: () => clerkUser.isLoaded && !clerkUser.isSignedIn, + isPaused: () => { + if (clerkUser.isLoaded && !clerkUser.isSignedIn) { + return true; + } + return !checkUserExists.data?.exists; + }, }); const [isScrolled, setIsScrolled] = useState(false);