diff --git a/src/components/mika/EnterpriseLeadForm.tsx b/src/components/mika/EnterpriseLeadForm.tsx new file mode 100644 index 0000000..dd86d4f --- /dev/null +++ b/src/components/mika/EnterpriseLeadForm.tsx @@ -0,0 +1,119 @@ +"use client"; + +import { useState } from "react"; +import { useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { z } from "zod"; +import { IMaskInput } from "react-imask"; +import { toast } from "sonner"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { Textarea } from "@/components/ui/textarea"; +import { Label } from "@/components/ui/label"; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; +import { Loader2 } from "lucide-react"; + +const schema = z.object({ + company_name: z.string().min(2, "Informe o nome da empresa").max(120), + contact_name: z.string().min(2, "Informe seu nome").max(120), + email: z.string().email("Formato de e-mail inválido."), + phone: z.string().min(14, "Telefone inválido").max(20), + team_size: z.enum(["1-10", "11-50", "51-200", "200+"], { message: "Selecione o tamanho da equipe" }), + message: z.string().max(1000).optional(), +}); + +type FormValues = z.infer; + +export function EnterpriseLeadForm() { + const [submitting, setSubmitting] = useState(false); + const { + register, + handleSubmit, + setValue, + watch, + reset, + formState: { errors }, + } = useForm({ resolver: zodResolver(schema) }); + + const onSubmit = async (data: FormValues) => { + setSubmitting(true); + try { + // Etapa 2: gravar em enterprise_leads via supabase.from(...).insert(...) + // Por ora: feedback otimista para o usuário. + await new Promise((r) => setTimeout(r, 700)); + toast.success("Recebemos seu contato! Falamos com você em até 1 dia útil."); + reset(); + } catch { + toast.error("Algo deu errado do nosso lado. Já estamos investigando."); + } finally { + setSubmitting(false); + } + }; + + const phone = watch("phone") || ""; + + return ( +
+
+
+ + + {errors.company_name &&

{errors.company_name.message}

} +
+
+ + + {errors.contact_name &&

{errors.contact_name.message}

} +
+
+ +
+
+ + + {errors.email &&

{errors.email.message}

} +
+
+ + setValue("phone", value as string, { shouldValidate: true })} + placeholder="(11) 99999-9999" + className="flex h-10 w-full rounded-lg border border-input bg-transparent px-3 py-2 text-sm focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20" + /> + {errors.phone &&

{errors.phone.message}

} +
+
+ +
+ + + {errors.team_size &&

{errors.team_size.message}

} +
+ +
+ +