2019-03-19 08:53:11 +00:00
|
|
|
import filter from 'lodash/filter'
|
|
|
|
|
|
|
|
const reports = {
|
|
|
|
state: {
|
|
|
|
userId: null,
|
|
|
|
statuses: [],
|
2021-01-12 12:55:31 +00:00
|
|
|
preTickedIds: [],
|
2019-03-19 08:53:11 +00:00
|
|
|
modalActivated: false
|
|
|
|
},
|
|
|
|
mutations: {
|
2021-01-12 12:43:21 +00:00
|
|
|
openUserReportingModal (state, { userId, statuses, preTickedIds }) {
|
2019-03-19 08:53:11 +00:00
|
|
|
state.userId = userId
|
|
|
|
state.statuses = statuses
|
2021-01-12 12:43:21 +00:00
|
|
|
state.preTickedIds = preTickedIds
|
2019-03-19 08:53:11 +00:00
|
|
|
state.modalActivated = true
|
|
|
|
},
|
|
|
|
closeUserReportingModal (state) {
|
|
|
|
state.modalActivated = false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
actions: {
|
2021-01-12 12:43:21 +00:00
|
|
|
openUserReportingModal ({ rootState, commit }, { userId, statusIds = [] }) {
|
|
|
|
const preTickedStatuses = statusIds.map(id => rootState.statuses.allStatusesObject[id])
|
|
|
|
const preTickedIds = statusIds
|
|
|
|
const statuses = preTickedStatuses.concat(
|
|
|
|
filter(rootState.statuses.allStatuses,
|
|
|
|
status => status.user.id === userId && !preTickedIds.includes(status.id)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
commit('openUserReportingModal', { userId, statuses, preTickedIds })
|
2019-03-19 08:53:11 +00:00
|
|
|
},
|
|
|
|
closeUserReportingModal ({ commit }) {
|
|
|
|
commit('closeUserReportingModal')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default reports
|