From 4aec263463d93893ebc0fd7e772df6a69e631a0c Mon Sep 17 00:00:00 2001 From: RcleydsonR Date: Tue, 13 Dec 2022 20:31:21 -0300 Subject: [PATCH] emit e2eid from buy step to home view --- src/components/ListComponent.vue | 61 +++++++++++++++++++----------- src/components/QrCodeComponent.vue | 23 +++++++---- src/utils/blockchain.ts | 2 + src/views/HomeView.vue | 31 ++++++++++----- 4 files changed, 78 insertions(+), 39 deletions(-) diff --git a/src/components/ListComponent.vue b/src/components/ListComponent.vue index aaef92e..109bdd4 100644 --- a/src/components/ListComponent.vue +++ b/src/components/ListComponent.vue @@ -1,23 +1,17 @@ @@ -97,7 +114,7 @@ const props = defineProps({ } p { - @apply text-gray-900 + @apply text-gray-900; } .text-container { @@ -115,8 +132,8 @@ p { @apply flex flex-col justify-center items-center px-8 py-6 gap-2 rounded-lg shadow-md shadow-gray-600 backdrop-blur-md mt-8 w-1/3; } -.last-deposit-info{ - @apply font-medium text-base +.last-deposit-info { + @apply font-medium text-base; } input[type="number"] { diff --git a/src/components/QrCodeComponent.vue b/src/components/QrCodeComponent.vue index de3f84a..c9e3753 100644 --- a/src/components/QrCodeComponent.vue +++ b/src/components/QrCodeComponent.vue @@ -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(""); const qrCodePayload = ref(""); +const isPixValid = ref(false); +const isCodeInputEmpty = ref(true); +const e2eId = ref(""); + +// Emits +const emit = defineEmits(["pixValidated"]); + const pixQrCode = pix({ pixKey: props.pixTarget ?? "", value: props.tokenValue, }); -const isPixValid = ref(false); -const isCodeInputEmpty = ref(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) => {