From 51e5705104c8e0c364619b1393db360dab5f4ba1 Mon Sep 17 00:00:00 2001 From: 230417 <230417@epvc.pt> Date: Wed, 28 Jan 2026 09:02:13 +0000 Subject: [PATCH] register --- web/src/pages/AuthRegister.tsx | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/web/src/pages/AuthRegister.tsx b/web/src/pages/AuthRegister.tsx index e9bb813..e5031e1 100644 --- a/web/src/pages/AuthRegister.tsx +++ b/web/src/pages/AuthRegister.tsx @@ -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