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) #283

Merged
merged 5 commits into from
Apr 9, 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
799 changes: 412 additions & 387 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 @@ -19,8 +19,8 @@
"@casl/ability": "^6.0.0",
"@hotwax/app-version-info": "^1.0.0",
"@hotwax/apps-theme": "^1.2.6",
"@hotwax/dxp-components": "1.12.1",
"@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,4 +1,4 @@
import { api, client, getConfig, initialise, logout, resetConfig, updateInstanceUrl, updateToken, setUserLocale } from '@hotwax/oms-api'
import { api, client, getConfig, initialise, logout, resetConfig, updateInstanceUrl, updateToken, setUserTimeZone, getAvailableTimeZones, setUserLocale } from '@hotwax/oms-api'

export {
api,
Expand All @@ -9,5 +9,7 @@ export {
resetConfig,
updateInstanceUrl,
updateToken,
setUserLocale
setUserLocale,
setUserTimeZone,
getAvailableTimeZones
}
4 changes: 4 additions & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"back-order": "back-order",
"Back-order": "Back-order",
"Broker orders": "Broker orders",
"Browser TimeZone": "Browser TimeZone",
"Browser time zone": "Browser time zone",
"Built: ": "Built: {builtDateTime}",
"eCom Store": "eCom Store",
"Cancel": "Cancel",
Expand Down Expand Up @@ -192,7 +194,9 @@
"Selected variant not available": "Selected variant not available",
"Selected variant not available. Reseting to first variant.": "Selected variant not available. Reseting to first variant.",
"Select a new promise date for these orders. This new date will be used for allocating inventory and fulfilling these orders.": "Select a new promise date for these orders. This new date will be used for allocating inventory and fulfilling these orders.",
"Selected TimeZone": "Selected TimeZone",
"Select time zone": "Select time zone",
"Select a different time zone": "Select a different time zone",
"Service has been scheduled": "Service has been scheduled",
"Settings": "Settings",
"Ships from date": "Ships from date",
Expand Down
6 changes: 4 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { login, logout, loader } from './user-utils';
import permissionPlugin from '@/authorization';
import permissionRules from '@/authorization/Rules';
import permissionActions from '@/authorization/Actions';
import { getConfig, initialise, setUserLocale} from '@/adapter'
import { getConfig, initialise, setUserTimeZone, getAvailableTimeZones, setUserLocale} from '@/adapter'
import localeMessages from './i18n/locales';

const app = createApp(App)
Expand All @@ -56,7 +56,9 @@ const app = createApp(App)
getConfig: getConfig,
initialise: initialise,
localeMessages,
setUserLocale
setUserLocale,
setUserTimeZone,
getAvailableTimeZones
});

// 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 @@ -12,20 +12,6 @@ const login = async (username: string, password: string): 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 setUserPreference = async (payload: any): Promise<any> => {
return api({
Expand Down Expand Up @@ -204,12 +190,10 @@ const getUserProfile = async (token: any): Promise<any> => {
}

export const UserService = {
getAvailableTimeZones,
getEComStores,
getPreferredStore,
getUserProfile,
getUserPermissions,
login,
setUserPreference,
setUserTimeZone,
}
16 changes: 6 additions & 10 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 { updateInstanceUrl, updateToken, resetConfig, logout } from '@/adapter'
Expand Down Expand Up @@ -136,16 +136,12 @@
/**
* 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;
},

/**
* Set user's selected Ecom store
Expand Down
30 changes: 4 additions & 26 deletions src/views/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,7 @@
<DxpAppVersionInfo />

<section>
<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" />
</section>
</ion-content>
</ion-page>
Expand All @@ -101,17 +86,14 @@ import {
IonHeader,
IonIcon,
IonItem,
IonLabel,
IonMenuButton,
IonPage,
IonSelect,
IonSelectOption,
IonTitle,
IonToolbar,
modalController } from "@ionic/vue";
IonToolbar } from "@ionic/vue";
import { defineComponent } from "vue";
import { mapGetters } from 'vuex'
import TimeZoneModal from '@/views/timezone-modal.vue'
import Image from '@/components/Image.vue';

export default defineComponent({
Expand All @@ -129,7 +111,6 @@ export default defineComponent({
IonHeader,
IonIcon,
IonItem,
IonLabel,
IonMenuButton,
IonPage,
IonSelect,
Expand Down Expand Up @@ -166,11 +147,8 @@ export default defineComponent({
goToLaunchpad() {
window.location.href = `${process.env.VUE_APP_LOGIN_URL}`
},
async changeTimeZone() {
const timeZoneModal = await modalController.create({
component: TimeZoneModal,
});
return timeZoneModal.present();
async timeZoneUpdated(tzId: string) {
await this.store.dispatch("user/setUserTimeZone", tzId)
},
updateBrand(event: any) {
if(event.detail.value && this.userProfile && this.currentEComStore?.productStoreId !== event.detail.value) {
Expand Down
169 changes: 0 additions & 169 deletions src/views/timezone-modal.vue

This file was deleted.

Loading