Skip to content

Commit

Permalink
Implemented: support to show timeZone of browser and user, renamed co…
Browse files Browse the repository at this point in the history
…mponent to have prefix Dxp and handled case of undefined for setUserLocale method
  • Loading branch information
ymaheshwari1 committed Nov 7, 2023
1 parent 7087eb5 commit ff75460
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ion-label class="ion-text-wrap">
<p class="overline">{{ instanceUrl }}</p>
</ion-label>
<ion-note slot="end">{{ userAppState.userProfile?.userTimeZone }}</ion-note>
<ion-note :color="browserTimeZone === userAppState.userProfile?.userTimeZone ? '' : 'danger'" slot="end">{{ userAppState.userProfile?.userTimeZone }}</ion-note>
</ion-item>
<!-- showing product stores only when there are multiple options to choose from. -->
<ion-item v-if="userAppState.userProfile?.stores?.length > 2" lines="none">
Expand Down Expand Up @@ -50,4 +50,7 @@ const userAppState = computed(() => ({
shopifyConfigs: appState.getters['user/getShopifyConfigs'],
currentShopifyConfig: appState.getters['user/getCurrentShopifyConfig']
}));
// Accessing browser timeZone to check for timeZone diff of the app and browser
const browserTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
</script>
2 changes: 1 addition & 1 deletion src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export { default as DxpImage } from './DxpImage.vue';
export { default as DxpUserProfile } from './DxpUserProfile.vue'
export { default as AppVersionInfo } from './AppVersionInfo.vue';
export { default as LanguageSwitcher } from './LanguageSwitcher.vue';
export { default as MenuFooterNavigation } from './MenuFooterNavigation.vue';
export { default as DxpMenuFooterNavigation } from './DxpMenuFooterNavigation.vue';
export { default as OmsInstanceNavigator } from './OmsInstanceNavigator.vue'
export { default as ProductIdentifier } from "./ProductIdentifier.vue";
export { default as Scanner } from './Scanner.vue';
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ declare var process: any;
import { createPinia } from "pinia";
import { useProductIdentificationStore } from "./store/productIdentification";
import { useAuthStore } from "./store/auth";
import { AppVersionInfo, DxpImage, DxpUserProfile, LanguageSwitcher, MenuFooterNavigation, OmsInstanceNavigator, ProductIdentifier, Scanner, ShopifyImg } from "./components";
import { AppVersionInfo, DxpImage, DxpUserProfile, LanguageSwitcher, DxpMenuFooterNavigation, OmsInstanceNavigator, ProductIdentifier, Scanner, ShopifyImg } from "./components";
import Login from "./components/Login";
import { goToOms, getProductIdentificationValue } from "./utils";
import { initialiseFirebaseApp } from "./utils/firebase"
Expand Down Expand Up @@ -48,7 +48,7 @@ export let dxpComponents = {
app.component('DxpUserProfile', DxpUserProfile)
app.component('LanguageSwitcher', LanguageSwitcher)
app.component('Login', Login)
app.component('MenuFooterNavigation', MenuFooterNavigation)
app.component('DxpMenuFooterNavigation', DxpMenuFooterNavigation)
app.component('OmsInstanceNavigator', OmsInstanceNavigator)
app.component('ProductIdentifier', ProductIdentifier)
app.component('Scanner', Scanner)
Expand Down Expand Up @@ -86,6 +86,7 @@ export {
appContext,
DxpImage,
DxpUserProfile,
DxpMenuFooterNavigation,
getProductIdentificationValue,
goToOms,
i18n,
Expand Down
3 changes: 2 additions & 1 deletion src/store/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export const useUserStore = defineStore('user', {
matchingLocale = matchingLocale || Object.keys(this.localeOptions).find((option: string) => option.slice(0, 2) === locale.slice(0, 2))
newLocale = matchingLocale || this.locale
// update locale in state and globally
await userContext.setUserLocale({ newLocale })
console.log('setting up locale for user', userContext.setUserLocale)
if(userContext.setUserLocale) await userContext.setUserLocale({ newLocale })
}
} catch (error) {
console.error(error)
Expand Down

0 comments on commit ff75460

Please sign in to comment.