emit e2eid from buy step to home view

This commit is contained in:
RcleydsonR
2022-12-13 20:31:21 -03:00
parent 409f22a8cf
commit 4aec263463
4 changed files with 78 additions and 39 deletions

View File

@@ -5,6 +5,7 @@ import { debounce } from "@/utils/debounce";
import CustomButton from "./CustomButton.vue";
import api from "../services/index";
// props and store references
const props = defineProps({
pixTarget: String,
tokenValue: Number,
@@ -12,13 +13,17 @@ const props = defineProps({
const qrCode = ref<string>("");
const qrCodePayload = ref<string>("");
const isPixValid = ref<boolean>(false);
const isCodeInputEmpty = ref<boolean>(true);
const e2eId = ref<string>("");
// Emits
const emit = defineEmits(["pixValidated"]);
const pixQrCode = pix({
pixKey: props.pixTarget ?? "",
value: props.tokenValue,
});
const isPixValid = ref<boolean>(false);
const isCodeInputEmpty = ref<boolean>(true);
pixQrCode.base64QrCode().then((code: string) => {
qrCode.value = code;
});
@@ -27,12 +32,12 @@ qrCodePayload.value = pixQrCode.payload();
const handleInputEvent = (event: any) => {
const { value } = event.target;
validatePix(value);
e2eId.value = value;
validatePix();
};
const validatePix = async (e2eid: any) => {
if (e2eid == "") {
const validatePix = async () => {
if (e2eId.value == "") {
isPixValid.value = false;
isCodeInputEmpty.value = true;
return;
@@ -42,7 +47,7 @@ const validatePix = async (e2eid: any) => {
if (sellerPixKey && transactionValue) {
var body_req = {
e2e_id: e2eid,
e2e_id: e2eId.value,
pix_key: sellerPixKey,
pix_value: transactionValue,
};
@@ -64,6 +69,7 @@ const validatePix = async (e2eid: any) => {
<template>
<div class="page">
<h2>{{e2eId}}</h2>
<div class="text-container">
<span class="text font-extrabold text-2xl max-w-[30rem]">
Utilize o QR Code ou copie o código para realizar o Pix
@@ -141,6 +147,7 @@ const validatePix = async (e2eid: any) => {
<CustomButton
:is-disabled="isPixValid == false"
:text="'Enviar para a rede'"
@button-clicked="emit('pixValidated', e2eId)"
/>
</div>
</div>