tango-app-api-store-builder 1.0.0-beta-119 → 1.0.0-beta-120

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.0-beta-119",
3
+ "version": "1.0.0-beta-120",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -504,83 +504,82 @@ export async function updateFixtureStatus( req, res ) {
504
504
  }
505
505
  }
506
506
 
507
- export async function updateStoreFixture(req, res) {
507
+ export async function updateStoreFixture( req, res ) {
508
508
  try {
509
509
  const { fixtureId, data } = req.body;
510
510
 
511
- const currentFixture = await storeFixtureService.findOne({ _id: new mongoose.Types.ObjectId(fixtureId) });
512
- let currentFixtureDoc = currentFixture.toObject()
511
+ const currentFixture = await storeFixtureService.findOne( { _id: new mongoose.Types.ObjectId( fixtureId ) } );
512
+ let currentFixtureDoc = currentFixture.toObject();
513
513
 
514
514
  const productBrandName = new Set();
515
515
  const productCategory = new Set();
516
516
  const productSubCategory = new Set();
517
517
 
518
- data.shelfConfig.forEach((shelf) => {
519
- const { productBrandName: brand, productCategory: category, productSubCategory: subCategory } = shelf;
518
+ data.shelfConfig.forEach( ( shelf ) => {
519
+ const { productBrandName: brand, productCategory: category, productSubCategory: subCategory } = shelf;
520
520
 
521
- if (Array.isArray(brand)) {
522
- brand.forEach((b) => productBrandName.add(b));
523
- }
521
+ if ( Array.isArray( brand ) ) {
522
+ brand.forEach( ( b ) => productBrandName.add( b ) );
523
+ }
524
524
 
525
- if (Array.isArray(category)) {
526
- category.forEach((c) => productCategory.add(c));
527
- }
525
+ if ( Array.isArray( category ) ) {
526
+ category.forEach( ( c ) => productCategory.add( c ) );
527
+ }
528
528
 
529
- if (Array.isArray(subCategory)) {
530
- subCategory.forEach((s) => productSubCategory.add(s));
531
- }
532
- });
533
-
529
+ if ( Array.isArray( subCategory ) ) {
530
+ subCategory.forEach( ( s ) => productSubCategory.add( s ) );
531
+ }
532
+ } );
534
533
 
535
- if (currentFixtureDoc.fixtureConfigId.toString() !== data.fixtureConfigId) {
536
- const newTemplate = await fixtureConfigService.findOne({_id: new mongoose.Types.ObjectId(data.fixtureConfigId) })
534
+
535
+ if ( currentFixtureDoc.fixtureConfigId.toString() !== data.fixtureConfigId ) {
536
+ const newTemplate = await fixtureConfigService.findOne( { _id: data.fixtureConfigId } );
537
537
  currentFixtureDoc = {
538
538
  ...currentFixtureDoc,
539
539
  ...newTemplate.toObject(),
540
- fixtureConfigId:newTemplate.toObject()._id,
541
- productBrandName:[...productBrandName],
542
- productCategory:[...productCategory],
543
- productSubCategory:[...productSubCategory]
544
- }
545
- }else{
540
+ fixtureConfigDoc: newTemplate.toObject()._id,
541
+ productBrandName: [ ...productBrandName ],
542
+ productCategory: [ ...productCategory ],
543
+ productSubCategory: [ ...productSubCategory ],
544
+ };
545
+ } else {
546
546
  currentFixtureDoc = {
547
547
  ...currentFixtureDoc,
548
548
  ...data,
549
- productBrandName:[...productBrandName],
550
- productCategory:[...productCategory],
551
- productSubCategory:[...productSubCategory]
552
- }
549
+ productBrandName: [ ...productBrandName ],
550
+ productCategory: [ ...productCategory ],
551
+ productSubCategory: [ ...productSubCategory ],
552
+ };
553
553
  }
554
554
 
555
- delete currentFixtureDoc._id
555
+ delete currentFixtureDoc._id;
556
556
 
557
557
 
558
- await storeFixtureService.updateOne({ _id: new mongoose.Types.ObjectId(fixtureId) }, currentFixtureDoc);
558
+ await storeFixtureService.updateOne( { _id: new mongoose.Types.ObjectId( fixtureId ) }, currentFixtureDoc );
559
559
 
560
- if (data?.shelfConfig?.length) {
561
- await fixtureShelfService.deleteMany({ fixtureId: new mongoose.Types.ObjectId(fixtureId) })
560
+ if ( data?.shelfConfig?.length ) {
561
+ await fixtureShelfService.deleteMany( { fixtureId: new mongoose.Types.ObjectId( fixtureId ) } );
562
562
 
563
563
 
564
- data.shelfConfig.forEach(async (shelf) => {
565
- delete shelf?._id
564
+ data.shelfConfig.forEach( async ( shelf ) => {
565
+ delete shelf?._id;
566
566
  const additionalMeta = {
567
- clientId: currentFixture.clientId,
568
- storeId: currentFixture.storeId,
569
- storeName: currentFixture.storeName,
570
- planoId: currentFixture.planoId,
571
- floorId: currentFixture.floorId,
572
- fixtureId: currentFixture._id,
573
- }
574
-
575
- await fixtureShelfService.create({ ...additionalMeta, ...shelf });
576
- });
567
+ clientId: currentFixture.clientId,
568
+ storeId: currentFixture.storeId,
569
+ storeName: currentFixture.storeName,
570
+ planoId: currentFixture.planoId,
571
+ floorId: currentFixture.floorId,
572
+ fixtureId: currentFixture._id,
573
+ };
577
574
 
575
+ await fixtureShelfService.create( { ...additionalMeta, ...shelf } );
576
+ } );
578
577
  }
579
578
 
580
- res.sendSuccess('Updated Successfully');
581
- } catch (e) {
582
- logger.error({ functionName: 'updateStoreFixture', error: e });
583
- return res.sendError(e, 500);
579
+ res.sendSuccess( 'Updated Successfully' );
580
+ } catch ( e ) {
581
+ logger.error( { functionName: 'updateStoreFixture', error: e } );
582
+ return res.sendError( e, 500 );
584
583
  }
585
584
  }
586
585
 
@@ -3054,7 +3054,7 @@ export async function storeFixturesTaskv2( req, res ) {
3054
3054
  status: compliance?.status ? compliance.status : '',
3055
3055
  shelfCount: shelves.length,
3056
3056
  productCount: productCount,
3057
- disabled: disabled,
3057
+ disabled: req?.body?.redo ? disabled : false,
3058
3058
  vmCount: vmCount,
3059
3059
  shelfConfig: shelfDetails,
3060
3060
  vmConfig: vmDetails,
@@ -3143,7 +3143,7 @@ export async function storeFixturesTaskv2( req, res ) {
3143
3143
  status: compliance?.status ? compliance.status : '',
3144
3144
  shelfCount: shelves.shelves,
3145
3145
  productCount: productCount,
3146
- disabled: disabled,
3146
+ disabled: req?.body?.redo ? disabled : false,
3147
3147
  vmCount: vmCount,
3148
3148
  shelfConfig: shelfDetails,
3149
3149
  vms: vmDetails,
@@ -414,12 +414,12 @@ export async function uploadImage( req, res ) {
414
414
  if ( !req.files.file ) {
415
415
  return res.sendError( 'Please upload a file', 400 );
416
416
  }
417
-
417
+ console.log( req.files );
418
418
  let params = {
419
419
  Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
420
420
  Key: `${req.body.taskId}/${req.body.qno}/${Date.now()}/`,
421
421
  fileName: req.files.file.name,
422
- ContentType: req.files.file.mimeType,
422
+ ContentType: req.files.file.mimeType?req.files.file.mimeType:req.files.file.mimetypes,
423
423
  body: req.files.file.data,
424
424
  };
425
425
  let fileRes = await fileUpload( params );