SurenNeware | 6185909 | 2020-10-01 09:37:32 +0530 | [diff] [blame] | 1 | import api from '@/store/api'; |
SurenNeware | 31bf55a | 2020-06-22 21:53:33 +0530 | [diff] [blame] | 2 | import i18n from '@/i18n'; |
SurenNeware | 090c2d4 | 2020-04-01 14:07:27 +0530 | [diff] [blame] | 3 | |
| 4 | const ServerLedStore = { |
| 5 | namespaced: true, |
| 6 | state: { |
Derick Montague | 6483544 | 2020-11-29 12:31:20 -0600 | [diff] [blame] | 7 | indicatorLedActiveState: false, |
SurenNeware | 090c2d4 | 2020-04-01 14:07:27 +0530 | [diff] [blame] | 8 | }, |
| 9 | getters: { |
Derick Montague | 6483544 | 2020-11-29 12:31:20 -0600 | [diff] [blame] | 10 | getIndicatorLedActiveState: (state) => state.indicatorLedActiveState, |
SurenNeware | 090c2d4 | 2020-04-01 14:07:27 +0530 | [diff] [blame] | 11 | }, |
| 12 | mutations: { |
Derick Montague | 6483544 | 2020-11-29 12:31:20 -0600 | [diff] [blame] | 13 | setIndicatorLedActiveState(state, indicatorLedActiveState) { |
| 14 | state.indicatorLedActiveState = indicatorLedActiveState; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 15 | }, |
SurenNeware | 090c2d4 | 2020-04-01 14:07:27 +0530 | [diff] [blame] | 16 | }, |
| 17 | actions: { |
Derick Montague | 6483544 | 2020-11-29 12:31:20 -0600 | [diff] [blame] | 18 | async getIndicatorLedActiveState({ commit }) { |
SurenNeware | 31bf55a | 2020-06-22 21:53:33 +0530 | [diff] [blame] | 19 | return await api |
Sean Zhang | 8841b7d | 2024-06-15 08:42:41 +0300 | [diff] [blame] | 20 | .get(`${await this.dispatch('global/getSystemPath')}`) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 21 | .then((response) => { |
Derick Montague | 6483544 | 2020-11-29 12:31:20 -0600 | [diff] [blame] | 22 | commit( |
| 23 | 'setIndicatorLedActiveState', |
Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame] | 24 | response.data.LocationIndicatorActive, |
Derick Montague | 6483544 | 2020-11-29 12:31:20 -0600 | [diff] [blame] | 25 | ); |
SurenNeware | 090c2d4 | 2020-04-01 14:07:27 +0530 | [diff] [blame] | 26 | }) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 27 | .catch((error) => console.log(error)); |
SurenNeware | 090c2d4 | 2020-04-01 14:07:27 +0530 | [diff] [blame] | 28 | }, |
Derick Montague | 6483544 | 2020-11-29 12:31:20 -0600 | [diff] [blame] | 29 | async saveIndicatorLedActiveState({ commit }, payload) { |
Yoshie Muranaka | 11bafca | 2020-12-01 16:38:47 -0800 | [diff] [blame] | 30 | commit('setIndicatorLedActiveState', payload); |
SurenNeware | 31bf55a | 2020-06-22 21:53:33 +0530 | [diff] [blame] | 31 | return await api |
Sean Zhang | 8841b7d | 2024-06-15 08:42:41 +0300 | [diff] [blame] | 32 | .patch(`${await this.dispatch('global/getSystemPath')}`, { |
SurenNeware | 2aac4d3 | 2020-11-24 16:32:14 +0530 | [diff] [blame] | 33 | LocationIndicatorActive: payload, |
| 34 | }) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 35 | .catch((error) => { |
SurenNeware | 31bf55a | 2020-06-22 21:53:33 +0530 | [diff] [blame] | 36 | console.log(error); |
Yoshie Muranaka | 11bafca | 2020-12-01 16:38:47 -0800 | [diff] [blame] | 37 | commit('setIndicatorLedActiveState', !payload); |
SurenNeware | 2aac4d3 | 2020-11-24 16:32:14 +0530 | [diff] [blame] | 38 | if (payload) { |
Sandeepa Singh | 68cbbe9 | 2021-07-14 16:02:22 +0530 | [diff] [blame] | 39 | throw new Error( |
Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame] | 40 | i18n.t('pageInventory.toast.errorEnableIdentifyLed'), |
Sandeepa Singh | 68cbbe9 | 2021-07-14 16:02:22 +0530 | [diff] [blame] | 41 | ); |
SurenNeware | 31bf55a | 2020-06-22 21:53:33 +0530 | [diff] [blame] | 42 | } else { |
Sandeepa Singh | 68cbbe9 | 2021-07-14 16:02:22 +0530 | [diff] [blame] | 43 | throw new Error( |
Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame] | 44 | i18n.t('pageInventory.toast.errorDisableIdentifyLed'), |
Sandeepa Singh | 68cbbe9 | 2021-07-14 16:02:22 +0530 | [diff] [blame] | 45 | ); |
SurenNeware | 31bf55a | 2020-06-22 21:53:33 +0530 | [diff] [blame] | 46 | } |
| 47 | }); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 48 | }, |
| 49 | }, |
SurenNeware | 090c2d4 | 2020-04-01 14:07:27 +0530 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | export default ServerLedStore; |