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