Fix alerts and modals
This commit is contained in:
@@ -22,6 +22,7 @@ import {
|
||||
import { getNetworksLiquidity } from "@/blockchain/events";
|
||||
import type { ValidDeposit } from "@/model/ValidDeposit";
|
||||
import type { WalletTransaction } from "@/model/WalletTransaction";
|
||||
import CustomAlert from "@/components/CustomAlert/CustomAlert.vue";
|
||||
|
||||
enum Step {
|
||||
Search,
|
||||
@@ -42,6 +43,7 @@ const loadingRelease = ref<boolean>(false);
|
||||
const showModal = ref<boolean>(false);
|
||||
const lastWalletTransactions = ref<WalletTransaction[]>([]);
|
||||
const depositList = ref<ValidDeposit[]>([]);
|
||||
const showBuyAlert = ref<boolean>(false);
|
||||
|
||||
const confirmBuyClick = async (
|
||||
selectedDeposit: ValidDeposit,
|
||||
@@ -71,6 +73,7 @@ const confirmBuyClick = async (
|
||||
|
||||
const releaseTransaction = async (e2eId: string) => {
|
||||
flowStep.value = Step.List;
|
||||
showBuyAlert.value = true;
|
||||
loadingRelease.value = true;
|
||||
|
||||
if (lockID.value && tokenAmount.value && pixTarget.value) {
|
||||
@@ -159,12 +162,19 @@ onMounted(async () => {
|
||||
v-if="flowStep == Step.Search"
|
||||
@token-buy="confirmBuyClick"
|
||||
/>
|
||||
<CustomModal
|
||||
<CustomAlert
|
||||
v-if="flowStep == Step.Search && showModal"
|
||||
:isRedirectModal="true"
|
||||
@close-modal="showModal = false"
|
||||
:type="'redirect'"
|
||||
@close-alert="showModal = false"
|
||||
@go-to-lock="flowStep = Step.Buy"
|
||||
/>
|
||||
<CustomAlert
|
||||
v-if="
|
||||
flowStep == Step.List && showBuyAlert && !loadingLock && !loadingRelease
|
||||
"
|
||||
:type="'buy'"
|
||||
@close-alert="showBuyAlert = false"
|
||||
/>
|
||||
<div v-if="flowStep == Step.Buy">
|
||||
<QrCodeComponent
|
||||
:pixTarget="String(pixTarget)"
|
||||
|
||||
@@ -7,12 +7,14 @@ import { ref, watch, onMounted } from "vue";
|
||||
import {
|
||||
listValidDepositTransactionsByWalletAddress,
|
||||
listAllTransactionByWalletAddress,
|
||||
checkUnreleasedLock,
|
||||
} from "@/blockchain/wallet";
|
||||
import { withdrawDeposit } from "@/blockchain/buyerMethods";
|
||||
import type { ValidDeposit } from "@/model/ValidDeposit";
|
||||
import type { WalletTransaction } from "@/model/WalletTransaction";
|
||||
|
||||
import router from "@/router/index";
|
||||
import CustomAlert from "@/components/CustomAlert/CustomAlert.vue";
|
||||
|
||||
const etherStore = useEtherStore();
|
||||
|
||||
@@ -21,6 +23,7 @@ const loadingWithdraw = ref<boolean>(false);
|
||||
|
||||
const depositList = ref<ValidDeposit[]>([]);
|
||||
const transactionsList = ref<WalletTransaction[]>([]);
|
||||
const showAlert = ref<boolean>(false);
|
||||
|
||||
const callWithdraw = async (amount: string) => {
|
||||
if (amount) {
|
||||
@@ -63,11 +66,25 @@ const getWalletTransactions = async () => {
|
||||
etherStore.setLoadingWalletTransactions(false);
|
||||
};
|
||||
|
||||
const checkForUnreleasedLocks = async (): Promise<void> => {
|
||||
const walletLocks = await checkUnreleasedLock(walletAddress.value);
|
||||
if (walletLocks) {
|
||||
showAlert.value = true;
|
||||
} else {
|
||||
showAlert.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const goToLock = () => {
|
||||
router.push({ name: "home" });
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
if (!walletAddress.value) {
|
||||
router.push({ name: "home" });
|
||||
}
|
||||
await getWalletTransactions();
|
||||
await checkForUnreleasedLocks();
|
||||
});
|
||||
|
||||
watch(walletAddress, async () => {
|
||||
@@ -80,6 +97,12 @@ watch(networkName, async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<CustomAlert
|
||||
v-if="showAlert"
|
||||
:type="'redirect'"
|
||||
@close-alert="showAlert = false"
|
||||
@go-to-lock="goToLock()"
|
||||
/>
|
||||
<div class="page">
|
||||
<div class="header" v-if="!loadingWithdraw && !walletAddress">
|
||||
Por Favor Conecte Sua Carteira
|
||||
|
||||
@@ -6,6 +6,7 @@ import { approveTokens, addDeposit } from "@/blockchain/sellerMethods";
|
||||
|
||||
import { ref } from "vue";
|
||||
import { useEtherStore } from "@/store/ether";
|
||||
import CustomAlert from "@/components/CustomAlert/CustomAlert.vue";
|
||||
|
||||
enum Step {
|
||||
Search,
|
||||
@@ -61,16 +62,17 @@ const sendNetwork = async () => {
|
||||
|
||||
<template>
|
||||
<div v-if="flowStep == Step.Sell">
|
||||
<WantSellComponent
|
||||
v-if="!loading"
|
||||
@approve-tokens="approveOffer"
|
||||
:showAlert="showAlert"
|
||||
/>
|
||||
<WantSellComponent v-if="!loading" @approve-tokens="approveOffer" />
|
||||
<LoadingComponent
|
||||
v-if="loading"
|
||||
:message="'A transação está sendo enviada para a rede.'"
|
||||
/>
|
||||
</div>
|
||||
<CustomAlert
|
||||
v-if="flowStep == Step.Sell && showAlert"
|
||||
:type="'sell'"
|
||||
@close-alert="showAlert = false"
|
||||
/>
|
||||
<div v-if="flowStep == Step.Network">
|
||||
<SendNetwork
|
||||
:pixKey="pixKeyBuyer"
|
||||
|
||||
Reference in New Issue
Block a user