tango-app-api-store-builder 1.0.17 → 1.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-store-builder",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -32,7 +32,7 @@
32
32
  "path": "^0.12.7",
33
33
  "selenium-webdriver": "^4.31.0",
34
34
  "sharp": "^0.34.1",
35
- "tango-api-schema": "^2.5.11",
35
+ "tango-api-schema": "^2.5.13",
36
36
  "tango-app-api-middleware": "3.1.48",
37
37
  "url": "^0.11.4",
38
38
  "winston": "^3.17.0",
@@ -14503,8 +14503,8 @@ export async function getstoreFixtureExcel( req, res ) {
14503
14503
  "Middle Masking": ele.fixtureType != 'floor' ? fixtureVm.find( ( vm ) => midShelfNumber.includes( vm.startYPosition ) && vm.startYPosition != midShelfNumber[midShelfNumber.length - 1] && !vm.vmName.includes( 'Leatherite' ) )?.vmName : '',
14504
14504
  "Leatherite": ele.fixtureType != 'floor' ? fixtureVm.find( ( vm ) => vm.vmName.includes( 'Leatherite' ) )?.vmName : '',
14505
14505
  "Lower Middle Masking": ele.fixtureType != 'floor' ? fixtureVm.find( ( vm ) => vm.startYPosition == midShelfNumber[midShelfNumber.length - 1] )?.vmName : '',
14506
- "Bottom Slander": ele.fixtureType != 'floor' ? fixtureVm.find( ( vm ) => vm.startYPosition == ele.shelfConfig.length && vm.yZone == 'stretch' && vm.xZone == 'stretch' )?.vmName : '',
14507
- "Bottom Mid": ele.fixtureType != 'floor' ? fixtureVm.find( ( vm ) => vm.startYPosition == ele.shelfConfig.length && vm.yZone == 'stretch' && vm.xZone != 'stretch' )?.vmName : '',
14506
+ "Bottom Slanter": ele.fixtureType != 'floor' ? fixtureVm.find( ( vm ) => vm.startYPosition == ele.shelfConfig.length && vm.yZone == 'stretch' && vm.xZone == 'stretch' )?.vmName : '',
14507
+ "Bottom Mid": ele.fixtureType != 'floor' ? fixtureVm.find( ( vm ) => bottomShelfNumber.includes( vm.startYPosition ) && vm.yZone == 'stretch' && vm.xZone != 'stretch' )?.vmName : '',
14508
14508
  "Euro Center Type": ele.fixtureType == 'floor' ? ele.fixtureCategory +'-'+ ele.fixtureWidth.value +' '+ ele.fixtureWidth.unit : '',
14509
14509
  "Euro Center VM": ele.fixtureType == 'floor' ? fixtureVm.map( ( ele ) => ele.vmName )?.toString() : '',
14510
14510
  },
@@ -18626,19 +18626,29 @@ async function updateMellerCollection() {
18626
18626
 
18627
18627
  export async function updateProduct( req, res ) {
18628
18628
  try {
18629
- let query = [
18630
- {
18631
- $group: {
18632
- _id: '$brandName',
18633
- id: { $first: '$_id' },
18634
- },
18635
- },
18636
- ];
18637
- let getProducts = await planoProductService.aggregate( query );
18629
+ let fixtureDetails = await storeFixtureService.findOne( { _id: req.body.fixtureId } );
18630
+ if ( !fixtureDetails ) {
18631
+ return res.sendError( 'No data found', 204 );
18632
+ }
18633
+ fixtureDetails['readerId'] = req.body.macId;
18634
+ fixtureDetails.save();
18635
+ let getProducts = await planoProductService.findSort( { brandName: { $ne: null } }, {}, { brandName: 1 } );
18636
+ let rfIdList = req.body.shelfDetails.flatMap( ( ele ) => ele.rfIdList );
18637
+ await Promise.all( rfIdList.map( async ( idList, index ) => {
18638
+ getProducts[index]['rfId']= idList;
18639
+ await planoProductService.updateOne( { _id: getProducts[index]._id }, { rfId: idList } );
18640
+ } ) );
18638
18641
  if ( getProducts.length ) {
18639
- await Promise.all( getProducts.map( async ( prod, index ) => {
18640
- await planoProductService.updateOne( { _id: prod.id }, { rfId: req.body.rfId[index] } );
18641
- } ) );
18642
+ let shelfDetails = await fixtureShelfService.findOne( { fixtureId: req.body.fixtureId } );
18643
+ let fixtureShelf = [];
18644
+ for ( let [ index, shelf ] of req.body.shelfDetails.entries() ) {
18645
+ let brandName = [ ...new Set( getProducts.filter( ( ele ) => shelf.rfIdList.includes( ele.rfId ) ).map( ( ele ) => ele.brandName ) ) ];
18646
+ fixtureShelf.push( { ...shelfDetails.toObject(), shelfNumber: index + 1, productBrandName: brandName, antennaNo: shelf.antennaNo, zone: shelf.zone, productPerShelf: shelf.rfIdList.length } );
18647
+ }
18648
+
18649
+ console.log( fixtureShelf, 'fixtureShelf' );
18650
+ await fixtureShelfService.deleteMany( { fixtureId: req.body.fixtureId } );
18651
+ await fixtureShelfService.insertMany( { fixtureShelf } );
18642
18652
  }
18643
18653
 
18644
18654
  return res.sendSuccess( 'Updated Successfully' );
@@ -40,3 +40,7 @@ export async function upsertOne( query, record ) {
40
40
  { upsert: true, new: true },
41
41
  );
42
42
  }
43
+
44
+ export async function findSort( query = {}, record={}, sort={} ) {
45
+ return model.planoProductModel.find( query, record, sort );
46
+ }