diff --git a/src/locales/en.json b/src/locales/en.json index f806720a..a28f9237 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -5,7 +5,6 @@ "App": "App", "Authenticating": "Authenticating", "Are you sure you have received the purchase order for the selected items? Once closed, the shipments for the selected items wont be available for receiving later.": "Are you sure you have received the purchase order for the selected items? { space } Once closed, the shipments for the selected items won't be available for receiving later.", - "Are you sure you want to change the time zone to?": "Are you sure you want to change the time zone to {timeZoneId}?", "Arrival date": "Arrival date", "Cancel": "Cancel", "Change": "Change", @@ -123,7 +122,6 @@ "Time zone updated successfully": "Time zone updated successfully", "To close the purchase order, select all.": "To close the purchase order, select all.", "Unable to update product identifier preference": "Unable to update product identifier preference", - "Update time zone": "Update time zone", "Username": "Username", "You do not have permission to access this page": "You do not have permission to access this page", "ZeroQuantity": "ZeroQuantity" diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index eb9d3aaa..5320472e 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -177,14 +177,16 @@ const actions: ActionTree = { /** * Update user timeZone */ - async setUserTimeZone ( { state, commit }, payload) { - const resp = await UserService.setUserTimeZone(payload) - if (resp.status === 200 && !hasError(resp)) { - const current: any = state.current; - current.userTimeZone = payload.timeZoneId; - commit(types.USER_INFO_UPDATED, current); - Settings.defaultZone = current.userTimeZone; - showToast(translate("Time zone updated successfully")); + async setUserTimeZone({ state, commit }, payload) { + const current: any = state.current; + if(current.userTimeZone !== payload.tzId) { + const resp = await UserService.setUserTimeZone(payload) + if(resp.status === 200 && !hasError(resp)) { + current.userTimeZone = payload.tzId; + commit(types.USER_INFO_UPDATED, current); + Settings.defaultZone = current.userTimeZone; + showToast(translate("Time zone updated successfully")); + } } }, diff --git a/src/views/TimezoneModal.vue b/src/views/TimezoneModal.vue index 2163501c..0fff0649 100644 --- a/src/views/TimezoneModal.vue +++ b/src/views/TimezoneModal.vue @@ -9,36 +9,39 @@ {{ translate("Select time zone") }} - + - -
- - - {{ translate("Fetching time zones") }} - -
-
-

{{ translate("No time zone found") }}

-
+
+ +
+ + + {{ translate("Fetching time zones") }} + +
+
+

{{ translate("No time zone found") }}

+
- -
- - - - {{ timeZone.label }} ({{ timeZone.id }}) - - - - -
- + +
+ + + + {{ timeZone.label }} ({{ timeZone.id }}) + + + + +
+
+ + - + @@ -63,8 +66,8 @@ import { IonSpinner, IonTitle, IonToolbar, - modalController, - alertController } from "@ionic/vue"; + modalController +} from "@ionic/vue"; import { defineComponent } from "vue"; import { close, save } from "ionicons/icons"; import { useStore } from "@/store"; @@ -106,25 +109,6 @@ export default defineComponent({ closeModal() { modalController.dismiss({ dismissed: true }); }, - async saveAlert() { - const message = translate("Are you sure you want to change the time zone to?", { timeZoneId: this.timeZoneId }); - const alert = await alertController.create({ - header: translate("Update time zone"), - message, - buttons: [ - { - text: translate("Cancel"), - }, - { - text: translate("Confirm"), - handler: () => { - this.setUserTimeZone(); - } - } - ], - }); - return alert.present(); - }, preventSpecialCharacters($event: any) { // Searching special characters fails the API, hence, they must be omitted if(/[`!@#$%^&*()_+\-=\\|,.<>?~]/.test($event.key)) $event.preventDefault(); @@ -137,13 +121,17 @@ export default defineComponent({ }, async getAvailableTimeZones() { this.isLoading = true; - const resp = await UserService.getAvailableTimeZones() - if(resp.status === 200 && !hasError(resp)) { - // We are filtering valid the timeZones coming with response here - this.timeZones = resp.data.filter((timeZone: any) => { - return DateTime.local().setZone(timeZone.id).isValid; - }); - this.findTimeZone(); + try { + const resp = await UserService.getAvailableTimeZones() + if(resp.status === 200 && !hasError(resp)) { + // We are filtering valid the timeZones coming with response here + this.timeZones = resp.data.filter((timeZone: any) => { + return DateTime.local().setZone(timeZone.id).isValid; + }); + this.findTimeZone(); + } + } catch(err) { + console.error(err) } this.isLoading = false; }, @@ -153,7 +141,7 @@ export default defineComponent({ }, async setUserTimeZone() { await this.store.dispatch("user/setUserTimeZone", { - "timeZoneId": this.timeZoneId + "tzId": this.timeZoneId }) this.closeModal() }