diff --git a/src/components/auth/RegisterForm.tsx b/src/components/auth/RegisterForm.tsx index dd1a7da..a3191bf 100644 --- a/src/components/auth/RegisterForm.tsx +++ b/src/components/auth/RegisterForm.tsx @@ -6,6 +6,8 @@ import { Input } from "@/components/ui/input"; import { useToast } from "@/components/ui/use-toast"; import { supabase } from "@/integrations/supabase/client"; import { enviarDadosParaWebhook } from '@/utils/webhookService'; +import { Label } from '@/components/ui/label'; +import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form"; interface RegisterFormProps { isLoading: boolean; @@ -114,6 +116,7 @@ const RegisterForm = ({ isLoading, setIsLoading }: RegisterFormProps) => { return (
+ { />
+ { />
+ { />
+ { />
+ { />
+ { } ); - // Update the registrar_usuario function to include the whatsapp parameter - const { data, error } = await supabaseClient.rpc('update_register_function'); + // Execute the SQL to update the function + const { data, error } = await supabaseClient.rpc('update_register_function', { + sql: ` + CREATE OR REPLACE FUNCTION public.registrar_usuario( + nome text, + empresa text, + email text, + senha text, + whatsapp text + ) RETURNS uuid + LANGUAGE plpgsql + SECURITY DEFINER + AS $function$ + DECLARE + novo_usuario_id UUID; + BEGIN + -- Inserir novo usuário com senha hash + INSERT INTO public.usuarios (nome, empresa, email, senha, whatsapp) + VALUES (nome, empresa, email, crypt(senha, gen_salt('bf')), whatsapp) + RETURNING id INTO novo_usuario_id; + + -- Retorna o ID do usuário criado sem criar tabela individual + RETURN novo_usuario_id; + END; + $function$ + ` + }); if (error) throw error;