tango-app-api-store-builder 1.0.0-beta-124 → 1.0.0-beta-126

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-124",
3
+ "version": "1.0.0-beta-126",
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.2.160",
35
+ "tango-api-schema": "2.2.163",
36
36
  "tango-app-api-middleware": "3.1.48",
37
37
  "url": "^0.11.4",
38
38
  "winston": "^3.17.0",
@@ -53,6 +53,7 @@ export async function getplanoFeedback( req, res ) {
53
53
  },
54
54
 
55
55
  }, { $unwind: { path: '$taskData', preserveNullAndEmptyArrays: true } },
56
+ { $sort: { _id: -1 } },
56
57
  );
57
58
 
58
59
 
@@ -485,10 +486,22 @@ export async function updateFixtureStatus( req, res ) {
485
486
  [
486
487
  { 'ans._id': new mongoose.Types.ObjectId( req.body.answerId ) },
487
488
  { 'iss._id': new mongoose.Types.ObjectId( req.body.issueId ) },
488
-
489
-
490
489
  ] );
491
490
  }
491
+ let findoneplanoData = await planoTaskService.findOne( { _id: new mongoose.Types.ObjectId( req.body._id ) } );
492
+ console.log( '************', findoneplanoData.answers[0].issues );
493
+ let totalApproved= findoneplanoData.answers[0].issues.filter( ( data ) => data.status==='pending' );
494
+ console.log( '---------->', totalApproved.length );
495
+ if ( totalApproved.length===0 ) {
496
+ await planoTaskService.updateOne(
497
+ {
498
+ _id: new mongoose.Types.ObjectId( req.body._id ),
499
+ },
500
+ {
501
+ 'status': 'complete',
502
+ },
503
+ );
504
+ }
492
505
  }
493
506
 
