Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented: timeZone switcher component from dxp package(dxp/262) #273

Merged
merged 5 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
774 changes: 408 additions & 366 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"@casl/ability": "^6.0.0",
"@hotwax/app-version-info": "^1.0.0",
"@hotwax/apps-theme": "^1.2.6",
"@hotwax/dxp-components": "^1.12.2",
"@hotwax/oms-api": "^1.13.0",
"@hotwax/dxp-components": "^1.13.0",
"@hotwax/oms-api": "^1.14.0",
"@ionic/core": "^7.6.0",
"@ionic/vue": "^7.6.0",
"@ionic/vue-router": "^7.6.0",
Expand Down
6 changes: 4 additions & 2 deletions src/adapter/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { api, client, getConfig, getProductIdentificationPref, getUserFacilities, initialise, logout, resetConfig, setProductIdentificationPref, updateInstanceUrl, updateToken } from '@hotwax/oms-api'
import { api, client, getAvailableTimeZones, getConfig, getProductIdentificationPref, getUserFacilities, initialise, logout, resetConfig, setProductIdentificationPref, updateInstanceUrl, updateToken, setUserTimeZone } from '@hotwax/oms-api'

export {
api,
client,
getAvailableTimeZones,
getConfig,
getProductIdentificationPref,
getUserFacilities,
Expand All @@ -11,5 +12,6 @@ export {
resetConfig,
setProductIdentificationPref,
updateInstanceUrl,
updateToken
updateToken,
setUserTimeZone
}
4 changes: 4 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"Are you sure you want to change the time zone to?": "Are you sure you want to change the time zone to {timeZoneId}?",
"Authenticating": "Authenticating",
"Back to Launchpad": "Back to Launchpad",
"Browser TimeZone": "Browser TimeZone",
"Browser time zone": "Browser time zone",
"Built: ": "Built: {builtDateTime}",
"Camera permission denied.": "Camera permission denied.",
"Cancel": "Cancel",
Expand Down Expand Up @@ -54,7 +56,9 @@
"Search time zones": "Search time zones",
"Secondary": "Secondary",
"Select facility": "Select facility",
"Selected TimeZone": "Selected TimeZone",
"Select time zone": "Select time zone",
"Select a different time zone": "Select a different time zone",
"Set facility": "Set facility",
"Settings": "Settings",
"Shopify Config": "Shopify Config",
Expand Down
6 changes: 4 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import permissionRules from '@/authorization/Rules';
import permissionActions from '@/authorization/Actions';
import { dxpComponents } from '@hotwax/dxp-components'
import { login, logout, loader } from './user-utils';
import { getConfig, getProductIdentificationPref, initialise, setProductIdentificationPref } from '@/adapter';
import { getConfig, getAvailableTimeZones, getProductIdentificationPref, initialise, setProductIdentificationPref, setUserTimeZone } from '@/adapter';
import localeMessages from './locales';

const app = createApp(App)
Expand All @@ -57,7 +57,9 @@ const app = createApp(App)
getProductIdentificationPref,
initialise,
localeMessages,
setProductIdentificationPref
setProductIdentificationPref,
getAvailableTimeZones,
setUserTimeZone,
});

// Filters are removed in Vue 3 and global filter introduced https://v3.vuejs.org/guide/migration/filters.html#global-filters
Expand Down
16 changes: 0 additions & 16 deletions src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,6 @@ const checkPermission = async (payload: any): Promise <any> => {
});
}

