Skip to content

Commit

Permalink
Implemented: logic to search product based on identifier selected in …
Browse files Browse the repository at this point in the history
…barcode identifier preference (hotwax#325)
  • Loading branch information
amansinghbais committed Jul 17, 2024
1 parent 2b1e1d5 commit 8a5c08d
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"Pending: items": "Pending: {itemsCount} items",
"Please provide a valid SKU.": "Please provide a valid SKU.",
"primary identifier": "primary identifier",
"Primary identifier": "Primary identifier",
"Primary Product Identifier": "Primary Product Identifier",
"Proceed": "Proceed",
"Product Identifier": "Product Identifier",
Expand Down Expand Up @@ -104,6 +105,7 @@
"Scanned item is not present within the shipment:": "Scanned item is not present within the shipment: {itemName}",
"Scanned successfully.": "Scanned {itemName} successfully.",
"secondary identifier": "secondary identifier",
"Secondary identifier": "Secondary identifier",
"Search": "Search",
"Search purchase orders": "Search purchase orders",
"Search returns": "Search returns",
Expand Down
11 changes: 9 additions & 2 deletions src/store/modules/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import RootState from '@/store/RootState'
import OrderState from './OrderState'
import * as types from './mutation-types'
import { hasError, showToast } from '@/utils'
import { translate } from '@hotwax/dxp-components'
import { getProductIdentificationValue, translate } from '@hotwax/dxp-components'
import emitter from "@/event-bus";
import store from "@/store";


const actions: ActionTree<OrderState, RootState> = {
Expand Down Expand Up @@ -41,7 +42,13 @@ const actions: ActionTree<OrderState, RootState> = {
return resp;
},
async updateProductCount({ commit, state }, payload ) {
const item = state.current.items.find((item: any) => item.internalName === payload);
const barcodeIdentifier = store.getters['util/getBarcodeIdentificationValue'];
const getProduct = store.getters['product/getProduct'];

const item = state.current.items.find((item: any) => {
const itemVal = barcodeIdentifier ? getProductIdentificationValue(barcodeIdentifier, getProduct(item.productId)) : item.internalName;
return itemVal === payload;
});

if (item) {
if(item.orderItemStatusId === 'ITEM_COMPLETED') return { isCompleted: true }
Expand Down
11 changes: 9 additions & 2 deletions src/store/modules/return/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import RootState from '@/store/RootState'
import ReturnState from './ReturnState'
import * as types from './mutation-types'
import { hasError, showToast } from '@/utils'
import { translate } from '@hotwax/dxp-components'
import { getProductIdentificationValue, translate } from '@hotwax/dxp-components'
import emitter from '@/event-bus'
import store from "@/store";

const actions: ActionTree<ReturnState, RootState> = {
async findReturn ({ commit, state }, payload) {
Expand Down Expand Up @@ -33,7 +34,13 @@ const actions: ActionTree<ReturnState, RootState> = {
return resp;
},
async updateReturnProductCount ({ commit, state }, payload) {
const item = state.current.items.find((item: any) => item.sku === payload);
const barcodeIdentifier = store.getters['util/getBarcodeIdentificationValue'];
const getProduct = store.getters['product/getProduct'];

const item = state.current.items.find((item: any) => {
const itemVal = barcodeIdentifier ? getProductIdentificationValue(barcodeIdentifier, getProduct(item.productId)) : item.internalName;
return itemVal === payload;
});

if (item) {
item.quantityAccepted = item.quantityAccepted ? parseInt(item.quantityAccepted) + 1 : 1;
Expand Down
11 changes: 9 additions & 2 deletions src/store/modules/shipment/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import RootState from '@/store/RootState'
import ShipmentState from './ShipmentState'
import * as types from './mutation-types'
import { hasError, showToast } from '@/utils'
import { translate } from '@hotwax/dxp-components'
import { getProductIdentificationValue, translate } from '@hotwax/dxp-components'
import emitter from '@/event-bus'
import store from "@/store";

const actions: ActionTree<ShipmentState, RootState> = {
async findShipment ({ commit, state }, payload) {
Expand Down Expand Up @@ -43,7 +44,13 @@ const actions: ActionTree<ShipmentState, RootState> = {
},

async updateShipmentProductCount ({ commit, state }, payload) {
const item = state.current.items.find((item: any) => item.sku === payload);
const barcodeIdentifier = store.getters['util/getBarcodeIdentificationValue'];
const getProduct = store.getters['product/getProduct'];

const item = state.current.items.find((item: any) => {
const itemVal = barcodeIdentifier ? getProductIdentificationValue(barcodeIdentifier, getProduct(item.productId)) : item.internalName;
return itemVal === payload;
});

if (item) {
item.quantityAccepted = item.quantityAccepted ? parseInt(item.quantityAccepted) + 1 : 1;
Expand Down
4 changes: 2 additions & 2 deletions src/store/modules/util/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ const actions: ActionTree<UtilState, RootState> = {
fromDate,
"productStoreId": ecomStore.productStoreId,
"settingTypeEnumId": "BARCODE_IDEN_PREF",
"settingValue": "productId"
"settingValue": "primaryId"
}

await UtilService.createBarcodeIdentificationPref(params) as any
Expand All @@ -216,7 +216,7 @@ const actions: ActionTree<UtilState, RootState> = {

// not checking for resp success and fail case as every time we need to update the state with the
// default value when creating a scan setting
commit(types.UTIL_BARCODE_IDENTIFICATION_PREF_UPDATED, "productId")
commit(types.UTIL_BARCODE_IDENTIFICATION_PREF_UPDATED, "primaryId")
return fromDate;
},

Expand Down
5 changes: 4 additions & 1 deletion src/store/modules/util/getters.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GetterTree } from 'vuex'
import RootState from '@/store/RootState'
import RootState from '../../RootState'
import UtilState from './UtilState';

const getters: GetterTree <UtilState, RootState> = {
Expand All @@ -14,6 +14,9 @@ const getters: GetterTree <UtilState, RootState> = {
},
getBarcodeIdentificationPref(state) {
return state.barcodeIdentificationPref
},
getBarcodeIdentificationValue(state, getters, rootState, rootGetters) {
return rootGetters['user/getProductIdentificationPref'][state.barcodeIdentificationPref]
}
}
export default getters;
3 changes: 2 additions & 1 deletion src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@
</ion-item>
<ion-item lines="none">
<ion-select :label="translate('Barcode Identifier')" interface="popover" :placeholder="translate('Select')" :value="barcodeIdentificationPref" @ionChange="setBarcodeIdentificationPref($event.detail.value)">
<ion-select-option v-for="identification in productIdentifications" :key="identification">{{ identification }}</ion-select-option>
<ion-select-option value="primaryId">{{ translate("Primary identifier") }}</ion-select-option>
<ion-select-option value="secondaryId">{{ translate("Secondary identifier") }}</ion-select-option>
</ion-select>
</ion-item>
</ion-card>
Expand Down

0 comments on commit 8a5c08d

Please sign in to comment.