import * as types from '../../types'; export default { [types.FETCH_DISTRIBUTORS]: ({commit}) => { // TODO: Remove this mocked data const distributors = [ { "id": 1, "title": "Charton Hobbes", "notes": "", "contacts": [ { "uuid": "44490103-92B7-4712-B494-E65878E6B0DC", "email": "abc@wisksolutions.com", "date": "2018-02-28T05:01:26Z", "name": "ABC", "phone": "", }, { "uuid": "E7AD1046-3293-4F41-910C-63A198C9D3B6", "email": "efg@wisksolutions.com", "date": "2018-02-28T05:01:26Z", "name": "EFG", "phone": "", } ] }, { "id": 2, "title": "Bob Marley", "notes": "Something", "contacts": [ { "uuid": "44490103-92B7-4712-B494-E65878E6B0DC", "email": "abc@wisksolutions.com", "date": "2018-02-28T05:01:26Z", "name": "ABC", "phone": "", } ] }, ] commit(types.UPDATE_DISTRIBUTORS, distributors) }, [types.CLEAR_DISTRIBUTORS]: ({commit}) => { commit(types.UPDATE_DISTRIBUTORS, []); }, /** * Expected payload: {id, distributor} */ [types.SET_DISTRIBUTOR]: ({commit, getters}, payload) => { if (payload.id) { // api call // Update server with what changed } else { // api call // Add new distributor } commit(types.UPDATE_DISTRIBUTOR, payload.distributor); }, };