From 87de79201c146e0982908c24189243e4bbeb111d Mon Sep 17 00:00:00 2001 From: enzoggqs Date: Thu, 8 Dec 2022 20:35:27 -0300 Subject: [PATCH] Integrate with the rest of the flow --- src/components/QrCodeForm.vue | 44 ++++++++++++++++------------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/src/components/QrCodeForm.vue b/src/components/QrCodeForm.vue index 7549af5..efca314 100644 --- a/src/components/QrCodeForm.vue +++ b/src/components/QrCodeForm.vue @@ -4,7 +4,6 @@ import { ref } from "vue"; import { debounce } from "@/utils/debounce"; import CustomButton from "./CustomButton.vue"; import api from "../services/index"; -import { AxiosError } from 'axios'; const props = defineProps({ pixTarget: String, @@ -12,6 +11,7 @@ const props = defineProps({ }); console.log(props.tokenValue); +console.log(props.pixTarget); const qrCode = ref(""); const qrCodePayload = ref(""); @@ -20,7 +20,6 @@ const pixQrCode = pix({ value: props.tokenValue, }); const pixIsValid = ref(0); -const stateButton = ref(false); pixQrCode.base64QrCode().then((code: string) => { qrCode.value = code; @@ -35,7 +34,7 @@ const handleInputEvent = (event: any) => { }; const validatePix = async (value: any) => { - console.log(value) + console.log(value); if(value == ''){ pixIsValid.value = 0; return; @@ -43,37 +42,34 @@ const validatePix = async (value: any) => { var sellerPixKey = props.pixTarget; var transactionValue = props.tokenValue; - // var body_req = { - // e2e_id: value, - // pix_key: sellerPixKey, - // pix_value: transactionValue, - // }; - var body_req = { - e2e_id: value, - pix_key: "12345678", - pix_value: 100, - }; - var resp = await api.post("http://localhost:8000/validate_pix", body_req) - .catch((reason: Error) => { - console.log('entrou no erro', reason); - pixIsValid.value = 2; - return; - }); - console.log("🚀 ~ file: QrCodeForm.vue:47 ~ validatePix ~ resp", resp); - console.log(resp.status); + if(sellerPixKey && transactionValue){ + var body_req = { + e2e_id: value, + pix_key: sellerPixKey, + pix_value: transactionValue, + }; + var resp = await api.post("http://localhost:8000/validate_pix", body_req) + .catch((reason: Error) => { + console.log('entrou no erro', reason); + pixIsValid.value = 2; + return; + }); + console.log("🚀 ~ file: QrCodeForm.vue:47 ~ validatePix ~ resp", resp); + console.log(resp.status); - pixIsValid.value = 1; + pixIsValid.value = 1; + } else { + pixIsValid.value = 0; + } };