Add spinner component to be reusable and add loading on network liquidity
This commit is contained in:
parent
c0f388f46e
commit
dc0c28f685
@ -31,6 +31,7 @@ const getNetworksLiquidity = async (): Promise<void> => {
|
|||||||
mumbaiProvider
|
mumbaiProvider
|
||||||
);
|
);
|
||||||
|
|
||||||
|
etherStore.setLoadingNetworkLiquidity(true);
|
||||||
const depositListGoerli = await getValidDeposits(
|
const depositListGoerli = await getValidDeposits(
|
||||||
getTokenAddress(NetworkEnum.ethereum),
|
getTokenAddress(NetworkEnum.ethereum),
|
||||||
p2pContractGoerli
|
p2pContractGoerli
|
||||||
@ -42,8 +43,8 @@ const getNetworksLiquidity = async (): Promise<void> => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
etherStore.setDepositsValidListGoerli(depositListGoerli);
|
etherStore.setDepositsValidListGoerli(depositListGoerli);
|
||||||
|
|
||||||
etherStore.setDepositsValidListMumbai(depositListMumbai);
|
etherStore.setDepositsValidListMumbai(depositListMumbai);
|
||||||
|
etherStore.setLoadingNetworkLiquidity(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getValidDeposits = async (
|
const getValidDeposits = async (
|
||||||
|
@ -6,6 +6,7 @@ import type { WalletTransaction } from "@/model/WalletTransaction";
|
|||||||
import { useEtherStore } from "@/store/ether";
|
import { useEtherStore } from "@/store/ether";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
import { ref, watch } from "vue";
|
import { ref, watch } from "vue";
|
||||||
|
import SpinnerComponent from "../SpinnerComponent.vue";
|
||||||
|
|
||||||
const etherStore = useEtherStore();
|
const etherStore = useEtherStore();
|
||||||
|
|
||||||
@ -111,22 +112,7 @@ showInitialItems();
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="blur-container" v-if="loadingWalletTransactions">
|
<div class="blur-container" v-if="loadingWalletTransactions">
|
||||||
<svg
|
<SpinnerComponent width="8" height="8" color="white"></SpinnerComponent>
|
||||||
aria-hidden="true"
|
|
||||||
class="w-8 h-8 mr-2 text-gray-200 animate-spin dark:text-gray-600 fill-white"
|
|
||||||
viewBox="0 0 100 101"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
|
||||||
fill="currentColor"
|
|
||||||
/>
|
|
||||||
<path
|
|
||||||
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
|
||||||
fill="currentFill"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="blur-container" v-if="!loadingWalletTransactions">
|
<div class="blur-container" v-if="!loadingWalletTransactions">
|
||||||
<div
|
<div
|
||||||
|
@ -9,6 +9,7 @@ import { verifyNetworkLiquidity } from "@/utils/networkLiquidity";
|
|||||||
import { NetworkEnum } from "@/model/NetworkEnum";
|
import { NetworkEnum } from "@/model/NetworkEnum";
|
||||||
import type { ValidDeposit } from "@/model/ValidDeposit";
|
import type { ValidDeposit } from "@/model/ValidDeposit";
|
||||||
import { decimalCount } from "@/utils/decimalCount";
|
import { decimalCount } from "@/utils/decimalCount";
|
||||||
|
import SpinnerComponent from "./SpinnerComponent.vue";
|
||||||
|
|
||||||
// Store reference
|
// Store reference
|
||||||
const etherStore = useEtherStore();
|
const etherStore = useEtherStore();
|
||||||
@ -18,6 +19,7 @@ const {
|
|||||||
networkName,
|
networkName,
|
||||||
depositsValidListGoerli,
|
depositsValidListGoerli,
|
||||||
depositsValidListMumbai,
|
depositsValidListMumbai,
|
||||||
|
loadingNetworkLiquidity,
|
||||||
} = storeToRefs(etherStore);
|
} = storeToRefs(etherStore);
|
||||||
|
|
||||||
// Reactive state
|
// Reactive state
|
||||||
@ -160,8 +162,11 @@ watch(walletAddress, (): void => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="custom-divide py-2"></div>
|
<div class="custom-divide py-2 mb-2"></div>
|
||||||
<div class="flex justify-between pt-2" v-if="hasLiquidity">
|
<div
|
||||||
|
class="flex justify-between"
|
||||||
|
v-if="hasLiquidity && !loadingNetworkLiquidity"
|
||||||
|
>
|
||||||
<p class="text-gray-500 font-normal text-sm w-auto">
|
<p class="text-gray-500 font-normal text-sm w-auto">
|
||||||
~ R$ {{ tokenValue.toFixed(2) }}
|
~ R$ {{ tokenValue.toFixed(2) }}
|
||||||
</p>
|
</p>
|
||||||
@ -182,12 +187,31 @@ watch(walletAddress, (): void => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex pt-2 justify-center" v-if="!validDecimals">
|
<div
|
||||||
|
class="flex justify-center items-center"
|
||||||
|
v-if="loadingNetworkLiquidity"
|
||||||
|
>
|
||||||
|
<span class="text-gray-900 font-normal text-sm mr-2"
|
||||||
|
>Carregando liquidez das redes.</span
|
||||||
|
>
|
||||||
|
<SpinnerComponent
|
||||||
|
width="4"
|
||||||
|
height="4"
|
||||||
|
color="blue-600"
|
||||||
|
></SpinnerComponent>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="flex justify-center"
|
||||||
|
v-if="!validDecimals && !loadingNetworkLiquidity"
|
||||||
|
>
|
||||||
<span class="text-red-500 font-normal text-sm"
|
<span class="text-red-500 font-normal text-sm"
|
||||||
>Por favor utilize no máximo 2 casas decimais</span
|
>Por favor utilize no máximo 2 casas decimais</span
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex pt-2 justify-center" v-else-if="!hasLiquidity">
|
<div
|
||||||
|
class="flex justify-center"
|
||||||
|
v-else-if="!hasLiquidity && !loadingNetworkLiquidity"
|
||||||
|
>
|
||||||
<span class="text-red-500 font-normal text-sm"
|
<span class="text-red-500 font-normal text-sm"
|
||||||
>Atualmente não há liquidez nas redes para sua demanda</span
|
>Atualmente não há liquidez nas redes para sua demanda</span
|
||||||
>
|
>
|
||||||
|
41
src/components/SpinnerComponent.vue
Normal file
41
src/components/SpinnerComponent.vue
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
// prop
|
||||||
|
const props = defineProps({
|
||||||
|
width: String,
|
||||||
|
height: String,
|
||||||
|
color: String,
|
||||||
|
show: Boolean,
|
||||||
|
});
|
||||||
|
|
||||||
|
const getCustomClass = () => {
|
||||||
|
return [
|
||||||
|
`w-${props.width}`,
|
||||||
|
`h-${props.height}`,
|
||||||
|
`fill-${props.color}`,
|
||||||
|
"text-gray-200",
|
||||||
|
"animate-spin",
|
||||||
|
"dark:text-gray-600",
|
||||||
|
];
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div v-if="props.show ? props.show : true">
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
:class="getCustomClass()"
|
||||||
|
viewBox="0 0 100 101"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||||
|
fill="currentFill"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</template>
|
@ -14,6 +14,7 @@ export const useEtherStore = defineStore("ether", {
|
|||||||
// Depósitos válidos para compra MUMBAI
|
// Depósitos válidos para compra MUMBAI
|
||||||
depositsValidListMumbai: [] as ValidDeposit[],
|
depositsValidListMumbai: [] as ValidDeposit[],
|
||||||
loadingWalletTransactions: false,
|
loadingWalletTransactions: false,
|
||||||
|
loadingNetworkLiquidity: false,
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
setWalletAddress(walletAddress: string) {
|
setWalletAddress(walletAddress: string) {
|
||||||
@ -40,6 +41,9 @@ export const useEtherStore = defineStore("ether", {
|
|||||||
setLoadingWalletTransactions(isLoadingWalletTransactions: boolean) {
|
setLoadingWalletTransactions(isLoadingWalletTransactions: boolean) {
|
||||||
this.loadingWalletTransactions = isLoadingWalletTransactions;
|
this.loadingWalletTransactions = isLoadingWalletTransactions;
|
||||||
},
|
},
|
||||||
|
setLoadingNetworkLiquidity(isLoadingNetworkLiquidity: boolean) {
|
||||||
|
this.loadingNetworkLiquidity = isLoadingNetworkLiquidity;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
// Alterar para integrar com mumbai
|
// Alterar para integrar com mumbai
|
||||||
getters: {
|
getters: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user