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 (

ON DIGITAL - CALCULADORA DE RESULTADOS

setInvestimento(e.target.value)} className="mt-1 p-2 w-full border rounded-lg" />
setLeads(e.target.value)} className="mt-1 p-2 w-full border rounded-lg" />
setEstimates(e.target.value)} className="mt-1 p-2 w-full border rounded-lg" />
setFechamentos(e.target.value)} className="mt-1 p-2 w-full border rounded-lg" />
setRetorno(e.target.value)} className="mt-1 p-2 w-full border rounded-lg" />
{resultados && (

Custo por Lead: R$ {resultados.custoPorLead}

Custo por Estimate: R$ {resultados.custoPorEstimate}

% de Estimates: {resultados.percentualEstimates}

% de Fechamento: {resultados.percentualFechamento}

ROAS: {resultados.roas}

CPA: R$ {resultados.cpa}

)}

Desenvolvido por ON DIGITAL

);}