This commit is contained in:
Matthieu Bessat 2020-07-22 14:31:00 +02:00
parent e987cf6c69
commit 4be9fea9fc

View file

@ -3,8 +3,24 @@ import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
state: {
interface AlertInterface {
color: string;
text: string;
enabled: boolean;
}
interface State {
alert: AlertInterface;
title: string;
tags: any;
data: any;
delegate: any;
debug: boolean;
validateMain: boolean;
validateMainCallback: any;
}
const defaultState: State = {
alert: {
color: '',
text: '',
@ -44,37 +60,40 @@ export default new Vuex.Store({
debug: false,
validateMain: false,
validateMainCallback: (d = false) => d
},
}
export default new Vuex.Store({
state: defaultState,
mutations: {
SET_DEBUG (state, payload) {
SET_DEBUG (state: State, payload) {
state.debug = payload
},
SET_TITLE (state, payload) {
SET_TITLE (state: State, payload) {
state.title = payload
window.document.title = state.title + ' | Panel forum des associations'
},
ADD_ALERT (state, payload) {
ADD_ALERT (state: State, payload) {
state.alert = {
color: payload.color,
text: payload.text,
enabled: true
}
},
DISABLE_ALERT (state) {
DISABLE_ALERT (state: State) {
state.alert.enabled = false
},
SET_DATA (state, payload) {
SET_DATA (state: State, payload) {
if (payload !== null) {
state.data = { ...state.data, ...payload }
}
},
SET_TAGS (state, payload) {
SET_TAGS (state: State, payload) {
state.tags = payload
},
SET_DELEGATE (state, payload) {
SET_DELEGATE (state: State, payload) {
state.delegate = { ...state.delegate, ...payload }
},
VALIDATE_MAIN (state, callback) {
VALIDATE_MAIN (state: State, callback) {
state.validateMain = true
state.validateMainCallback = (d: boolean) => {
state.validateMain = false