Skip to content

Commit

Permalink
Merge pull request #314 from xuhcc/empty-cart-withdraw
Browse files Browse the repository at this point in the history
Frontend: Show 'withdraw' button even if cart is empty
  • Loading branch information
xuhcc authored Mar 19, 2021
2 parents a07cf0c + 31c4475 commit 048bb44
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
9 changes: 6 additions & 3 deletions vue-app/src/components/Cart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export default class Cart extends Vue {
}
canSubmit(): boolean {
return this.$store.state.currentRound && this.cart.length > 0
return this.$store.state.currentRound && this.cart.length > 0 || this.canWithdrawContribution()
}
private isFormValid(): boolean {
Expand Down Expand Up @@ -271,6 +271,7 @@ export default class Cart extends Vue {
hasUnallocatedFunds(): boolean {
return (
this.errorMessage === null &&
this.contribution !== null &&
!this.contribution.isZero() &&
this.getTotal().lt(this.contribution)
Expand Down Expand Up @@ -312,8 +313,10 @@ export default class Cart extends Vue {
}
canWithdrawContribution(): boolean {
const { status } = this.$store.state.currentRound
return status === RoundStatus.Cancelled && !this.contribution.isZero()
return (
this.$store.state.currentRound?.status === RoundStatus.Cancelled &&
!this.contribution.isZero()
)
}
withdrawContribution(): void {
Expand Down
2 changes: 2 additions & 0 deletions vue-app/src/components/ProjectListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import { DateTime } from 'luxon'
import { DEFAULT_CONTRIBUTION_AMOUNT, CartItem } from '@/api/contributions'
import { recipientRegistryType } from '@/api/core'
import { Project, getProject } from '@/api/projects'
import { RoundStatus } from '@/api/round'
import { TcrItemStatus } from '@/api/recipient-registry-kleros'
import RecipientRegistrationModal from '@/components/RecipientRegistrationModal.vue'
import { SAVE_CART } from '@/store/action-types'
Expand Down Expand Up @@ -111,6 +112,7 @@ export default class ProjectListItem extends Vue {
this.$store.state.currentUser &&
this.$store.state.currentRound &&
DateTime.local() < this.$store.state.currentRound.votingDeadline &&
this.$store.state.currentRound.status !== RoundStatus.Cancelled &&
this.project.isHidden === false &&
this.project.isLocked === false
)
Expand Down
2 changes: 2 additions & 0 deletions vue-app/src/components/WithdrawalModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { BigNumber } from 'ethers'
import { withdrawContribution } from '@/api/contributions'
import Transaction from '@/components/Transaction.vue'
import { SET_CONTRIBUTION } from '@/store/mutation-types'
import { formatAmount } from '@/utils/amounts'
import { waitForTransaction } from '@/utils/contracts'
Expand Down Expand Up @@ -54,6 +55,7 @@ export default class WithdrawalModal extends Vue {
this.withdrawalTxError = error.message
return
}
this.$store.commit(SET_CONTRIBUTION, BigNumber.from(0))
this.step += 1
}
Expand Down
1 change: 1 addition & 0 deletions vue-app/src/views/Project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ export default class ProjectView extends Vue {
this.hasContributeBtn() &&
this.$store.state.currentUser &&
DateTime.local() < this.$store.state.currentRound.votingDeadline &&
this.$store.state.currentRound.status !== RoundStatus.Cancelled &&
this.project !== null &&
!this.project.isLocked
)
Expand Down

0 comments on commit 048bb44

Please sign in to comment.