diff --git a/actions/checkout.ts b/actions/checkout.ts index 7d4d04c..6c34c84 100644 --- a/actions/checkout.ts +++ b/actions/checkout.ts @@ -1,4 +1,6 @@ export interface Props { + name: string; + cpf_cnpj: string; email: string; sku: string; credit_card: { diff --git a/components/ui/CheckoutForm.tsx b/components/ui/CheckoutForm.tsx index d314cff..8a0dcaa 100644 --- a/components/ui/CheckoutForm.tsx +++ b/components/ui/CheckoutForm.tsx @@ -8,6 +8,7 @@ export interface Props { function CheckoutForm() { const [name, setName] = useState(""); + const [cpf, setCPF] = useState(""); // const [creditCartHolder, setCreditCardHolder] = useState(""); const [creditCardNumber, setCreditCardNumber] = useState(""); const [creditCardExpMonth, setCreditCardExpMonth] = useState(""); @@ -43,6 +44,8 @@ function CheckoutForm() { const [isLoadingPostalCode, setIsLoadingPostalCode] = useState(false); setHolderEmail(localStorage.getItem("emailConfirm") || ""); + setName(localStorage.getItem("nameUserAsaas") || ""); + setCPF(localStorage.getItem("cpfUserAsaas") || ""); const planSku = localStorage.getItem("planSKU") || ""; const planName = localStorage.getItem("planName") || ""; @@ -63,11 +66,18 @@ function CheckoutForm() { "Não foi encontrado email. Reinicie o cadastro", ); window.location.href = "/cadastrar"; + } else if (cpf == "" || name == "") { + alert( + "Não foi encontrado o usuário deste processo de pagamento. Por favor, reinicie o cadastro", + ); + window.location.href = "/cadastrar"; } else { try { const r = await invoke["deco-sites/ecannadeco"].actions .checkout( { + name, + cpf_cnpj: cpf, email: holderEmail, sku: planSku, credit_card: { diff --git a/components/ui/SignUpForm.tsx b/components/ui/SignUpForm.tsx index a953321..fec364e 100644 --- a/components/ui/SignUpForm.tsx +++ b/components/ui/SignUpForm.tsx @@ -44,6 +44,8 @@ function SignUpForm({ formTitle }: Props) { setLoading(false); } else { localStorage.setItem("emailConfirm", email); + localStorage.setItem("cpfUserAsaas", cpf); + localStorage.setItem("nameUserAsaas", name); setLoading(false); window.location.href = "/confirmar-cadastro"; }