494
507
  if ( req.body.taskType==='layout' ) {
@@ -556,7 +569,7 @@ export async function updateStoreFixture( req, res ) {
556
569
  currentFixtureDoc = {
557
570
  ...currentFixtureDoc,
558
571
  ...newTemplate.toObject(),
559
- fixtureConfigDoc: newTemplate.toObject()._id,
572
+ fixtureConfigId: newTemplate.toObject()._id,
560
573
  productBrandName: [ ...productBrandName ],
561
574
  productCategory: [ ...productCategory ],
562
575
  productSubCategory: [ ...productSubCategory ],
@@ -602,3 +615,40 @@ export async function updateStoreFixture( req, res ) {
602
615
  }
603
616
  }
604
617
 
618
+ export async function updateredostatus( req, res ) {
619
+ try {
620
+ console.log( '------->', req.body );
621
+ if ( req.body.type==='layout' ) {
622
+ await planoTaskService.updateOne(
623
+ {
624
+ planoId: new mongoose.Types.ObjectId( req.body.planoId ),
625
+ floorId: new mongoose.Types.ObjectId( req.body.floorId ),
626
+ type: req.body.type,
627
+ },
628
+ {
629
+ 'answers.$[].issues.$[].status': 'completed',
630
+ 'answers.$[].issues.$[].Details.$[].status': 'agree',
631
+ 'status': 'complete',
632
+ },
633
+ );
634
+ } else {
635
+ await planoTaskService.updateOne(
636
+ {
637
+ planoId: new mongoose.Types.ObjectId( req.body.planoId ),
638
+ floorId: new mongoose.Types.ObjectId( req.body.floorId ),
639
+ fixtureId: new mongoose.Types.ObjectId( req.body.fixtureId ),
640
+ type: req.body.type,
641
+ },
642
+ {
643
+ 'answers.$[].issues.$[].status': 'completed',
644
+ 'answers.$[].issues.$[].Details.$[].status': 'agree',
645
+ 'status': 'complete',
646
+ },
647
+ );
648
+ }
649
+ res.sendSuccess( 'updated successfully' );
650
+ } catch ( e ) {
651
+ logger.error( { functionName: 'updateredostatus', error: e } );
652
+ return res.sendError( e, 500 );
653
+ }
654
+ }
@@ -1327,18 +1327,19 @@ export async function getVmDetails( req, res ) {
1327
1327
  return res.sendError( 'No data found', 204 );
1328
1328
  }
1329
1329
  getVmDetails = getVmDetails.toObject();
1330
+ getVmDetails.templateCount = 0;
1330
1331
  let templateDetails = await fixtureTemplateService.find( { 'vmConfig.vmId': { $in: req.query.vmId } } );
1331
1332
  if ( templateDetails.length && getVmDetails.status != 'draft' ) {
1332
1333
  getVmDetails.templateCount = templateDetails.length;
1333
1334
  getVmDetails.status = 'inactive';
1334
- }
1335
- let fixtureDetails = await storeFixtureService.find( { 'vmConfig.vmId': { $in: req.query.vmId } }, { planoId: 1 } );
1336
- if ( fixtureDetails.length ) {
1337
- let planoList = fixtureDetails.map( ( ele ) => ele.planoId );
1338
- let planoDetails = await planoService.find( { _id: { $in: planoList } }, { status: 1 } );
1339
- planoDetails = planoDetails.map( ( ele ) => ele.status );
1340
- if ( planoDetails.includes( 'completed' ) ) {
1341
- getVmDetails.status = 'active';
1335
+ let fixtureDetails = await storeFixtureService.find( { 'vmConfig.vmId': { $in: req.query.vmId } }, { planoId: 1 } );
1336
+ if ( fixtureDetails.length ) {
1337
+ let planoList = fixtureDetails.map( ( ele ) => ele.planoId );
1338
+ let planoDetails = await planoService.find( { _id: { $in: planoList } }, { status: 1 } );
1339
+ planoDetails = planoDetails.map( ( ele ) => ele.status );
1340
+ if ( planoDetails.includes( 'completed' ) ) {
1341
+ getVmDetails.status = 'active';
1342
+ }
1342
1343
  }
1343
1344
  }
1344
1345
  return res.sendSuccess( getVmDetails );
@@ -3013,7 +3013,6 @@ export async function storeFixturesTaskv2( req, res ) {
3013
3013
  const compliance = await planoTaskComplianceService.findOne( {
3014
3014
  fixtureId: fixture._id,
3015
3015
  type: req.body?.type ? req.body.type : 'fixture',
3016
- date_string: req.body?.date,
3017
3016
  }, { status: 1, answers: 1 } );
3018
3017
 
3019
3018
  const shelves = await fixtureShelfService.findAndSort( { fixtureId: fixture._id }, { }, { shelfNumber: 1 } );
@@ -3044,9 +3043,14 @@ export async function storeFixturesTaskv2( req, res ) {
3044
3043
 
3045
3044
  let disabled = true;
3046
3045
  if ( compliance?.status && compliance.status == 'incomplete' ) {
3047
- let issueDetails = compliance?.answers?.[0]?.issues.find( ( ele ) => ele.status == 'disagree' );
3048
- if ( issueDetails ) {
3049
- redoCount ++;
3046
+ const hasDisagree = compliance?.answers?.some( ( answer ) =>
3047
+ answer?.issues?.some( ( issue ) =>
3048
+ issue?.Details?.some( ( detail ) => detail.status === 'disagree' ),
3049
+ ),
3050
+ );
3051
+
3052
+ if ( hasDisagree ) {
3053
+ redoCount++;
3050
3054
  disabled = false;
3051
3055
  }
3052
3056
  }
@@ -3104,7 +3108,6 @@ export async function storeFixturesTaskv2( req, res ) {
3104
3108
  const compliance = await planoTaskComplianceService.findOne( {
3105
3109
  fixtureId: fixture._id,
3106
3110
  type: req.body?.type ? req.body.type : 'fixture',
3107
- date_string: req.body?.date,
3108
3111
  }, { status: 1 } );
3109
3112
 
3110
3113
  const shelves = await fixtureShelfService.findAndSort( { fixtureId: fixture._id }, { }, { shelfNumber: 1 } );
@@ -3134,8 +3137,13 @@ export async function storeFixturesTaskv2( req, res ) {
3134
3137
 
3135
3138
  let disabled = true;
3136
3139
  if ( compliance?.status && compliance.status == 'incomplete' ) {
3137
- let issueDetails = compliance?.answers?.[0]?.issues.find( ( ele ) => ele.status == 'disagree' );
3138
- if ( issueDetails ) {
3140
+ const hasDisagree = compliance?.answers?.some( ( answer ) =>
3141
+ answer?.issues?.some( ( issue ) =>
3142
+ issue?.Details?.some( ( detail ) => detail.status === 'disagree' ),
3143
+ ),
3144
+ );
3145
+
3146
+ if ( hasDisagree ) {
3139
3147
  redoCount++;
3140
3148
  disabled = false;
3141
3149
  }
@@ -3261,7 +3269,10 @@ export async function planoList( req, res ) {
3261
3269
  $expr: {
3262
3270
  $and: [
3263
3271
  { $eq: [ '$planoId', '$$plano' ] },
3264
- { isPlano: true },
3272
+ { $eq: [ '$isPlano', true ] },
3273
+ {
3274
+ $lte: [ '$date_iso', new Date( dayjs().format( 'YYYY-MM-DD' ) ) ],
3275
+ },
3265
3276
  ],
3266
3277
  },
3267
3278
  },
@@ -3274,19 +3285,27 @@ export async function planoList( req, res ) {
3274
3285
  taskId: { $last: '$_id' },
3275
3286
  },
3276
3287
  },
3288
+ {
3289
+ $group: {
3290
+ _id: null,
3291
+ taskStatus: {
3292
+ $push: {
3293
+ type: '$_id',
3294
+ status: '$checklistStatus',
3295
+ date: '$dateString',
3296
+ },
3297
+ },
3298
+ taskIds: { $push: '$taskId' },
3299
+ },
3300
+ },
3277
3301
  ],
3278
3302
  as: 'planoTask',
3279
3303
  },
3280
3304
  },
3281
3305
  {
3282
3306
  $addFields: {
3283
- taskIds: {
3284
- $map: {
3285
- input: '$planoTask',
3286
- as: 'task',
3287
- in: '$$task.taskId',
3288
- },
3289
- },
3307
+ taskIds: { $ifNull: [ { $arrayElemAt: [ '$planoTask.taskIds', 0 ] }, [] ] },
3308
+ taskStatus: { $ifNull: [ { $arrayElemAt: [ '$planoTask.taskStatus', 0 ] }, [] ] },
3290
3309
  },
3291
3310
  },
3292
3311
  {
@@ -3618,12 +3637,34 @@ export async function planoList( req, res ) {
3618
3637
  },
3619
3638
  } );
3620
3639
  }
3621
- if ( inputData?.filter?.taskPending?.length ) {
3640
+ if ( inputData?.filter?.taskPending?.length && inputData?.filter?.taskPending != 'all' ) {
3641
+ let andQuery = [];
3642
+
3643
+ if ( inputData.filter.taskPending == 'layout' ) {
3644
+ andQuery.push(
3645
+ { 'planoTask.taskStatus.type': 'layout' },
3646
+ { 'planoTask.taskStatus.status': 'submit' },
3647
+ { 'taskDetails.layoutStatus': 'pending' },
3648
+ );
3649
+ }
3650
+ if ( inputData.filter.taskPending == 'fixture' ) {
3651
+ andQuery.push(
3652
+ { 'planoTask.taskStatus.type': 'fixture' },
3653
+ { 'planoTask.taskStatus.status': 'submit' },
3654
+ { 'taskDetails.fixtureStatus': 'pending' },
3655
+ );
3656
+ }
3657
+ if ( inputData.filter.taskPending == 'vm' ) {
3658
+ andQuery.push(
3659
+ { 'planoTask.taskStatus.type': 'vm' },
3660
+ { 'taskDetails.vmStatus': 'pending' },
3661
+ { 'planoTask.taskStatus.status': 'submit' },
3662
+ );
3663
+ }
3664
+
3622
3665
  query.push( {
3623
3666
  $match: {
3624
- ...( inputData.filter.taskPending == 'layout' ) ? { 'taskDetails.layoutStatus': 'pending', 'planoTask._id': 'layout', 'planoTask.checklistStatus': 'submit' } :{},
3625
- ...( inputData.filter.taskPending == 'fixture' ) ? { 'taskDetails.fixtureStatus': 'pending', 'planoTask._id': 'fixture', 'planoTask.checklistStatus': 'submit' } :{},
3626
- ...( inputData.filter.taskPending == 'vm' ) ? { 'taskDetails.vmStatus': 'pending', 'planoTask._id': 'vm', 'planoTask.checklistStatus': 'submit' } :{},
3667
+ $and: andQuery,
3627
3668
  },
3628
3669
  } );
3629
3670
  }
@@ -3669,6 +3710,8 @@ export async function planoList( req, res ) {
3669
3710
  },
3670
3711
  } );
3671
3712
 
3713
+ console.log( JSON.stringify( query ) );
3714
+
3672
3715
  let planoDetails = await planoService.aggregate( query );
3673
3716
 
3674
3717
  if ( !planoDetails[0].data.length ) {
@@ -595,11 +595,16 @@ export async function updateAnswersv2( req, res ) {
595
595
  type: req.body.type,
596
596
  date_iso: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
597
597
  taskId: req.body.taskId,
598
+ taskType: req.body.taskType,
598
599
  storeName: req.body?.storeName,
599
600
  storeId: req.body?.storeId,
600
601
  };
601
- console.log( data );
602
- await planoTaskService.updateOne( { planoId: req.body.planoId, floorId: req.body.floorId, fixtureId: req.body.fixtureId, type: req.body.type, date_string: dayjs().format( 'YYYY-MM-DD' ), ...( taskDetails?._id ) ? { taskId: taskDetails?._id } :{} }, data );
602
+ console.log( '111111', data );
603
+ if ( req.body.type==='layout' ) {
604
+ await planoTaskService.updateOne( { planoId: req.body.planoId, taskType: req.body.taskType, floorId: req.body.floorId, fixtureId: req.body.fixtureId, type: req.body.type, date_string: dayjs().format( 'YYYY-MM-DD' ), ...( taskDetails?._id ) ? { taskId: taskDetails?._id } :{} }, data );
605
+ } else {
606
+ await planoTaskService.updateOne( { planoId: req.body.planoId, floorId: req.body.floorId, fixtureId: req.body.fixtureId, type: req.body.type, date_string: dayjs().format( 'YYYY-MM-DD' ), ...( taskDetails?._id ) ? { taskId: taskDetails?._id } :{} }, data );
607
+ }
603
608
 
604
609
  return res.sendSuccess( 'Fixture details updated successfully' );
605
610
  } catch ( e ) {
@@ -15,4 +15,4 @@ managePlanoRouter
15
15
  .get( '/fixtureVMList', managePlanoController.fixtureVMList )
16
16
  .post( '/updateFixtureStatus', isAllowedSessionHandler, managePlanoController.updateFixtureStatus )
17
17
  .post( '/updateStoreFixture', managePlanoController.updateStoreFixture )
18
- .post( '/updateStoreFixture', managePlanoController.updateStoreFixture );
18
+ .post( '/updateredostatus', managePlanoController.updateredostatus );