Skip to content

Commit

Permalink
Merge pull request #664 from clrfund/fix/missing-round-error
Browse files Browse the repository at this point in the history
Fix missing round error
  • Loading branch information
yuetloo authored Jun 2, 2023
2 parents 2f8786d + 3415a01 commit e2ae2e0
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 14 deletions.
3 changes: 2 additions & 1 deletion vue-app/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const routeName = computed(() => route.name?.toString() || '')
const isUserAndRoundLoaded = computed(() => !!currentUser.value && !!currentRound.value)
const isInApp = computed(() => routeName.value !== 'landing')
const isVerifyStep = computed(() => routeName.value === 'verify-step')
const isSideCartShown = computed(() => !!currentUser.value && isSidebarShown.value && routeName.value !== 'cart')
const isSideCartShown = computed(() => isUserAndRoundLoaded.value && isSidebarShown.value && routeName.value !== 'cart')
const isCartPadding = computed(() => {
const routes = ['cart']
return routes.includes(routeName.value)
Expand Down Expand Up @@ -169,6 +169,7 @@ onMounted(async () => {
await appStore.loadMACIFactoryInfo()
await appStore.loadRoundInfo()
await recipientStore.loadRecipientRegistryInfo()
appStore.isAppReady = true
setupLoadIntervals()
})
Expand Down
3 changes: 2 additions & 1 deletion vue-app/src/components/CallToActionCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import { useAppStore, useUserStore } from '@/stores'
import { storeToRefs } from 'pinia'
const appStore = useAppStore()
const { canUserReallocate, hasContributionPhaseEnded } = storeToRefs(appStore)
const { canUserReallocate, hasContributionPhaseEnded, currentRound } = storeToRefs(appStore)
const userStore = useUserStore()
const { currentUser } = storeToRefs(userStore)
Expand All @@ -58,6 +58,7 @@ const hasStartedVerification = computed(
const showUserVerification = computed(() => {
return (
userRegistryType === UserRegistryType.BRIGHT_ID &&
currentRound.value &&
currentUser.value?.isRegistered !== undefined &&
!currentUser.value.isRegistered
)
Expand Down
18 changes: 9 additions & 9 deletions vue-app/src/components/Cart.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<template>
<div class="h100">
<div v-if="!currentUser" class="empty-cart">
<loader v-if="!isAppReady"></loader>
<div v-else-if="!currentRound" class="empty-cart">
<div class="moon-emoji">🌚</div>
<h3>{{ $t('roundInfo.div21') }}</h3>
</div>
<div v-else-if="!currentUser" class="empty-cart">
<div class="moon-emoji">🌚</div>
<h3>{{ $t('cart.h3_1') }}</h3>
<button @click="promptConnection" class="btn-action">{{ $t('cart.connect') }}</button>
Expand Down Expand Up @@ -217,7 +222,7 @@
</div>
</template>
<script setup lang="ts">
import { computed, ref, onMounted } from 'vue'
import { computed, ref } from 'vue'
import { BigNumber } from 'ethers'
import { parseFixed } from '@ethersproject/bignumber'
import { DateTime } from 'luxon'
Expand Down Expand Up @@ -262,6 +267,7 @@ const {
hasUserVoted,
hasContributionPhaseEnded,
contributor,
isAppReady,
} = storeToRefs(appStore)
const userStore = useUserStore()
const { currentUser } = storeToRefs(userStore)
Expand Down Expand Up @@ -293,12 +299,6 @@ function removeAll(): void {
appStore.toggleEditSelection(true)
}
onMounted(() => {
if (currentUser.value && !currentUser.value.encryptionKey) {
promptSignagure()
}
})
function showError(errorMessage: string) {
const { open, close } = useModal({
component: ErrorModal,
Expand Down Expand Up @@ -348,7 +348,7 @@ function promptSignagure(): void {
}
async function loadCart() {
if (appStore.cartLoaded) {
if (appStore.cartLoaded || !appStore.currentRound) {
return
}
Expand Down
21 changes: 20 additions & 1 deletion vue-app/src/components/CartWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<script setup lang="ts">
import { computed } from 'vue'
import Cart from '@/components/Cart.vue'
import { useModal } from 'vue-final-modal'
import SignatureModal from '@/components/SignatureModal.vue'
import { useAppStore, useUserStore } from '@/stores'
import { storeToRefs } from 'pinia'
Expand All @@ -43,8 +46,24 @@ const isCartBadgeShown = computed(() => {
return (canUserReallocate.value || isRoundContributionPhase.value) && !!cart.value.length
})
async function promptSignagure() {
const { open, close } = useModal({
component: SignatureModal,
attrs: {
onClose() {
close().then(() => {
appStore.toggleShowCartPanel()
})
},
},
})
open()
}
function toggleCart(): void {
appStore.toggleShowCartPanel()
if (currentUser.value && !currentUser.value.encryptionKey) {
promptSignagure()
}
}
</script>

Expand Down
2 changes: 2 additions & 0 deletions vue-app/src/stores/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { assert, ASSERT_MISSING_ROUND, ASSERT_MISSING_SIGNATURE, ASSERT_NOT_CONN
import { Keypair } from '@clrfund/maci-utils'

export type AppState = {
isAppReady: boolean
cart: CartItem[]
cartEditModeSelected: boolean
committedCart: CartItem[]
Expand All @@ -46,6 +47,7 @@ export type AppState = {

export const useAppStore = defineStore('app', {
state: (): AppState => ({
isAppReady: false,
cart: new Array<CartItem>(),
cartEditModeSelected: false,
committedCart: new Array<CartItem>(),
Expand Down
2 changes: 1 addition & 1 deletion vue-app/src/views/Profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ onMounted(async () => {
const walletProvider = computed(() => currentUser.value?.walletProvider)
const showBrightIdWidget = computed(
() => userRegistryType === UserRegistryType.BRIGHT_ID && !hasContributionPhaseEnded.value,
() => userRegistryType === UserRegistryType.BRIGHT_ID && currentRound.value && !hasContributionPhaseEnded.value,
)
const tokenLogo = computed(() => getTokenLogo(nativeTokenSymbol.value))
const displayAddress = computed(() => {
Expand Down
2 changes: 1 addition & 1 deletion vue-app/src/views/VerifyLanding.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ onMounted(async () => {
})
const isRoundFull = computed(() => isRoundContributorLimitReached.value)
const isRoundOver = computed(() => hasContributionPhaseEnded.value)
const isRoundOver = computed(() => !currentRound.value || hasContributionPhaseEnded.value)
const showBrightIdButton = computed(() => currentUser.value?.isRegistered === false)
async function promptSignagure() {
Expand Down

0 comments on commit e2ae2e0

Please sign in to comment.