Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

Commit

Permalink
fix(proposal): show toast error for proposal submit failures
Browse files Browse the repository at this point in the history
  • Loading branch information
vhf committed Oct 28, 2019
1 parent 14b409a commit ea58c19
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 39 deletions.
42 changes: 22 additions & 20 deletions pages/proposal/class.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ import discardDraft from '@/apollo/mutations/discardDraft'
import ClassForm from '@/components/proposal/ClassForm'
import ProgressionBox from '@/components/proposal/ProgressionBox'
import Loader from '@/components/layout/Loader'
import { toastClose } from '@/libs/utils'
import { SAVE, SUBMIT, NEW, LOAD } from '@/store/action-types'
Expand Down Expand Up @@ -265,6 +266,15 @@ export default {
this.$store.dispatch('drafts/LOAD')
this.$router.push({ name: 'proposal-id', params: { id: this.success } })
}
},
error () {
if (this.error && !this.success) {
this.$vuexSet('class.clss.isDraft', true)
this.autosaveDraft().then(() => {
this.isLoading = false
this.$toast.error(`Error: ${this.error}`, toastClose)
})
}
}
},
methods: {
Expand All @@ -275,27 +285,19 @@ export default {
load: LOAD
}),
async sendProposal () {
try {
// Send splash screen
this.isLoading = true
// remove draft status from the json proposalObject
this.$vuexSet('class.clss.isDraft', false)
// save the changes
await this.autosaveDraft()
this.stopAutosave()
// Send splash screen
this.isLoading = true
// remove draft status from the json proposalObject
this.$vuexSet('class.clss.isDraft', false)
// save the changes
await this.autosaveDraft()
this.stopAutosave()
const token = this.$apolloHelpers.getToken()
// create the PR etc
await this.submit(token)
// submit will commit success or error to the store,
// see this page's `watch`ers
}
catch (err) {
this.$vuexSet('class.clss.isDraft', true)
// save the changes
await this.autosaveDraft()
this.isLoading = false
}
const token = this.$apolloHelpers.getToken()
// create the PR etc
await this.submit(token)
// submit will commit success or error to the store,
// see this page's `watch`ers
},
stopAutosave () {
clearInterval(this.saveInterval)
Expand Down
42 changes: 23 additions & 19 deletions pages/proposal/property.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ import discardDraft from '@/apollo/mutations/discardDraft'
import PropertyForm from '@/components/proposal/PropertyForm'
import ProgressionBox from '@/components/proposal/ProgressionBox'
import Loader from '@/components/layout/Loader'
import { toastClose } from '@/libs/utils'
import { SAVE, SUBMIT, NEW, LOAD } from '@/store/action-types'
const {
Expand Down Expand Up @@ -263,6 +265,15 @@ export default {
this.$store.dispatch('drafts/LOAD')
this.$router.push({ name: 'proposal-id', params: { id: this.success } })
}
},
error () {
if (this.error && !this.success) {
this.$vuexSet('prop.prop.isDraft', true)
this.autosaveDraft().then(() => {
this.isLoading = false
this.$toast.error(`Error: ${this.error}`, toastClose)
})
}
}
},
methods: {
Expand All @@ -273,26 +284,19 @@ export default {
load: LOAD
}),
async sendProposal () {
try {
// Send splash screen
this.isLoading = true
// remove draft status from the json proposalObject
this.$vuexSet('prop.prop.isDraft', false)
// save the changes
await this.autosaveDraft()
this.stopAutosave()
// Send splash screen
this.isLoading = true
// remove draft status from the json proposalObject
this.$vuexSet('prop.prop.isDraft', false)
// save the changes
await this.autosaveDraft()
this.stopAutosave()
const token = this.$apolloHelpers.getToken()
// create the PR etc
await this.submit(token)
// submit will commit success or error to the store,
// see this page's `watch`ers
}
catch (err) {
this.$vuexSet('prop.prop.isDraft', true)
await this.autosaveDraft()
this.isLoading = false
}
const token = this.$apolloHelpers.getToken()
// create the PR etc
await this.submit(token)
// submit will commit success or error to the store,
// see this page's `watch`ers
},
stopAutosave () {
clearInterval(this.saveInterval)
Expand Down

0 comments on commit ea58c19

Please sign in to comment.