forked from vercel/nextjs-subscription-payments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
signin.tsx
60 lines (54 loc) · 1.6 KB
/
signin.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { useRouter } from 'next/router';
import { useEffect } from 'react';
import { useUser, useSupabaseClient } from '@supabase/auth-helpers-react';
import { Auth } from '@supabase/auth-ui-react';
import { ThemeSupa } from '@supabase/auth-ui-shared';
import LoadingDots from '@/components/ui/LoadingDots';
import Logo from '@/components/icons/Logo';
import { getURL } from '@/utils/helpers';
const SignIn = () => {
const router = useRouter();
const user = useUser();
const supabaseClient = useSupabaseClient();
useEffect(() => {
if (user) {
router.replace('/account');
}
}, [user]);
if (!user)
return (
<div className="flex justify-center height-screen-helper">
<div className="flex flex-col justify-between max-w-lg p-3 m-auto w-80 ">
<div className="flex justify-center pb-12 ">
<Logo width="64px" height="64px" />
</div>
<div className="flex flex-col space-y-4">
<Auth
supabaseClient={supabaseClient}
providers={['github']}
redirectTo={getURL()}
magicLink={true}
appearance={{
theme: ThemeSupa,
variables: {
default: {
colors: {
brand: '#404040',
brandAccent: '#52525b'
}
}
}
}}
theme="dark"
/>
</div>
</div>
</div>
);
return (
<div className="m-6">
<LoadingDots />
</div>
);
};
export default SignIn;