Skip to content

Commit

Permalink
Fix time left
Browse files Browse the repository at this point in the history
  • Loading branch information
samuveth committed Jan 24, 2024
1 parent 288c040 commit 6a7f992
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .eslintrc-auto-import.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"useBalances": true,
"useAccount": true,
"useNetwork": true,
"usePayment": true
"usePayment": true,
"useChangeNetwork": true
}
}
28 changes: 22 additions & 6 deletions src/components/SpaceProposalBoostClaim.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ async function loadVouchers(boosts: BoostSubgraph[]) {
console.error('Get vouchers error:', e);
}
}
const timeLeftToClaim = computed(() => {
if (!unclaimedBoosts.value.length) return 0;
return Number(unclaimedBoosts.value[0].end) - Math.floor(Date.now() / 1000);
});
</script>

<template>
Expand Down Expand Up @@ -200,7 +205,12 @@ async function loadVouchers(boosts: BoostSubgraph[]) {
<TuneButton
variant="white"
class="text-white"
@click="!loadingRewards && (claimModalOpen = true)"
:class="{
'cursor-not-allowed': loadingRewards || timeLeftToClaim <= 0
}"
@click="
!loadingRewards && timeLeftToClaim > 0 && (claimModalOpen = true)
"
>
<TuneLoadingSpinner v-if="loadingRewards" class="text-white" />
<div v-else class="flex items-center">
Expand All @@ -211,12 +221,18 @@ async function loadVouchers(boosts: BoostSubgraph[]) {
</TuneButton>
</div>
<div
v-if="boosts.length"
class="flex text-white justify-center items-center mt-2"
v-if="eligibleBoosts.length"
class="flex text-white justify-center mt-2"
>
<i-ho-clock class="mr-1 text-sm" />
{{ formatDuration(Number(boosts[0].end) - Number(boosts[0].start)) }}
left
<span v-if="timeLeftToClaim > 0" class="flex items-center">
<i-ho-clock class="mr-1 text-sm" />
{{ formatDuration(timeLeftToClaim) }}
left
</span>
<span v-else class="flex items-center">
<i-ho-exclamation-circle class="mr-1 text-sm" />
Claiming period ended
</span>
</div>
</TuneBlock>
<ModalTransactionStatus
Expand Down
4 changes: 3 additions & 1 deletion src/components/SpaceProposalBoostItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ async function withdraw(boost: BoostSubgraph) {
<div class="mt-[2px] md:mt-0">
Withdrawable in:
<span class="text-skin-heading">
{{ formatDuration(Number(boost.end) - Number(boost.start)) }}
{{
formatDuration(Number(boost.end) - Math.floor(Date.now() / 1000))
}}
</span>
</div>
</div>
Expand Down

0 comments on commit 6a7f992

Please sign in to comment.