Skip to content

Commit

Permalink
Revert "Revert "fix: Header buttons"" (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsun969 authored Feb 18, 2024
1 parent d7f5c57 commit a2c51c9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/app/(account)/signin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 {
Expand All @@ -35,6 +38,7 @@ export default function SignInPage() {

if (result.status === 'complete') {
await setActive({ session: result.createdSessionId });
router.push('/');
} else {
console.log(result);
}
Expand Down
26 changes: 16 additions & 10 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -156,15 +161,16 @@ export default function Header() {
Continue Signing Up
</Button>
)}
{!checkUserPaid.data?.paid && (
<Button
colour="orange"
href="/settings"
onClick={closeMenu}
>
Continue to payment
</Button>
)}
{checkUserExists.data?.exists &&
!checkUserPaid.data?.paid && (
<Button
colour="orange"
href="/settings"
onClick={closeMenu}
>
Continue to payment
</Button>
)}
<UserButton
userExists={Boolean(checkUserExists.data?.exists)}
userPaid={Boolean(checkUserPaid.data?.paid)}
Expand Down

0 comments on commit a2c51c9

Please sign in to comment.