Skip to content
Snippets Groups Projects
Commit 1a4260c5 authored by Tim Eder's avatar Tim Eder
Browse files

unified eports in store

parent 03f66000
No related branches found
No related tags found
3 merge requests!296Merge develop for staging release,!230Draft: Vuex store refactoring suggestions,!225Draft: Resolve "[Refactoring] Improve vuex store usage"
...@@ -47,7 +47,7 @@ export interface IAppbarStore { ...@@ -47,7 +47,7 @@ export interface IAppbarStore {
* *
* @return {IAppbarStore} the state object * @return {IAppbarStore} the state object
*/ */
export const state = (): IAppbarStore => { const state = (): IAppbarStore => {
return { return {
activeTab: null, activeTab: null,
cancelBtnDisabled: false, cancelBtnDisabled: false,
...@@ -59,7 +59,7 @@ export const state = (): IAppbarStore => { ...@@ -59,7 +59,7 @@ export const state = (): IAppbarStore => {
} }
} }
export const mutations = { const mutations = {
/** /**
* Sets the title of the AppBar * Sets the title of the AppBar
* *
...@@ -141,7 +141,7 @@ type StoreContext = { ...@@ -141,7 +141,7 @@ type StoreContext = {
dispatch: (action: string, payload: any) => void dispatch: (action: string, payload: any) => void
} }
export const actions = { const actions = {
/** /**
* initializes the Appbar * initializes the Appbar
* *
...@@ -452,3 +452,10 @@ export const actions = { ...@@ -452,3 +452,10 @@ export const actions = {
context.dispatch('init', state()) context.dispatch('init', state())
} }
} }
export default {
namespaced: true,
state,
actions,
mutations
}
...@@ -46,7 +46,7 @@ interface contactsState { ...@@ -46,7 +46,7 @@ interface contactsState {
totalPages: number totalPages: number
} }
export const state = () => ({ const state = () => ({
contacts: [], contacts: [],
contact: null, contact: null,
configurationContacts: [], configurationContacts: [],
...@@ -54,7 +54,8 @@ export const state = () => ({ ...@@ -54,7 +54,8 @@ export const state = () => ({
pageNumber: 1, pageNumber: 1,
pageSize: 20 pageSize: 20
}) })
export const getters = {
const getters = {
searchContacts: (state: contactsState) => { searchContacts: (state: contactsState) => {
return state.contacts.filter((c: Contact) => !state.configurationContacts.find((rc: Contact) => rc.id === c.id)) return state.contacts.filter((c: Contact) => !state.configurationContacts.find((rc: Contact) => rc.id === c.id))
}, },
...@@ -68,7 +69,7 @@ export const getters = { ...@@ -68,7 +69,7 @@ export const getters = {
} }
// @ts-ignore // @ts-ignore
export const actions: { const actions: {
[key: string]: any; [key: string]: any;
$api: Api $api: Api
} = { } = {
...@@ -126,7 +127,8 @@ export const actions: { ...@@ -126,7 +127,8 @@ export const actions: {
return this.$api.contacts.save(contact) return this.$api.contacts.save(contact)
} }
} }
export const mutations = {
const mutations = {
setContacts (state: contactsState, contacts: Contact[]) { setContacts (state: contactsState, contacts: Contact[]) {
state.contacts = contacts state.contacts = contacts
}, },
...@@ -143,3 +145,11 @@ export const mutations = { ...@@ -143,3 +145,11 @@ export const mutations = {
state.totalPages = count state.totalPages = count
} }
} }
export default {
namespaced: true,
state,
getters,
actions,
mutations
}
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
import { Commit } from 'vuex' import { Commit } from 'vuex'
import { IUploadResult } from '@/services/sms/UploadApi' import { IUploadResult } from '@/services/sms/UploadApi'
import { Api } from '@/services/Api' import { Api } from '@/services/Api'
const state = () => ({}) const state = () => ({})
const getters = {} const getters = {}
......
...@@ -34,14 +34,14 @@ export interface ISnackbarStore { ...@@ -34,14 +34,14 @@ export interface ISnackbarStore {
success: string success: string
} }
export const state = () => { const state = () => {
return { return {
error: '', error: '',
success: '' success: ''
} }
} }
export const mutations = { const mutations = {
setError (state: ISnackbarStore, error: string) { setError (state: ISnackbarStore, error: string) {
state.error = error state.error = error
}, },
...@@ -55,3 +55,9 @@ export const mutations = { ...@@ -55,3 +55,9 @@ export const mutations = {
state.success = '' state.success = ''
} }
} }
export default {
namespaced: true,
state,
mutations
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment