idek
This commit is contained in:
parent
c5eed77822
commit
2054bc86ee
@ -1,6 +1,8 @@
|
||||
const Layout = async ({ children }: { children: React.ReactNode }) => {
|
||||
return (
|
||||
<div className='max-w-7xl flex flex-col gap-12 items-start'>{children}</div>
|
||||
<div className='max-w-7xl flex flex-col gap-12 items-center'>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export default Layout;
|
||||
|
@ -2,7 +2,6 @@ import Link from 'next/link';
|
||||
import { signUp } from '@/lib/actions';
|
||||
import { FormMessage, type Message, SubmitButton } from '@/components/default';
|
||||
import { Input, Label } from '@/components/ui';
|
||||
import { SmtpMessage } from '@/app/(auth-pages)/smtp-message';
|
||||
|
||||
const SignUp = async (props: { searchParams: Promise<Message> }) => {
|
||||
const searchParams = await props.searchParams;
|
||||
@ -17,37 +16,33 @@ const SignUp = async (props: { searchParams: Promise<Message> }) => {
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<>
|
||||
<form className='flex flex-col min-w-64 max-w-64 mx-auto'>
|
||||
<h1 className='text-2xl font-medium'>Sign up</h1>
|
||||
<p className='text-sm text text-foreground'>
|
||||
Already have an account?{' '}
|
||||
<Link
|
||||
className='text-primary font-medium underline'
|
||||
href='/sign-in'
|
||||
>
|
||||
Sign in
|
||||
</Link>
|
||||
</p>
|
||||
<div className='flex flex-col gap-2 [&>input]:mb-3 mt-8'>
|
||||
<Label htmlFor='email'>Email</Label>
|
||||
<Input name='email' placeholder='you@example.com' required />
|
||||
<Label htmlFor='password'>Password</Label>
|
||||
<Input
|
||||
type='password'
|
||||
name='password'
|
||||
placeholder='Your password'
|
||||
minLength={6}
|
||||
required
|
||||
/>
|
||||
<SubmitButton formAction={signUp} pendingText='Signing up...'>
|
||||
Sign up
|
||||
</SubmitButton>
|
||||
<FormMessage message={searchParams} />
|
||||
</div>
|
||||
</form>
|
||||
<SmtpMessage />
|
||||
</>
|
||||
<form className='flex flex-col min-w-64 max-w-64 mx-auto'>
|
||||
<h1 className='text-2xl font-medium'>Sign up</h1>
|
||||
<p className='text-sm text text-foreground'>
|
||||
Already have an account?{' '}
|
||||
<Link className='text-primary font-medium underline' href='/sign-in'>
|
||||
Sign in
|
||||
</Link>
|
||||
</p>
|
||||
<div className='flex flex-col gap-2 [&>input]:mb-3 mt-8'>
|
||||
<Label htmlFor='name'>Name</Label>
|
||||
<Input name='name' placeholder='Full Name' required />
|
||||
<Label htmlFor='email'>Email</Label>
|
||||
<Input name='email' placeholder='you@example.com' required />
|
||||
<Label htmlFor='password'>Password</Label>
|
||||
<Input
|
||||
type='password'
|
||||
name='password'
|
||||
placeholder='Your password'
|
||||
minLength={6}
|
||||
required
|
||||
/>
|
||||
<SubmitButton formAction={signUp} pendingText='Signing up...'>
|
||||
Sign up
|
||||
</SubmitButton>
|
||||
<FormMessage message={searchParams} />
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
@ -7,6 +7,7 @@ import { headers } from 'next/headers';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export const signUp = async (formData: FormData) => {
|
||||
const name = formData.get('name') as string;
|
||||
const email = formData.get('email') as string;
|
||||
const password = formData.get('password') as string;
|
||||
const supabase = await createServerClient();
|
||||
@ -20,27 +21,37 @@ export const signUp = async (formData: FormData) => {
|
||||
);
|
||||
}
|
||||
|
||||
const { error } = await supabase.auth.signUp({
|
||||
const { data, error } = await supabase.auth.signUp({
|
||||
email,
|
||||
password,
|
||||
options: {
|
||||
emailRedirectTo: `${origin}/auth/callback`,
|
||||
},
|
||||
//options: {
|
||||
//emailRedirectTo: `${origin}/auth/callback`,
|
||||
//},
|
||||
});
|
||||
|
||||
if (error) {
|
||||
console.error(error.code + ': ' + error.message);
|
||||
return encodedRedirect(
|
||||
'error',
|
||||
'/sign-up',
|
||||
'Thanks for signing up! Please check your email for a verification link.',
|
||||
);
|
||||
return redirect('/protected');
|
||||
//return encodedRedirect('error', '/sign-up',
|
||||
//'Thanks for signing up! Please check your email for a verification link.');
|
||||
} else {
|
||||
return encodedRedirect(
|
||||
'success',
|
||||
'/sign-up',
|
||||
'Thanks for signing up! Please check your email for a verification link.',
|
||||
);
|
||||
try {
|
||||
if (!data.user) throw new Error('Could not sign up');
|
||||
const { error } = await supabase
|
||||
.from('profiles')
|
||||
.update({
|
||||
full_name: name,
|
||||
provider: 'email',
|
||||
})
|
||||
.eq('id', data.user.id);
|
||||
if (error) throw new Error('Could not update profile');
|
||||
} catch (error) {
|
||||
console.error('Error updating profile: ', error);
|
||||
} finally {
|
||||
return redirect('/protected');
|
||||
//return encodedRedirect('success', '/protected',
|
||||
//'Thanks for signing up! Please check your email for a verification link.);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user