|
@@ -1,16 +1,18 @@
|
|
-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'
|
|
|
|
|
|
+import { SET_CUSTOMERS, SET_LOADING_CUSTOMERS, SET_SHOW_CUSTOMER_FORM, SET_SELECTED_CUSTOMER } from '@/constants/mutationTypes'
|
|
|
|
+import { INIT_CUSTOMERS, SHOW_CUSTOMER_FORM, HIDE_CUSTOMER_FORM, SUBMIT_CUSTOMER, SELECT_CUSTOMER } from '@/constants/actionTypes'
|
|
|
|
|
|
const initialState = {
|
|
const initialState = {
|
|
customers: [],
|
|
customers: [],
|
|
loadingCustomers: false,
|
|
loadingCustomers: false,
|
|
- showingCustomerForm: false
|
|
|
|
|
|
+ showingCustomerForm: false,
|
|
|
|
+ selectedCustomer: null
|
|
}
|
|
}
|
|
|
|
|
|
const state = {
|
|
const state = {
|
|
customers: initialState.customers,
|
|
customers: initialState.customers,
|
|
loadingCustomers: !initialState.loadingCustomers,
|
|
loadingCustomers: !initialState.loadingCustomers,
|
|
- showingCustomerForm: initialState.showingCustomerForm
|
|
|
|
|
|
+ showingCustomerForm: initialState.showingCustomerForm,
|
|
|
|
+ selectedCustomer: initialState.selectedCustomer
|
|
}
|
|
}
|
|
|
|
|
|
const getters = {
|
|
const getters = {
|
|
@@ -34,6 +36,13 @@ const getters = {
|
|
*/
|
|
*/
|
|
showingCustomerForm(state) {
|
|
showingCustomerForm(state) {
|
|
return state.showingCustomerForm
|
|
return state.showingCustomerForm
|
|
|
|
+ },
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ * @param {*} state
|
|
|
|
+ */
|
|
|
|
+ selectedCustomer(state) {
|
|
|
|
+ return state.selectedCustomer
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -61,6 +70,14 @@ const mutations = {
|
|
*/
|
|
*/
|
|
[SET_SHOW_CUSTOMER_FORM] (state, payload) {
|
|
[SET_SHOW_CUSTOMER_FORM] (state, payload) {
|
|
state.showingCustomerForm = !!payload
|
|
state.showingCustomerForm = !!payload
|
|
|
|
+ },
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ * @param {*} state
|
|
|
|
+ * @param {*} payload
|
|
|
|
+ */
|
|
|
|
+ [SET_SELECTED_CUSTOMER] (state, payload) {
|
|
|
|
+ state.selectedCustomer = payload
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -95,6 +112,13 @@ const actions = {
|
|
*/
|
|
*/
|
|
[SUBMIT_CUSTOMER] ({ commit }) {
|
|
[SUBMIT_CUSTOMER] ({ commit }) {
|
|
console.log('submit')
|
|
console.log('submit')
|
|
|
|
+ },
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ * @param {*} param0
|
|
|
|
+ */
|
|
|
|
+ [SELECT_CUSTOMER] ({ commit }, payload) {
|
|
|
|
+ commit(SET_SELECTED_CUSTOMER, payload)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|