This commit is contained in:
2026-01-28 09:02:13 +00:00
parent 42b1eb6459
commit 51e5705104

View File

@@ -33,6 +33,13 @@ export default function AuthRegister() {
const { data, error: signUpError } = await supabase.auth.signUp({
email,
password,
options: {
data: {
name,
role,
shop_name: role === 'barbearia' ? shopName : null,
},
},
})
if (signUpError) throw signUpError
@@ -44,12 +51,17 @@ export default function AuthRegister() {
}
// 2) Criar perfil na tabela public.profiles
const { error: profileError } = await supabase.from('profiles').insert({
id: userId,
name,
role,
shop_name: role === 'barbearia' ? shopName : null,
})
const { error: profileError } = await supabase
.from('profiles')
.upsert(
{
id: userId,
name,
role,
shop_name: role === 'barbearia' ? shopName : null,
},
{ onConflict: 'id' }
)
if (profileError) throw profileError
// 3) Redirecionar