tango-app-api-store-builder 1.0.0-beta-137 → 1.0.0-beta-139

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-137",
3
+ "version": "1.0.0-beta-139",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,7 +1,7 @@
1
1
  import * as floorService from '../service/storeBuilder.service.js';
2
2
  import { logger } from 'tango-app-api-middleware';
3
3
  // import * as storeService from '../service/store.service.js';
4
- // import * as planoService from '../service/planogram.service.js';
4
+ import * as planoService from '../service/planogram.service.js';
5
5
  import * as storeFixtureService from '../service/storeFixture.service.js';
6
6
  import * as fixtureShelfService from '../service/fixtureShelf.service.js';
7
7
  // import * as planoProductService from '../service/planoProduct.service.js';
@@ -634,8 +634,23 @@ export async function updateFixtureStatus( req, res ) {
634
634
  { 'iss._id': new mongoose.Types.ObjectId( req.body.issueId ) },
635
635
  ] );
636
636
  }
637
+ let vmTask = await planoTaskService.find(
638
+ {
639
+ planoId: new mongoose.Types.ObjectId( req.body.planoId ),
640
+ floorId: new mongoose.Types.ObjectId( req.body.floorId ),
641
+ type: 'vm',
642
+ },
637
643
 
638
-
644
+ );
645
+ let allTaskDone = vmTask.filter( ( data ) => data.status === 'incomplete' );
646
+ if ( allTaskDone.length === 0 ) {
647
+ await planoService.updateOne(
648
+ {
649
+ _id: new mongoose.Types.ObjectId( req.body.planoId ),
650
+ },
651
+ { $set: { planoProgress: 100 } },
652
+ );
653
+ }
639
654
  res.sendSuccess( 'updated successfully' );
640
655
  } catch ( e ) {
641
656
  logger.error( { functionName: 'updateFixtureStatus', error: e } );
@@ -77,7 +77,7 @@ export async function fixtureBulkUpload( req, res ) {
77
77
  let FixLibCode = await getMaxFixtureLibCode();
78
78
  groupedData[ele].fixtureLibCode = FixLibCode;
79
79
  // fixtureData.push( groupedData[ele] );
80
- await planoLibraryService.findOneAndUpdate( { 'fixtureCategory': groupedData[ele].fixtureCategory, 'fixtureWidth.value': groupedData[ele].fixtureWidth.value, 'fixtureWidth.unit': groupedData[ele].fixtureWidth.unit }, groupedData[ele] );
80
+ await planoLibraryService.upsertOne( { 'fixtureCategory': groupedData[ele].fixtureCategory, 'fixtureWidth.value': groupedData[ele].fixtureWidth.value, 'fixtureWidth.unit': groupedData[ele].fixtureWidth.unit }, groupedData[ele] );
81
81
  // }
82
82
  }
83
83
  // let deleteList = inputData.deleteFixtureList.map( ( ele ) => new ObjectId( ele ) );
@@ -3053,9 +3053,9 @@ export async function storeFixturesTaskv2( req, res ) {
3053
3053
  redoCount++;
3054
3054
  disabled = false;
3055
3055
  }
3056
- if ( compliance?.taskType == 'redo' ) {
3057
- disabled = false;
3058
- }
3056
+ }
3057
+ if ( compliance?.taskType == 'redo' ) {
3058
+ disabled = false;
3059
3059
  }
3060
3060
 
3061
3061
  return {
@@ -3153,9 +3153,9 @@ export async function storeFixturesTaskv2( req, res ) {
3153
3153
  redoCount++;
3154
3154
  disabled = false;
3155
3155
  }
3156
- if ( compliance.taskType == 'redo' ) {
3157
- disabled = false;
3158
- }
3156
+ }
3157
+ if ( compliance?.taskType == 'redo' ) {
3158
+ disabled = false;
3159
3159
  }
3160
3160
 
3161
3161
  return {
@@ -4183,3 +4183,16 @@ export async function getTaskDetails( req, res ) {
4183
4183
  return res.sendError( e, 500 );
4184
4184
  }
4185
4185
  }
4186
+
4187
+ export async function getPlanoUser( req, res ) {
4188
+ try {
4189
+ let userList = await planoStaticData.findOne( { type: 'user' }, { data: 1 } );
4190
+ if ( !userList?.data?.includes( req.user.email ) ) {
4191
+ return res.sendSuccess( 'Unauthorized' );
4192
+ }
4193
+ return res.sendSuccess( 'Authorized' );
4194
+ } catch ( e ) {
4195
+ logger.error( { functionName: 'getPlanoUser', error: e } );
4196
+ return res.sendError( e, 500 );
4197
+ }
4198
+ }
@@ -293,11 +293,9 @@ export async function createTask( req, res ) {
293
293
  for ( let j=0; j<req.body.days; j++ ) {
294
294
  let planoProgress = req.body.checkListName == 'Fixture Verification' ? 50 : req.body.checkListName == 'VM Verification' ? 75 : 25;
295
295
  if ( req.body?.checkListName && req.body.checkListName == 'Layout Verification' ) {
296
- let taskIdList = await planoTaskService.find( { planoId: planoDetails?._id, floorId: taskData.floorId } );
297
- taskIdList = taskIdList.map( ( ele ) => ele.taskId );
298
- await planoTaskService.deleteMany( { planoId: planoDetails?._id, floorId: taskData.floorId } );
296
+ await planoTaskService.deleteMany( { planoId: planoDetails?._id, floorId: taskData?.floorId } );
299
297
  planoProgress = 25;
300
- await processedService.deleteMany( { _id: taskIdList } );
298
+ await processedService.deleteMany( { planoId: planoDetails?._id, floorId: taskData?.floorId, isPlano: true } );
301
299
  }
302
300
  await planoService.updateOne( { _id: planoDetails?._id }, { $set: { planoProgress } } );
303
301
  let currDate = dayjs().add( j, 'day' );
@@ -50,4 +50,5 @@ storeBuilderRouter
50
50
 
51
51
  storeBuilderRouter
52
52
  .post( '/planoList', isAllowedSessionHandler, storeBuilderController.planoList )
53
- .get( '/taskDetails', isAllowedSessionHandler, storeBuilderController.getTaskDetails );
53
+ .get( '/taskDetails', isAllowedSessionHandler, storeBuilderController.getTaskDetails )
54
+ .get( '/getPlanoUser', isAllowedSessionHandler, storeBuilderController.getPlanoUser );