Skip to content

Commit

Permalink
fix: isNFTMinting ref
Browse files Browse the repository at this point in the history
  • Loading branch information
Another-DevX committed Jan 16, 2024
1 parent 49d4964 commit aabc990
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import useWeb3 from '@/services/web3/useWeb3';
const { startConnectWithInjectedProvider } = useWeb3();
const { isMobile, bp } = useBreakpoints();
const { NFTData, isLoading, MintNFT } = useRFNFT();
const { NFTData, isLoading, MintNFT, isMintingNFT } = useRFNFT();
const { isWalletReady } = useWeb3();
const nftImageSrc = computed(() => NFTData.value?.imageData || NFTImage);
Expand Down Expand Up @@ -67,9 +67,9 @@ const levels = ref([
>Connect wallet</BalBtn
>
<BalBtn
v-else-if="!NFTData"
:disabled="MintingNFT"
color="gradient-blue-light"
v-else
:color="isMintingNFT ? 'gray' : 'gradient-blue-light'"
:disabled="isMintingNFT"
class="self-end w-fit"
size="sm"
@click="() => MintNFT()"
Expand Down Expand Up @@ -121,9 +121,9 @@ const levels = ref([
>Connect wallet</BalBtn
>
<BalBtn
v-else-if="!NFTData"
color="gradient-blue-light"
:disabled="MintingNFT"
v-else
:color="isMintingNFT ? 'gray' : 'gradient-blue-light'"
:disabled="isMintingNFT"
class="self-end w-fit"
size="sm"
@click="() => MintNFT()"
Expand Down Expand Up @@ -184,8 +184,8 @@ const levels = ref([
>
<BalBtn
v-else
color="gradient-blue-light"
:disabled="MintingNFT"
:color="isMintingNFT ? 'gray' : 'gradient-blue-light'"
:disabled="isMintingNFT"
class="self-end w-fit"
size="sm"
@click="() => MintNFT()"
Expand Down
6 changes: 6 additions & 0 deletions src/composables/campaigns/useRFNFT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export function useRFNFT() {
const { addNotification } = useNotifications();
const { addTransaction } = useTransactions();
const { account } = useWeb3();
const isMintingNFT = ref(false);

const fetchNFTImage = async (ipfsHash: string) => {
try {
const imageUrl = `https://${
Expand Down Expand Up @@ -55,6 +57,7 @@ export function useRFNFT() {
});

const MintNFT = async () => {
isMintingNFT.value = true;
try {
const txResponse = await campaignsService.mintNFT();
addTransaction({
Expand All @@ -70,12 +73,15 @@ export function useRFNFT() {
message: 'The NFT could not be minted',
type: 'error',
});
} finally {
isMintingNFT.value = false;
}
};

return {
NFTData: data,
isLoading,
MintNFT,
isMintingNFT,
};
}

0 comments on commit aabc990

Please sign in to comment.