Skip to content

Commit

Permalink
Merge pull request #294 from ymaheshwari1/fix/items-not-rendered-inve…
Browse files Browse the repository at this point in the history
…ntory-page

Fixed: issue when rendering products information on the inventory review page
  • Loading branch information
ymaheshwari1 authored Jun 26, 2024
2 parents c6d12d5 + 3eba720 commit 9327121
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/store/modules/stock/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,20 @@ const actions: ActionTree<StockState, RootState> = {
identificationTypeId: items[0]?.identificationTypeId //fetching identificationTypeId from first item, as all the items will have one identification type
}
const cachedProducts = await store.dispatch("product/fetchProducts", payload);

// creating products object based on identification selected, if not doing so, and if we select an identification that is not equal to pseudoId of the product then the products are not displayed
const products: any = Object.values(cachedProducts).reduce((updatedProducts: any, product: any) => {
const identification = product.identifications.find((identification: any) => payload.identificationTypeId.toLowerCase() === identification.productIdTypeEnumId.toLowerCase())
updatedProducts[identification.idValue] = product
return updatedProducts;
}, {})

const parsed = [] as any;
const initial = items.map((item: any) => {
const product = cachedProducts[item.identification];
const facilityLocation = rootGetters['util/getFacilityLocationsByFacilityId'](item.externalFacilityId)?.[0];
const product = products[item.identification];
// Getting facilityId using externalFacilityId as the locations are saved by using facilityId as key
const facilityId = facilityMapping[item.externalFacilityId]
const facilityLocation = facilityId ? rootGetters['util/getFacilityLocationsByFacilityId'](facilityId)?.[0] : '';
item.locationSeqId = facilityLocation?.locationSeqId;
parsed.push(item);

Expand Down

0 comments on commit 9327121

Please sign in to comment.