Skip to content

Commit

Permalink
Improved: code for handling when product dont have primaryId item (dx…
Browse files Browse the repository at this point in the history
…p/178)
  • Loading branch information
amansinghbais committed Oct 5, 2023
1 parent 4efbc9c commit 5d5aa7a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default defineComponent({
// Get product identification from api using dxp-component and set the state if eComStore is defined
if (this.currentEComStore.productStoreId) {
await useProductIdentificationStore().getIdentificationPref(this.currentEComStore.productStoreId)
.catch((error) => console.error(error));
.catch((error) => console.error(error));
}
},
unmounted() {
Expand Down
10 changes: 4 additions & 6 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ const actions: ActionTree<UserState, RootState> = {
if (preferredStoreId) {
const store = userProfile.stores.find((store: any) => store.productStoreId === preferredStoreId);
store && (preferredStore = store)

// Get product identification from api using dxp-component and set the state if eComStore is defined
await useProductIdentificationStore().getIdentificationPref(preferredStoreId)
.catch((error) => console.error(error));
}

setPermissions(appPermissions);
Expand All @@ -72,12 +76,6 @@ const actions: ActionTree<UserState, RootState> = {
commit(types.USER_TOKEN_CHANGED, { newToken: token });
commit(types.USER_PERMISSIONS_UPDATED, appPermissions);
updateToken(token);

// Get product identification from api using dxp-component and set the state if eComStore is defined
if (preferredStoreId){
await useProductIdentificationStore().getIdentificationPref(preferredStoreId)
.catch((error) => console.error(error));
}
}
} catch (err: any) {
showToast(translate('Something went wrong'));
Expand Down
2 changes: 1 addition & 1 deletion src/views/catalog-product-details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

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

Expand Down
2 changes: 1 addition & 1 deletion src/views/catalog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<ShopifyImg :src="product.mainImageUrl" size="small"/>
</ion-thumbnail>
<ion-label class="ion-text-wrap">
<h5>{{ getProductIdentificationValue(productIdentificationPref.primaryId, product) }}</h5>
<h5>{{ getProductIdentificationValue(productIdentificationPref.primaryId, product) ? getProductIdentificationValue(productIdentificationPref.primaryId, product) : product.productName }}</h5>
<p>{{ getProductIdentificationValue(productIdentificationPref.secondaryId, product) }}</p>
</ion-label>
</ion-item>
Expand Down
2 changes: 1 addition & 1 deletion src/views/orders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<ShopifyImg :src="getProduct(item.productId).mainImageUrl" size="small"></ShopifyImg>
</ion-thumbnail>
<ion-label>
<h2>{{ getProductIdentificationValue(productIdentificationPref.primaryId, item) }}</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
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 @@ -195,7 +195,7 @@ import {
alertController,
modalController,
} from "@ionic/vue";
import { defineComponent } from "vue";
import { computed, defineComponent } from "vue";
import {
informationCircle,
send,
Expand All @@ -213,7 +213,7 @@ import BackgroundJobModal from "./background-job-modal.vue";
import { useStore } from "@/store";
import { mapGetters } from "vuex";
import { ProductService } from '@/services/ProductService'
import { ShopifyImg } from "@hotwax/dxp-components";
import { getProductIdentificationValue, ShopifyImg, useProductIdentificationStore } from "@hotwax/dxp-components";
import { sizeIndex } from "@/apparel-sorter"
import { DateTime } from 'luxon';
import emitter from "@/event-bus";
Expand Down Expand Up @@ -576,15 +576,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 @@
<ShopifyImg :src="getProduct(product.groupValue).mainImageUrl" size="small"></ShopifyImg>
</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 { ShopifyImg } from "@hotwax/dxp-components";
import { getProductIdentificationValue, ShopifyImg, useProductIdentificationStore } from "@hotwax/dxp-components";
export default defineComponent({
name: "settings",
Expand Down Expand Up @@ -159,10 +159,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

0 comments on commit 5d5aa7a

Please sign in to comment.