Integrate and componentize QRCode screen

This commit is contained in:
enzoggqs 2022-12-05 23:20:18 -03:00
parent 5c0bc4922d
commit cfaa1b9342
3 changed files with 22 additions and 14 deletions

View File

@ -2,13 +2,20 @@
import { pix } from "../utils/QrCodePix"; import { pix } from "../utils/QrCodePix";
import { ref } from "vue"; import { ref } from "vue";
import { debounce } from "@/utils/debounce"; import { debounce } from "@/utils/debounce";
import CustomButton from "../components/CustomButton.vue"; import CustomButton from "./CustomButton.vue";
const props = defineProps({
pixTarget: String,
tokenValue: Number,
});
console.log(props.tokenValue);
const qrCode = ref<string>(""); const qrCode = ref<string>("");
const qrCodePayload = ref<string>(""); const qrCodePayload = ref<string>("");
const pixQrCode = pix({ const pixQrCode = pix({
pixKey: "key_test123456789", pixKey: props.pixTarget,
value: 100, value: props.tokenValue,
}); });
const pixIsValid = ref<number>(0); const pixIsValid = ref<number>(0);
const stateButton = ref(false); const stateButton = ref(false);
@ -36,7 +43,6 @@ const validatePix = (value: any) => {
} }
}; };
console.log(pixIsValid.value, stateButton.value)
</script> </script>
<template> <template>
@ -59,7 +65,7 @@ console.log(pixIsValid.value, stateButton.value)
<img :src="qrCode" class="w-48 h-48" /> <img :src="qrCode" class="w-48 h-48" />
<span class="text-center font-bold">Código pix</span> <span class="text-center font-bold">Código pix</span>
<span class="text-center text-xs"> <span class="text-center text-xs">
c02942far7047f6shri5ifh371908973 {{ pixTarget }}
</span> </span>
<img <img
alt="Copy PIX code" alt="Copy PIX code"

View File

@ -1,6 +1,5 @@
import { createRouter, createWebHistory } from "vue-router"; import { createRouter, createWebHistory } from "vue-router";
import HomeView from "../views/HomeView.vue"; import HomeView from "../views/HomeView.vue";
import QrCodeFormVue from "../views/QrCodeForm.vue";
import MockView from "../views/MockView.vue"; import MockView from "../views/MockView.vue";
const router = createRouter({ const router = createRouter({
@ -11,11 +10,6 @@ const router = createRouter({
name: "home", name: "home",
component: HomeView, component: HomeView,
}, },
{
path: "/pix",
name: "pix",
component: QrCodeFormVue,
},
{ {
path: "/mock", path: "/mock",
name: "mock", name: "mock",

View File

@ -9,7 +9,7 @@ import p2pix from "../utils/smart_contract_files/P2PIX.json";
import addresses from "../utils/smart_contract_files/localhost.json"; import addresses from "../utils/smart_contract_files/localhost.json";
import { useEtherStore } from "@/store/ether"; import { useEtherStore } from "@/store/ether";
import { ethers } from "ethers"; import { ethers } from "ethers";
import QrCodeForm from "./QrCodeForm.vue"; import QrCodeForm from "../components/QrCodeForm.vue";
import { storeToRefs } from "pinia"; import { storeToRefs } from "pinia";
@ -21,7 +21,9 @@ enum Step {
// States // States
const etherStore = useEtherStore(); const etherStore = useEtherStore();
const { loadingLock } = storeToRefs(etherStore); const { loadingLock } = storeToRefs(etherStore);
const flowStep = ref<Step>(Step.Search) const flowStep = ref<Step>(Step.Search);
const pixTarget = ref<string>("");
const tokens = ref<number>();
const confirmBuyClick = async ({ selectedDeposit, tokenValue }: any) => { const confirmBuyClick = async ({ selectedDeposit, tokenValue }: any) => {
// finish buy screen // finish buy screen
@ -33,6 +35,8 @@ const confirmBuyClick = async ({ selectedDeposit, tokenValue }: any) => {
.then((deposit) => (depositDetail = deposit)); .then((deposit) => (depositDetail = deposit));
console.log(tokenValue); console.log(tokenValue);
console.log(depositDetail); console.log(depositDetail);
tokens.value = tokenValue;
pixTarget.value = depositDetail?.pixTarget;
// Makes lock with deposit ID and the Amount // Makes lock with deposit ID and the Amount
if (depositDetail) { if (depositDetail) {
@ -70,7 +74,11 @@ const confirmBuyClick = async ({ selectedDeposit, tokenValue }: any) => {
<template> <template>
<SearchComponent v-if="(flowStep == Step.Search)" @token-buy="confirmBuyClick" /> <SearchComponent v-if="(flowStep == Step.Search)" @token-buy="confirmBuyClick" />
<div v-if="(flowStep == Step.Buy)"> <div v-if="(flowStep == Step.Buy)">
<QrCodeForm v-if="!loadingLock"/> <QrCodeForm
:pixTarget="pixTarget"
:tokenValue="tokens"
v-if="!loadingLock"
/>
<ValidationComponent v-if="loadingLock"/> <ValidationComponent v-if="loadingLock"/>
</div> </div>
</template> </template>