const getAvailableTimeZones = async (): Promise <any> => {
return api({
url: "getAvailableTimeZones",
method: "get",
cache: true
});
}
const setUserTimeZone = async (payload: any): Promise <any> => {
return api({
url: "setUserTimeZone",
method: "post",
data: payload
});
}
const getQOHViewConfig = async (token: any, productStoreId: any): Promise<any> => {
// If the productStoreId is not provided, it may be case of facility not associated with any productStore
if (!productStoreId) {
Expand Down Expand Up @@ -225,12 +211,10 @@ const getCurrentEComStore = async (token: any, facilityId: any): Promise<any> =>

export const UserService = {
login,
getAvailableTimeZones,
getCurrentEComStore,
getQOHViewConfig,
getUserPermissions,
getUserProfile,
setUserTimeZone,
checkPermission,
updateQOHViewConfig
}
15 changes: 6 additions & 9 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import RootState from '@/store/RootState'
import UserState from './UserState'
import * as types from './mutation-types'
import { hasError, showToast } from '@/utils'

Check warning on line 6 in src/store/modules/user/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'hasError' is defined but never used

Check warning on line 6 in src/store/modules/user/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'hasError' is defined but never used
import { translate } from '@/i18n'
import { Settings } from 'luxon';
import { getUserFacilities, logout, updateInstanceUrl, updateToken, resetConfig } from '@/adapter'
Expand Down Expand Up @@ -157,16 +157,13 @@
/**
* 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 }, timeZoneId) {
const current: any = state.current;
current.userTimeZone = timeZoneId;
commit(types.USER_INFO_UPDATED, current);
Settings.defaultZone = current.userTimeZone;
},


// update current facility information
async setFacility ({ commit, dispatch, state }, payload) {
Expand Down
28 changes: 5 additions & 23 deletions src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,7 @@

<section>
<DxpProductIdentifier />

<ion-card>
<ion-card-header>
<ion-card-title>
{{ $t('Timezone') }}
</ion-card-title>
</ion-card-header>
<ion-card-content>
{{ $t('The timezone you select is used to ensure automations you schedule are always accurate to the time you select.') }}
</ion-card-content>
<ion-item lines="none">
<ion-label> {{ userProfile && userProfile.userTimeZone ? userProfile.userTimeZone : '-' }} </ion-label>
<ion-button @click="changeTimeZone()" slot="end" fill="outline" color="dark">{{ $t("Change") }}</ion-button>
</ion-item>
</ion-card>
<DxpTimeZoneSwitcher @timeZoneUpdated="timeZoneUpdated"/>
<ion-card>
<ion-card-header>
<ion-card-title>
Expand All @@ -93,13 +79,12 @@
</template>

<script lang="ts">
import { alertController, IonAvatar, IonButton, IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, IonContent, IonHeader,IonIcon, IonItem, IonLabel, IonPage, IonSelect, IonSelectOption, IonTitle, IonToggle, IonToolbar, modalController } from '@ionic/vue';
import { alertController, IonAvatar, IonButton, IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, IonContent, IonHeader,IonIcon, IonItem, IonPage, IonSelect, IonSelectOption, IonTitle, IonToggle, IonToolbar } from '@ionic/vue';
import { defineComponent } from 'vue';
import { codeWorkingOutline, ellipsisVertical, personCircleOutline, storefrontOutline, openOutline} from 'ionicons/icons'
import { mapGetters, useStore } from 'vuex';
import { useRouter } from 'vue-router';
import Image from '@/components/Image.vue'
import TimeZoneModal from '@/views/TimezoneModal.vue';
import { Actions, hasPermission } from '@/authorization'
import { UserService } from '@/services/UserService'
import { hasError, showToast } from '@/utils';
Expand All @@ -119,7 +104,6 @@ export default defineComponent({
IonHeader,
IonIcon,
IonItem,
IonLabel,
IonPage,
IonSelect,
IonSelectOption,
Expand Down Expand Up @@ -239,11 +223,9 @@ export default defineComponent({
});
await alert.present();
},
async changeTimeZone() {
const timeZoneModal = await modalController.create({
component: TimeZoneModal,
});
return timeZoneModal.present();

async timeZoneUpdated(tzId: string) {
await this.store.dispatch("user/setUserTimeZone", tzId)
},
logout () {
if (Object.keys(this.uploadProducts).length > 0) {
Expand Down
167 changes: 0 additions & 167 deletions src/views/TimezoneModal.vue

This file was deleted.

Loading