import { useState } from "react";import { Card, CardContent } from "@/components/ui/card";import { Input } from "@/components/ui/input";import { Button } from "@/components/ui/button";export default function CalculadoraResultados() { const [investimento, setInvestimento] = useState(""); const [leads, setLeads] = useState(""); const [estimates, setEstimates] = useState(""); const [fechamentos, setFechamentos] = useState(""); const [retorno, setRetorno] = useState(""); const [resultados, setResultados] = useState(null); const calcularResultados = () => { const inv = parseFloat(investimento); const leadCount = parseFloat(leads); const est = parseFloat(estimates); const fech = parseFloat(fechamentos); const ret = parseFloat(retorno); if (!isNaN(inv) && !isNaN(leadCount) && !isNaN(est) && !isNaN(fech) && !isNaN(ret) && inv > 0) { const custoPorLead = inv / leadCount; const custoPorEstimate = est > 0 ? inv / est : 0; const percentualEstimates = leadCount > 0 ? (est / leadCount) * 100 : 0; const percentualFechamento = est > 0 ? (fech / est) * 100 : 0; const roas = ret / inv; const cpa = fech > 0 ? inv / fech : 0; setResultados({ custoPorLead: custoPorLead.toFixed(2), custoPorEstimate: custoPorEstimate.toFixed(2), percentualEstimates: percentualEstimates.toFixed(2) + "%", percentualFechamento: percentualFechamento.toFixed(2) + "%", roas: roas.toFixed(2), cpa: cpa.toFixed(2), }); } else { setResultados("Valores inválidos"); } }; return (
);}