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