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: logic to fetch Product identification from Dxp component (#237) #308

Merged
merged 14 commits into from
Nov 19, 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
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { mapGetters, useStore } from 'vuex';
import { Settings } from 'luxon'
import { initialise, resetConfig } from '@/adapter'
import { useRouter } from 'vue-router';
import { useProductIdentificationStore } from "@hotwax/dxp-components";

export default defineComponent({
name: "App",
Expand All @@ -43,7 +44,8 @@ export default defineComponent({
...mapGetters({
userProfile: 'user/getUserProfile',
userToken: 'user/getUserToken',
instanceUrl: 'user/getInstanceUrl'
instanceUrl: 'user/getInstanceUrl',
currentEComStore: 'user/getCurrentEComStore'
})
},
methods: {
Expand Down Expand Up @@ -101,6 +103,10 @@ export default defineComponent({
if (this.userProfile && this.userProfile.userTimeZone) {
Settings.defaultZone = this.userProfile.userTimeZone;
}

// Get product identification from api using dxp-component
await useProductIdentificationStore().getIdentificationPref(this.currentEComStore?.productStoreId)
.catch((error) => console.error(error));
},
unmounted() {
emitter.off('presentLoader', this.presentLoader);
Expand Down
4 changes: 3 additions & 1 deletion src/adapter/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { api, client, getConfig, initialise, logout, resetConfig, updateInstanceUrl, updateToken, setUserTimeZone, getAvailableTimeZones, setUserLocale } from '@hotwax/oms-api'
import { api, client, getConfig, getProductIdentificationPref, initialise, logout, resetConfig, setProductIdentificationPref, updateInstanceUrl, updateToken, setUserTimeZone, getAvailableTimeZones, setUserLocale } from '@hotwax/oms-api'

export {
api,
client,
getConfig,
getProductIdentificationPref,
initialise,
logout,
resetConfig,
setProductIdentificationPref,
updateInstanceUrl,
updateToken,
setUserLocale,
Expand Down
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ import { login, logout, loader } from './user-utils';
import permissionPlugin, { Actions, hasPermission } from '@/authorization';
import permissionRules from '@/authorization/Rules';
import permissionActions from '@/authorization/Actions';
import { getConfig, initialise, setUserTimeZone, getAvailableTimeZones, setUserLocale} from '@/adapter'
import { setUserTimeZone, getAvailableTimeZones, setUserLocale} from '@/adapter'
import localeMessages from './i18n/locales';
import { getConfig, getProductIdentificationPref, initialise, setProductIdentificationPref } from '@/adapter'

const app = createApp(App)
.use(IonicVue, {
Expand All @@ -60,6 +61,8 @@ const app = createApp(App)
setUserLocale,
setUserTimeZone,
getAvailableTimeZones,
getProductIdentificationPref,
setProductIdentificationPref,
hasPermission
});

Expand Down
34 changes: 27 additions & 7 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
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'
import { useAuthStore } from '@hotwax/dxp-components';
import { useAuthStore, useProductIdentificationStore } from '@hotwax/dxp-components';
import { getServerPermissionsFromRules, prepareAppPermissions, resetPermissions, setPermissions } from '@/authorization'
import emitter from '@/event-bus'

Expand All @@ -21,13 +21,13 @@
const { token, oms } = payload;
dispatch("setUserInstanceUrl", oms);
try {
if (token) {
// Getting the permissions list from server
const permissionId = process.env.VUE_APP_PERMISSION_ID;
if (token) {
// Getting the permissions list from server
const permissionId = process.env.VUE_APP_PERMISSION_ID;

// Prepare permissions list
const serverPermissionsFromRules = getServerPermissionsFromRules();
if (permissionId) serverPermissionsFromRules.push(permissionId);
// Prepare permissions list
const serverPermissionsFromRules = getServerPermissionsFromRules();
if (permissionId) serverPermissionsFromRules.push(permissionId);

const serverPermissions = await UserService.getUserPermissions({
permissionIds: [...new Set(serverPermissionsFromRules)]
Expand Down Expand Up @@ -74,7 +74,23 @@
commit(types.USER_TOKEN_CHANGED, { newToken: token });
commit(types.USER_PERMISSIONS_UPDATED, appPermissions);
updateToken(token);

// Get product identification from api using dxp-component
await useProductIdentificationStore().getIdentificationPref(preferredStoreId)
.catch((error) => console.error(error));

setPermissions(appPermissions);
if (userProfile.userTimeZone) {
Settings.defaultZone = userProfile.userTimeZone;
}

// TODO user single mutation
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, preferredStore);
commit(types.USER_INFO_UPDATED, userProfile);
commit(types.USER_TOKEN_CHANGED, { newToken: token });
commit(types.USER_PERMISSIONS_UPDATED, appPermissions);
updateToken(token);
}
} catch (err: any) {
showToast(translate('Something went wrong'));
console.error("error", err);
Expand Down Expand Up @@ -157,6 +173,10 @@
'userPrefTypeId': 'SELECTED_BRAND',
'userPrefValue': payload.eComStore.productStoreId
});

// Get product identification from api using dxp-component
await useProductIdentificationStore().getIdentificationPref(payload.eComStore.productStoreId)
.catch((error) => console.error(error));
},

/**
Expand Down
15 changes: 10 additions & 5 deletions src/views/catalog-product-details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

<div class="product-info" v-if="Object.keys(currentVariant).length">
<div class="ion-padding">
<h4>{{ currentVariant.parentProductName }}</h4>
<p>{{ currentVariant.sku }}</p>
<h4>{{ getProductIdentificationValue(productIdentificationPref.primaryId, currentVariant) ? getProductIdentificationValue(productIdentificationPref.primaryId, currentVariant) : currentVariant.productName }}</h4>
<p>{{ getProductIdentificationValue(productIdentificationPref.secondaryId, currentVariant) }}</p>
</div>

<div class="product-features">
Expand Down Expand Up @@ -386,7 +386,7 @@ import {
IonRow,
popoverController,
} from "@ionic/vue";
import { defineComponent } from "vue";
import { computed, defineComponent } from "vue";
import {
alertCircleOutline,
checkmarkCircleOutline,
Expand All @@ -395,7 +395,7 @@ import {
shirtOutline
} from "ionicons/icons";
import { useStore } from "@/store";
import { DxpShopifyImg } from "@hotwax/dxp-components";
import { getProductIdentificationValue, DxpShopifyImg, useProductIdentificationStore } from "@hotwax/dxp-components";
import { mapGetters } from "vuex";
import { showToast, getFeature, hasError } from "@/utils";
import { translate } from "@/i18n";
Expand Down Expand Up @@ -434,7 +434,7 @@ export default defineComponent({
IonToggle,
IonToolbar,
IonTitle,
IonRow,
IonRow
},
data() {
return {
Expand Down Expand Up @@ -1120,13 +1120,18 @@ export default defineComponent({
setup() {
const store = useStore();
const router = useRouter();
const productIdentificationStore = useProductIdentificationStore();
let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref)

return {
alertCircleOutline,
Actions,
checkmarkCircleOutline,
chevronForwardOutline,
copyOutline,
getProductIdentificationValue,
hasPermission,
productIdentificationPref,
router,
shirtOutline,
store
Expand Down
12 changes: 8 additions & 4 deletions src/views/catalog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
<DxpShopifyImg :src="product.mainImageUrl" size="small"/>
</ion-thumbnail>
<ion-label class="ion-text-wrap">
<h5>{{ product.parentProductName }}</h5>
<p>{{ product.sku }}</p>
<h5>{{ getProductIdentificationValue(productIdentificationPref.primaryId, product) ? getProductIdentificationValue(productIdentificationPref.primaryId, product) : product.productName }}</h5>
<p>{{ getProductIdentificationValue(productIdentificationPref.secondaryId, product) }}</p>
</ion-label>
</ion-item>

Expand Down Expand Up @@ -106,10 +106,10 @@ import {
IonTitle,
IonToolbar,
} from '@ionic/vue';
import { defineComponent } from 'vue';
import { computed, defineComponent } from 'vue';
import { useRouter } from "vue-router";
import { useStore } from "@/store";
import { DxpShopifyImg } from '@hotwax/dxp-components';
import { getProductIdentificationValue, DxpShopifyImg, useProductIdentificationStore } from '@hotwax/dxp-components';
import { mapGetters } from 'vuex';
import { DateTime } from 'luxon';
import { JobService } from '@/services/JobService';
Expand Down Expand Up @@ -290,8 +290,12 @@ export default defineComponent({
setup() {
const router = useRouter();
const store = useStore();
const productIdentificationStore = useProductIdentificationStore();
let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref)

return {
getProductIdentificationValue,
productIdentificationPref,
router,
store,
};
Expand Down
23 changes: 14 additions & 9 deletions src/views/orders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
<DxpShopifyImg :src="getProduct(item.productId).mainImageUrl" size="small"></DxpShopifyImg>
</ion-thumbnail>
<ion-label>
<h2>{{ item.parentProductName ? item.parentProductName :item.productName }}</h2>
<h2>{{ getProductIdentificationValue(productIdentificationPref.primaryId, item) ? getProductIdentificationValue(productIdentificationPref.primaryId, item) : item.productName }}</h2>
<p v-if="$filters.getFeature(getProduct(item.productId).featureHierarchy, '1/COLOR/')">{{ $t("Color") }} : {{ $filters.getFeature(getProduct(item.productId).featureHierarchy, '1/COLOR/') }}</p>
<p v-if="$filters.getFeature(getProduct(item.productId).featureHierarchy, '1/SIZE/')">{{ $t("Size") }} : {{ $filters.getFeature(getProduct(item.productId).featureHierarchy, '1/SIZE/') }}</p>
</ion-label>
Expand Down Expand Up @@ -208,7 +208,7 @@ import {
modalController,
popoverController,
} from "@ionic/vue";
import { defineComponent } from "vue";
import { computed, defineComponent } from "vue";
import WarehouseModal from "./warehouse-modal.vue";
import BackgroundJobModal from "./background-job-modal.vue";
import PromiseDateModal from "./promise-date-modal.vue";
Expand All @@ -228,7 +228,7 @@ import { useStore } from "@/store";
import { mapGetters } from "vuex";
import { showToast } from '@/utils'
import { Plugins } from '@capacitor/core';
import { DxpShopifyImg } from "@hotwax/dxp-components";
import { getProductIdentificationValue, DxpShopifyImg, useProductIdentificationStore } from "@hotwax/dxp-components";
import emitter from "@/event-bus";

const { Clipboard } = Plugins;
Expand Down Expand Up @@ -504,17 +504,22 @@ export default defineComponent({
},
setup() {
const store = useStore();
const productIdentificationStore = useProductIdentificationStore();
let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref)

return {
store,
pricetag,
ribbon,
ellipsisVertical,
send,
business,
calendar,
close,
closeCircle,
ellipsisVertical,
getProductIdentificationValue,
hourglass,
close,
pricetag,
productIdentificationPref,
ribbon,
send,
store
};
},
});
Expand Down
10 changes: 7 additions & 3 deletions src/views/product-details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<div class="product-info">
<ion-item lines="none" class="product-title">
<h1>{{ current.product.productName }}</h1>
<h1>{{ getProductIdentificationValue(productIdentificationPref.primaryId, current.product) ? getProductIdentificationValue(productIdentificationPref.primaryId, current.product) : current.product.productName }}</h1>
</ion-item>
<div class="product-features">
<ion-list v-if="$filters.getFeaturesList(current.product.featureHierarchy, '1/COLOR/').length">
Expand Down Expand Up @@ -193,7 +193,7 @@ import {
alertController,
modalController,
} from "@ionic/vue";
import { defineComponent } from "vue";
import { computed, defineComponent } from "vue";
import {
informationCircle,
send,
Expand All @@ -211,7 +211,7 @@ import BackgroundJobModal from "./background-job-modal.vue";
import { useStore } from "@/store";
import { mapGetters } from "vuex";
import { ProductService } from '@/services/ProductService'
import { DxpShopifyImg } from "@hotwax/dxp-components";
import { getProductIdentificationValue, DxpShopifyImg, useProductIdentificationStore } from "@hotwax/dxp-components";
import { sizeIndex } from "@/apparel-sorter"
import { DateTime } from 'luxon';
import emitter from "@/event-bus";
Expand Down Expand Up @@ -577,15 +577,19 @@ export default defineComponent({
},
setup() {
const store = useStore();
const productIdentificationStore = useProductIdentificationStore();
let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref)
return {
informationCircle,
send,
business,
closeCircle,
getProductIdentificationValue,
hourglass,
calendar,
close,
list,
productIdentificationPref,
ribbon,
refresh,
store
Expand Down
14 changes: 9 additions & 5 deletions src/views/products.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<DxpShopifyImg :src="getProduct(product.groupValue).mainImageUrl" size="small"></DxpShopifyImg>
</ion-thumbnail>
<ion-label>
<h2>{{ getProduct(product.groupValue).productName}}</h2>
<h2>{{ getProductIdentificationValue(productIdentificationPref.primaryId, getProduct(product.groupValue)) ? getProductIdentificationValue(productIdentificationPref.primaryId, getProduct(product.groupValue)) : getProduct(product.groupValue).productName }}</h2>
<p v-for="(attribute, feature) in ($filters.groupFeatures(getProduct(product.groupValue).featureHierarchy))" :key="attribute" ><span class="sentence-case">{{ feature }}</span>: {{ attribute }}</p>
</ion-label>
<ion-badge slot="end" color="success">{{ product.doclist.numFound }} {{ $t("pieces preordered") }}</ion-badge>
Expand Down Expand Up @@ -66,13 +66,13 @@ import {
IonToolbar,
modalController,
} from "@ionic/vue";
import { defineComponent } from "vue";
import { computed, defineComponent } from "vue";
import { hourglass } from "ionicons/icons";
import { useRouter } from "vue-router";
import BackgroundJobModal from "./background-job-modal.vue";
import { useStore } from "@/store";
import { mapGetters } from "vuex";
import { DxpShopifyImg } from "@hotwax/dxp-components";
import { getProductIdentificationValue, DxpShopifyImg, useProductIdentificationStore } from "@hotwax/dxp-components";

export default defineComponent({
name: "settings",
Expand Down Expand Up @@ -178,10 +178,14 @@ export default defineComponent({
setup() {
const router = useRouter();
const store = useStore();
const productIdentificationStore = useProductIdentificationStore();
let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref)
return {
router,
store,
getProductIdentificationValue,
hourglass,
productIdentificationPref,
router,
store
};
},
});
Expand Down
4 changes: 3 additions & 1 deletion src/views/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<DxpAppVersionInfo />

<section>
<DxpProductIdentifier />
<DxpTimeZoneSwitcher @timeZoneUpdated="timeZoneUpdated" />
</section>
</ion-content>
Expand Down Expand Up @@ -95,6 +96,7 @@
import { defineComponent } from "vue";
import { mapGetters } from 'vuex'
import Image from '@/components/Image.vue';
import { DxpProductIdentifier } from '@hotwax/dxp-components';

Check warning on line 99 in src/views/settings.vue

View workflow job for this annotation

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

'DxpProductIdentifier' is defined but never used

Check warning on line 99 in src/views/settings.vue

View workflow job for this annotation

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

'DxpProductIdentifier' is defined but never used

export default defineComponent({
name: "settings",
Expand Down Expand Up @@ -180,4 +182,4 @@
align-items: center;
padding: var(--spacer-xs) 10px 0px;
}
</style>
</style>
Loading