Skip to content

Commit

Permalink
Improved: code by removing locale state related code
Browse files Browse the repository at this point in the history
  • Loading branch information
k2maan committed Oct 4, 2023
1 parent d9689e7 commit c74d8ef
Show file tree
Hide file tree
Showing 12 changed files with 288 additions and 215 deletions.
464 changes: 275 additions & 189 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 @@ -17,8 +17,8 @@
"@casl/ability": "^6.0.0",
"@hotwax/app-version-info": "^1.0.0",
"@hotwax/apps-theme": "^1.1.0",
"@hotwax/dxp-components": "^1.7.0",
"@hotwax/oms-api": "^1.9.0",
"@hotwax/dxp-components": "file:../../Ionic SDK/ionic-sdk",
"@hotwax/oms-api": "file:../../OMS API/oms-api",
"@ionic/core": "6.7.5",
"@ionic/vue": "6.7.5",
"@ionic/vue-router": "6.7.5",
Expand Down
1 change: 0 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export default defineComponent({
},
computed: {
...mapGetters({
locale: 'user/getLocale',
userToken: 'user/getUserToken',
instanceUrl: 'user/getInstanceUrl'
})
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, hasError, initialise, resetConfig, updateInstanceUrl, updateToken } from '@hotwax/oms-api'
import { api, client, getConfig, hasError, initialise, resetConfig, updateInstanceUrl, updateToken, getUserPreference, setUserPreference } from '@hotwax/oms-api'

export {
api,
Expand All @@ -8,5 +8,7 @@ export {
hasError,
resetConfig,
updateInstanceUrl,
updateToken
updateToken,
getUserPreference,
setUserPreference
}
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { dxpComponents } from '@hotwax/dxp-components'
import { login, logout, loader } from './user-utils';
import localeMessages from './locales';
import { getConfig, initialise } from './adapter';
import { getUserPreference, setUserPreference } from '@/adapter';

const app = createApp(App)
.use(IonicVue, {
Expand All @@ -53,7 +54,9 @@ const app = createApp(App)
appLoginUrl: process.env.VUE_APP_LOGIN_URL as string,
localeMessages,
getConfig,
initialise
initialise,
getUserPreference,
setUserPreference
});

// Filters are removed in Vue 3 and global filter introduced https://v3.vuejs.org/guide/migration/filters.html#global-filters
Expand Down
1 change: 0 additions & 1 deletion src/store/modules/user/UserState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export default interface UserState {
currentFacility: object;
instanceUrl: string;
preference: any;
locale: string;
permissions: any;
currentEComStore: any;
}
6 changes: 1 addition & 5 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@ const actions: ActionTree<UserState, RootState> = {
'userPrefTypeId': 'BOPIS_PREFERENCE',
'userPrefValue': JSON.stringify(state.preference)
});
},

setLocale({ commit }, payload) {
commit(types.USER_LOCALE_UPDATED, payload)
},
}
}
export default actions;
3 changes: 0 additions & 3 deletions src/store/modules/user/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ const getters: GetterTree <UserState, RootState> = {
showPackingSlip (state) {
return state.preference.showPackingSlip;
},
getLocale (state) {
return state.locale;
},
getCurrency (state) {
return state.currentEComStore.defaultCurrencyUomId ? state.currentEComStore.defaultCurrencyUomId : 'USD';
},
Expand Down
1 change: 0 additions & 1 deletion src/store/modules/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const userModule: Module<UserState, RootState> = {
showPackingSlip: false,
configurePicker: false,
},
locale: 'en',
currentEComStore: {},
permissions: [],
},
Expand Down
1 change: 0 additions & 1 deletion src/store/modules/user/mutation-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ export const USER_INFO_UPDATED = SN_USER + '/INFO_UPDATED'
export const USER_CURRENT_FACILITY_UPDATED = SN_USER + '/CURRENT_FACILITY_UPDATED'
export const USER_INSTANCE_URL_UPDATED = SN_USER + '/INSTANCE_URL_UPDATED'
export const USER_PREFERENCE_UPDATED = SN_USER + '/PREFERENCE_UPDATED'
export const USER_LOCALE_UPDATED = SN_USER + '/LOCALE_UPDATED'
export const USER_CURRENT_ECOM_STORE_UPDATED = SN_USER + '/CURRENT_ECOM_STORE_UPDATED'
export const USER_PERMISSIONS_UPDATED = SN_USER + '/PERMISSIONS_UPDATED'
3 changes: 0 additions & 3 deletions src/store/modules/user/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ const mutations: MutationTree <UserState> = {
[types.USER_PREFERENCE_UPDATED] (state, payload) {
state.preference = {...state.preference, ...payload};
},
[types.USER_LOCALE_UPDATED] (state, payload) {
state.locale = payload;
},
[types.USER_CURRENT_ECOM_STORE_UPDATED] (state, payload) {
state.currentEComStore = payload
},
Expand Down
8 changes: 2 additions & 6 deletions src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@

<script lang="ts">
import { IonAvatar, IonButton, IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, IonContent, IonHeader, IonIcon, IonItem, IonLabel, IonPage, IonSelect, IonSelectOption, IonTitle, IonToggle , IonToolbar, modalController } from '@ionic/vue';
import { computed, defineComponent } from 'vue';
import { defineComponent } from 'vue';
import { ellipsisVertical, personCircleOutline, sendOutline , storefrontOutline, codeWorkingOutline, openOutline } from 'ionicons/icons'
import { mapGetters, useStore } from 'vuex';
import { useRouter } from 'vue-router';
Expand All @@ -196,7 +196,7 @@ import { DateTime } from 'luxon';
import { UserService } from '@/services/UserService'
import { showToast } from '@/utils';
import { hasError } from '@/adapter'
import { translate, useUserStore } from "@hotwax/dxp-components";
import { translate } from "@hotwax/dxp-components";
import { Actions, hasPermission } from '@/authorization'
export default defineComponent({
Expand Down Expand Up @@ -386,9 +386,6 @@ export default defineComponent({
setup () {
const store = useStore();
const router = useRouter();
const userStore = useUserStore();
const locale = computed(() => userStore.getLocale);
return {
Actions,
Expand All @@ -401,7 +398,6 @@ export default defineComponent({
storefrontOutline,
codeWorkingOutline,
openOutline,
locale,
translate
}
}
Expand Down

0 comments on commit c74d8ef

Please sign in to comment.