admin.js
5 days ago
appointment.js
5 days ago
booking.js
5 days ago
customers.js
5 days ago
event.js
5 days ago
package.js
5 days ago
payment.js
5 days ago
socialAuthOptions.js
5 days ago
status.js
5 days ago
useReactiveCustomize.js
5 days ago
customers.js
48 lines
| 1 | import httpClient from '../../../plugins/axios' |
| 2 | import { settings } from '../../../plugins/settings' |
| 3 | import { useUrlParams } from '../common/helper' |
| 4 | |
| 5 | function useCustomers(params, callback) { |
| 6 | httpClient |
| 7 | .get('/users/customers', { params: useUrlParams(params) }) |
| 8 | .then((response) => { |
| 9 | callback(response.data.data.users) |
| 10 | }) |
| 11 | .catch(() => { |
| 12 | callback([]) |
| 13 | }) |
| 14 | } |
| 15 | |
| 16 | function useSearchCustomers(store, value = '', params = {}, callback = () => {}) { |
| 17 | store.commit('customerInfo/setLoading', true) |
| 18 | |
| 19 | setTimeout(() => { |
| 20 | useCustomers( |
| 21 | Object.assign( |
| 22 | { |
| 23 | search: value, |
| 24 | page: 1, |
| 25 | limit: settings.general.customersFilterLimit, |
| 26 | skipCount: 1, |
| 27 | }, |
| 28 | params, |
| 29 | ), |
| 30 | (result) => { |
| 31 | store.commit('customerInfo/setCustomers', result) |
| 32 | |
| 33 | store.commit('customerInfo/setLoading', false) |
| 34 | |
| 35 | callback() |
| 36 | }, |
| 37 | ) |
| 38 | }, 500) |
| 39 | } |
| 40 | |
| 41 | function useFocusCustomers(store) { |
| 42 | if (!store.getters['customerInfo/getCustomers'].length) { |
| 43 | useSearchCustomers(store) |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | export { useCustomers, useSearchCustomers, useFocusCustomers } |
| 48 |