|
@@ -1,14 +1,16 @@
|
|
|
-import { SET_CUSTOMERS, SET_LOADING_CUSTOMERS } from '@/constants/mutationTypes'
|
|
|
-import { INIT_CUSTOMERS } from '@/constants/actionTypes'
|
|
|
+import { SET_CUSTOMERS, SET_LOADING_CUSTOMERS, SET_SHOW_CUSTOMER_FORM } from '@/constants/mutationTypes'
|
|
|
+import { INIT_CUSTOMERS, SHOW_CUSTOMER_FORM, HIDE_CUSTOMER_FORM, SUBMIT_CUSTOMER } from '@/constants/actionTypes'
|
|
|
|
|
|
const initialState = {
|
|
|
customers: [],
|
|
|
- loadingCustomers: false
|
|
|
+ loadingCustomers: false,
|
|
|
+ showingCustomerForm: false
|
|
|
}
|
|
|
|
|
|
const state = {
|
|
|
customers: initialState.customers,
|
|
|
- loadingCustomers: !initialState.loadingCustomers
|
|
|
+ loadingCustomers: !initialState.loadingCustomers,
|
|
|
+ showingCustomerForm: initialState.showingCustomerForm
|
|
|
}
|
|
|
|
|
|
const getters = {
|
|
@@ -25,6 +27,13 @@ const getters = {
|
|
|
*/
|
|
|
loadingCustomers(state) {
|
|
|
return state.loadingCustomers
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param {*} state
|
|
|
+ */
|
|
|
+ showingCustomerForm(state) {
|
|
|
+ return state.showingCustomerForm
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -44,6 +53,14 @@ const mutations = {
|
|
|
*/
|
|
|
[SET_LOADING_CUSTOMERS] (state, payload) {
|
|
|
state.loadingCustomers = !!payload
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param {*} state
|
|
|
+ * @param {*} payload
|
|
|
+ */
|
|
|
+ [SET_SHOW_CUSTOMER_FORM] (state, payload) {
|
|
|
+ state.showingCustomerForm = !!payload
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -56,12 +73,34 @@ const actions = {
|
|
|
[INIT_CUSTOMERS] ({ commit }, payload) {
|
|
|
commit(SET_CUSTOMERS, payload)
|
|
|
commit(SET_LOADING_CUSTOMERS)
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param {*} param0
|
|
|
+ * @param {*} payload
|
|
|
+ */
|
|
|
+ [SHOW_CUSTOMER_FORM] ({ commit }) {
|
|
|
+ commit(SET_SHOW_CUSTOMER_FORM, true)
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param {*} param0
|
|
|
+ */
|
|
|
+ [HIDE_CUSTOMER_FORM] ({ commit }) {
|
|
|
+ commit(SET_SHOW_CUSTOMER_FORM, false)
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param {*} param0
|
|
|
+ */
|
|
|
+ [SUBMIT_CUSTOMER] ({ commit }) {
|
|
|
+ console.log('submit')
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export default {
|
|
|
state,
|
|
|
getters,
|
|
|
- actions,
|
|
|
- mutations
|
|
|
+ mutations,
|
|
|
+ actions
|
|
|
}
|