Skip to content

Commit

Permalink
Implemented: app version component from the dxp-components (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
amansinghbais committed Jul 16, 2024
1 parent d6f4e3e commit 31b4cfa
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 23 deletions.
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import store from './store'
import { dxpComponents } from "@hotwax/dxp-components"
import { login, logout, loader } from "@/user-utils";
import { getConfig, initialise } from '@/adapter';
import localeMessages from './locales';


const app = createApp(App)
Expand All @@ -52,7 +53,8 @@ const app = createApp(App)
loader,
appLoginUrl: process.env.VUE_APP_LOGIN_URL as string,
getConfig,
initialise
initialise,
localeMessages
});

// Filters are removed in Vue 3 and global filter introduced https://v3.vuejs.org/guide/migration/filters.html#global-filters
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/user/UserState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export default interface UserState {
url: string;
token: string;
}
pwaState: any;
}
4 changes: 4 additions & 0 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ const actions: ActionTree<UserState, RootState> = {
productStore = (state.current as any).stores.find((store: any) => store.productStoreId === payload.productStoreId);
}
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, productStore);
},

updatePwaState({ commit }, payload) {
commit(types.USER_PWA_STATE_UPDATED, payload);
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/store/modules/user/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ const getters: GetterTree <UserState, RootState> = {
},
getOmsRedirectionInfo(state) {
return state.omsRedirectionInfo;
}
},
getPwaState(state) {
return state.pwaState;
},
}
export default getters;
4 changes: 4 additions & 0 deletions src/store/modules/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const userModule: Module<UserState, RootState> = {
omsRedirectionInfo: {
url: "",
token: ""
},
pwaState: {
updateExists: false,
registration: null,
}
},
getters,
Expand Down
3 changes: 2 additions & 1 deletion src/store/modules/user/mutation-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export const USER_END_SESSION = SN_USER + '/END_SESSION'
export const USER_INFO_UPDATED = SN_USER + '/INFO_UPDATED'
export const USER_INSTANCE_URL_UPDATED = SN_USER + '/INSTANCE_URL_UPDATED'
export const USER_CURRENT_ECOM_STORE_UPDATED = SN_USER + '/CURRENT_ECOM_STORE_UPDATED'
export const USER_OMS_REDIRECTION_INFO_UPDATED = SN_USER + '/OMS_REDIRECTION_INFO_UPDATED'
export const USER_OMS_REDIRECTION_INFO_UPDATED = SN_USER + '/OMS_REDIRECTION_INFO_UPDATED'
export const USER_PWA_STATE_UPDATED = SN_USER + '/PWA_STATE_UPDATED'
6 changes: 5 additions & 1 deletion src/store/modules/user/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ const mutations: MutationTree <UserState> = {
},
[types.USER_OMS_REDIRECTION_INFO_UPDATED](state, payload) {
state.omsRedirectionInfo = payload;
}
},
[types.USER_PWA_STATE_UPDATED](state, payload) {
state.pwaState.registration = payload.registration;
state.pwaState.updateExists = payload.updateExists;
},
}
export default mutations;
21 changes: 2 additions & 19 deletions src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,7 @@
</section>
<hr />

<div class="section-header">
<h1>
{{ translate("App") }}
<p class="overline" >{{ translate("Version: ", { appVersion }) }}</p>
</h1>
<p class="overline">{{ translate("Built: ", { builtDateTime: getDateTime(appInfo.builtTime) }) }}</p>
</div>
<DxpAppVersionInfo />

<section>
<ion-card>
Expand All @@ -102,28 +96,21 @@

<script setup lang="ts">
import { IonAvatar, IonButton, IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, IonContent, IonHeader, IonIcon, IonItem, IonLabel, IonMenuButton, IonPage, IonSelect, IonSelectOption, IonTitle, IonToolbar, modalController } from '@ionic/vue';
import { computed, onMounted, ref } from 'vue';
import { computed } from 'vue';
import { openOutline } from 'ionicons/icons'
import { useStore } from 'vuex';
import TimeZoneModal from '@/views/TimezoneModal.vue';
import Image from '@/components/Image.vue'
import { DateTime } from "luxon";
import { translate } from '@/i18n';
import { goToOms } from "@hotwax/dxp-components";
const store = useStore()
const appVersion = ref("")
const appInfo = (process.env.VUE_APP_VERSION_INFO ? JSON.parse(process.env.VUE_APP_VERSION_INFO) : {}) as any
const userProfile = computed(() => store.getters["user/getUserProfile"])
const currentEComStore = computed(() => store.getters["user/getCurrentEComStore"])
const oms = computed(() => store.getters["user/getInstanceUrl"])
const omsRedirectionInfo = computed(() => store.getters["user/getOmsRedirectionInfo"])
onMounted(() => {
appVersion.value = appInfo.branch ? (appInfo.branch + "-" + appInfo.revision) : appInfo.tag;
})
function setEComStore(event: CustomEvent) {
if(userProfile.value?.stores) {
store.dispatch("user/setEcomStore", {
Expand All @@ -147,10 +134,6 @@ function logout() {
})
}
function getDateTime(time: any) {
return time ? DateTime.fromMillis(time).toLocaleString(DateTime.DATETIME_MED) : "";
}
function goToLaunchpad() {
window.location.href = `${process.env.VUE_APP_LOGIN_URL}`
}
Expand Down

0 comments on commit 31b4cfa

Please sign in to comment.