From 4be9fea9fcf9b9c9d0b740479cf3495abae9f151 Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Wed, 22 Jul 2020 14:31:00 +0200 Subject: [PATCH] update --- src/store/index.ts | 117 ++++++++++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 49 deletions(-) diff --git a/src/store/index.ts b/src/store/index.ts index 654a04e..d4267ac 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -3,78 +3,97 @@ import Vuex from 'vuex' Vue.use(Vuex) -export default new Vuex.Store({ - state: { - alert: { - color: '', - text: '', - enabled: false - }, - title: '', - tags: [], - data: { - name: '', - tags: [], - descriptionShort: '', - descriptionLong: '', - thumbnail: { - key: '', - contentType: '', - location: '', - type: 'thumbnail' - }, - contacts: { - facebook: '', - twitter: '', - instagram: '', - website: '', - address: '', - person: '', - email: '', - phone: '', - peoples: [] - } - }, - delegate: { - validationState: 'unaware', - admiName: '', - email: '', - publicUrl: '' - }, - debug: false, - validateMain: false, - validateMainCallback: (d = false) => d +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: '', + enabled: false }, + title: '', + tags: [], + data: { + name: '', + tags: [], + descriptionShort: '', + descriptionLong: '', + thumbnail: { + key: '', + contentType: '', + location: '', + type: 'thumbnail' + }, + contacts: { + facebook: '', + twitter: '', + instagram: '', + website: '', + address: '', + person: '', + email: '', + phone: '', + peoples: [] + } + }, + delegate: { + validationState: 'unaware', + admiName: '', + email: '', + publicUrl: '' + }, + 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