Skip to content

Commit

Permalink
send name and cpf to checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
baufaker committed Apr 9, 2024
1 parent 121ad6b commit 403d346
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions actions/checkout.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export interface Props {
name: string;
cpf_cnpj: string;
email: string;
sku: string;
credit_card: {
Expand Down
10 changes: 10 additions & 0 deletions components/ui/CheckoutForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface Props {

function CheckoutForm() {
const [name, setName] = useState<string>("");
const [cpf, setCPF] = useState<string>("");
// const [creditCartHolder, setCreditCardHolder] = useState<string>("");
const [creditCardNumber, setCreditCardNumber] = useState<string>("");
const [creditCardExpMonth, setCreditCardExpMonth] = useState<string>("");
Expand Down Expand Up @@ -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") || "";
Expand All @@ -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: {
Expand Down
2 changes: 2 additions & 0 deletions components/ui/SignUpForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down

0 comments on commit 403d346

Please sign in to comment.