diff --git a/src/locales/en.json b/src/locales/en.json index 974bf387..ba9b6bbf 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -3,7 +3,6 @@ "App": "App", "Apply": "Apply", "Any edits made on this page will be lost.": "Any edits made on this page made will be lost.", - "Are you sure you want to change the time zone to?": "Are you sure you want to change the time zone to?", "Are you sure you want to change the date time format?": "Are you sure you want to change the date time format?", "Are you sure you want to delete this CSV mapping? This action cannot be undone.": "Are you sure you want to delete this CSV mapping? This action cannot be undone.", "Are you sure you want to update this CSV mapping? This action cannot be undone.": "Are you sure you want to update this CSV mapping? This action cannot be undone.", @@ -48,6 +47,7 @@ "Failed to save CSV mapping.": "Failed to save CSV mapping.", "Failed to delete CSV mapping.": "Failed to delete CSV mapping.", "Failed to update CSV mapping.": "Failed to update CSV mapping.", + "Fetching TimeZones": "Fetching TimeZones", "Field mapping name": "Field mapping name", "This CSV mapping has been saved.": "This CSV mapping has been saved.", "This CSV mapping has been deleted.": "This CSV mapping has been deleted.", @@ -164,7 +164,6 @@ "UI Components": "UI Components", "Update": "Update", "Update mapping": "Update mapping", - "Update time zone": "Update time zone", "Update date time format": "Update date time format", "Upload": "Upload", "Upload a file": "Upload a file", diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 375bb0a7..70b7a27a 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -150,13 +150,15 @@ 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); - 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); + showToast(translate("Time zone updated successfully")); + } } }, diff --git a/src/views/TimezoneModal.vue b/src/views/TimezoneModal.vue index 91fd3f41..c1e1d01e 100644 --- a/src/views/TimezoneModal.vue +++ b/src/views/TimezoneModal.vue @@ -9,36 +9,40 @@ {{ $t("Select time zone") }} - + - -
- - - {{ $t("Fetching time zones") }} - -
-
-

{{ $t("No time zone found") }}

-
+
+ +
+ + + {{ $t("Fetching time zones") }} + +
- -
- - - - {{ timeZone.label }} ({{ timeZone.id }}) - - - - -
- +
+

{{ $t("No time zone found") }}

+
+ + +
+ + + + {{ timeZone.label }} ({{ timeZone.id }}) + + + + +
+
+ + - + @@ -63,8 +67,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"; @@ -105,25 +109,6 @@ export default defineComponent({ closeModal() { modalController.dismiss({ dismissed: true }); }, - async saveAlert() { - const message = this.$t("Are you sure you want to change the time zone to?", { timeZoneId: this.timeZoneId }); - const alert = await alertController.create({ - header: this.$t("Update time zone"), - message, - buttons: [ - { - text: this.$t("Cancel"), - }, - { - text: this.$t("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(); @@ -136,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; }, @@ -152,7 +141,7 @@ export default defineComponent({ }, async setUserTimeZone() { await this.store.dispatch("user/setUserTimeZone", { - "timeZoneId": this.timeZoneId + "tzId": this.timeZoneId }) this.closeModal() }