Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production 2024-02-18_01 #71

Merged
merged 1 commit into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading