Update all to useUSer composabe. Still some bugs to resolve.

This commit is contained in:
Filipe Soccol
2025-04-01 12:04:24 -03:00
parent e93cac6086
commit 9fa2b34a5d
26 changed files with 495 additions and 454 deletions

View File

@@ -8,7 +8,7 @@ import {
import CustomButton from "@/components/CustomButton/CustomButton.vue";
import type { ValidDeposit } from "@/model/ValidDeposit";
import type { WalletTransaction } from "@/model/WalletTransaction";
import { useViemStore } from "@/store/viem";
import { useUser } from "@/composables/useUser";
import { NetworkEnum } from "@/model/NetworkEnum";
import { onMounted, ref, watch } from "vue";
import ListingComponent from "../ListingComponent/ListingComponent.vue";
@@ -19,8 +19,8 @@ const props = defineProps<{
isCurrentStep: boolean;
}>();
const viemStore = useViemStore();
const { walletAddress } = storeToRefs(viemStore);
const user = useUser();
const { walletAddress } = useUser();
const lastWalletTransactions = ref<WalletTransaction[]>([]);
const depositList = ref<ValidDeposit[]>([]);
@@ -29,7 +29,7 @@ const activeLockAmount = ref<number>(0);
// methods
const getWalletTransactions = async () => {
viemStore.setLoadingWalletTransactions(true);
user.setLoadingWalletTransactions(true);
if (walletAddress.value) {
const walletDeposits = await listValidDepositTransactionsByWalletAddress(
walletAddress.value
@@ -48,20 +48,20 @@ const getWalletTransactions = async () => {
lastWalletTransactions.value = allUserTransactions;
}
}
viemStore.setLoadingWalletTransactions(false);
user.setLoadingWalletTransactions(false);
};
const callWithdraw = async (amount: string) => {
if (amount) {
viemStore.setLoadingWalletTransactions(true);
const withdraw = await withdrawDeposit(amount, viemStore.selectedToken);
user.setLoadingWalletTransactions(true);
const withdraw = await withdrawDeposit(amount, user.selectedToken.value);
if (withdraw) {
console.log("Saque realizado!");
await getWalletTransactions();
} else {
console.log("Não foi possível realizar o saque!");
}
viemStore.setLoadingWalletTransactions(false);
user.setLoadingWalletTransactions(false);
}
};
@@ -93,14 +93,14 @@ onMounted(async () => {
<div>
<p>Tokens recebidos</p>
<p class="text-2xl text-gray-900">
{{ props.tokenAmount }} {{ viemStore.selectedToken }}
{{ props.tokenAmount }} {{ user.selectedToken }}
</p>
</div>
<div class="my-5">
<p class="text-sm">
<b>Não encontrou os tokens? </b><br />Clique no botão abaixo para
<br />
cadastrar o {{ viemStore.selectedToken }} em sua carteira.
cadastrar o {{ user.selectedToken }} em sua carteira.
</p>
</div>
<CustomButton :text="'Cadastrar token'" @buttonClicked="() => {}" />