Skip to content

Commit

Permalink
feat: create support pop up logic
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroAkbal committed Oct 2, 2020
1 parent 7d43569 commit fc6c47d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
38 changes: 38 additions & 0 deletions components/utils/SupportPopUpManager.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<script>
import { mapGetters, mapMutations } from 'vuex'
export default {
data() {
return {
isSupportPopUpActive: false,
}
},
computed: {
...mapGetters(['getTimesTheAppHasBeenOpened']),
},
watch: {
getTimesTheAppHasBeenOpened(value) {
if (value % 10 === 0) {
this.isSupportPopUpActive = true
//
} else {
this.isSupportPopUpActive = false
}
},
},
mounted() {
this.setTimesTheAppHasBeenOpened(this.getTimesTheAppHasBeenOpened + 1)
},
methods: {
...mapMutations(['setTimesTheAppHasBeenOpened']),
toggleSupportPopUp() {
this.isSupportPopUpActive = !this.isSupportPopUpActive
},
},
}
</script>
12 changes: 12 additions & 0 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ export const state = () => ({
},

errors: undefined,

statistics: {
timesTheAppHasBeenOpened: 0,
},
})

export const getters = {
Expand All @@ -14,12 +18,20 @@ export const getters = {
getErrors(state) {
return state.errors
},

getTimesTheAppHasBeenOpened(state) {
return state.statistics.timesTheAppHasBeenOpened
},
}

export const mutations = {
setErrors(state, value) {
state.errors = value
},

setTimesTheAppHasBeenOpened(state, value) {
state.statistics.timesTheAppHasBeenOpened = value
},
}

export const actions = {
Expand Down

0 comments on commit fc6c47d

Please sign in to comment.