Skip to content

Commit

Permalink
Reuse the existing v-snackbar
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKostka committed Jan 16, 2024
1 parent 9a7fd67 commit c4e7526
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions src/components/Pages/ManageWiki/Cards/QuestyCaptcha.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,13 @@
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
<v-snackbar color="success" elevation="24" v-model="successMessage">
Your questions have been saved
<v-snackbar :color="message.status" elevation="24" v-model="message.show">
{{ message.text }}
<template v-slot:action>
<v-btn
text
variant="text"
@click="closeAlert"
>
Close
</v-btn>
</template>
</v-snackbar>
<v-snackbar color="error" elevation="24" v-model="errorMessage">
Something is wrong with saving your questions. Please try again
<template v-slot:action>
<v-btn
text
variant="text"
@click="closeAlert"
@click="message.show = false"
>
Close
</v-btn>
Expand All @@ -111,8 +99,7 @@ export default {
],
data () {
return {
successMessage: false,
errorMessage: false,
message: false,
captchaActivate: false,
questionsFromStore: [],
panel: false
Expand Down Expand Up @@ -143,6 +130,9 @@ export default {
answers: []
})
},
showMessage (status, message) {
this.message = { status: status, text: message, show: true }
},
saveForm () {
for (let i = 0; i < this.questionsFromStore.length; i++) {
const entry = this.questionsFromStore[i]
Expand Down Expand Up @@ -174,22 +164,18 @@ export default {
.then(() => {
this.$store.dispatch('setEnabledQuestyCaptcha', enableValue)
this.$store.dispatch('setQuestyCaptchaQuestions', this.questionsFromStore)
this.successMessage = true
this.showMessage('success', 'Your questions have been saved.')
})
.catch(err => {
console.log(err.response)
this.errorMessage = true
this.showMessage('error', 'Something went wrong with saving your questions. Please try again.')
})
this.panel = false
})
},
recoverDefaultQuestions () {
const recoveredDefaultQuestions = this.$store.state.wikis.currentWikiSettings.defaultQuestions
this.questionsFromStore = JSON.parse(JSON.stringify(recoveredDefaultQuestions))
},
closeAlert () {
this.successMessage = false
this.errorMessage = false
}
}
}
Expand Down

0 comments on commit c4e7526

Please sign in to comment.