tango-app-api-store-builder 1.0.0-beta-180 → 1.0.0-beta-181

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-180",
3
+ "version": "1.0.0-beta-181",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -152,12 +152,13 @@ export async function getTemplateDetails( req, res ) {
152
152
  return vm;
153
153
  }
154
154
  } ) );
155
+ templateDetails.status = templateDetails.status == 'draft' ? 'draft' : 'inactive';
155
156
  let storeFixtureDetails = await storeFixtureService.find( { fixtureConfigId: req.query.templateId } );
156
157
  if ( storeFixtureDetails.length ) {
157
158
  let fixtureId = storeFixtureDetails.map( ( ele ) => ele.planoId );
158
159
  let planoDetails = await planoService.find( { _id: { $in: fixtureId } }, { status: 1 } );
159
160
  planoDetails = planoDetails.map( ( ele ) => ele.status );
160
- templateDetails.status = planoDetails.includes( 'completed' ) ? 'active' : 'inactive';
161
+ templateDetails.status = planoDetails.includes( 'completed' ) ? 'active' : templateDetails.status;
161
162
  }
162
163
  let data = {
163
164
  ...templateDetails,
@@ -922,6 +922,7 @@ export async function updateGlobalComment( req, res ) {
922
922
  floorId: new mongoose.Types.ObjectId( req.body.floorId ),
923
923
  taskType: req.body.taskType,
924
924
  clientId: req.body.clientId,
925
+ taskId: req.body.taskId,
925
926
  };
926
927
  await planoGlobalCommentService.create( payload );
927
928
  await insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).planoglobalcomments, payload );
@@ -1143,6 +1144,31 @@ function pipelineStage( type, planoId, floorId, filterByStatus, filterByApproval
1143
1144
  },
1144
1145
  };
1145
1146
 
1147
+ let commandLookup = {
1148
+ $lookup: {
1149
+ from: 'planoglobalcomments',
1150
+ let: { taskId: '$_id' },
1151
+ pipeline: [
1152
+ {
1153
+ $match: {
1154
+ $expr: {
1155
+ $eq: [ '$taskId', '$$taskId' ],
1156
+ },
1157
+ },
1158
+ },
1159
+
1160
+ ],
1161
+ as: 'commentData',
1162
+ },
1163
+ };
1164
+
1165
+ let unwindCommenTask = {
1166
+ $unwind: {
1167
+ path: '$commentData',
1168
+ preserveNullAndEmptyArrays: true,
1169
+ },
1170
+ };
1171
+
1146
1172
 
1147
1173
  const commonLookups = type === 'layout' ? [] : [
1148
1174
  {
@@ -1287,6 +1313,7 @@ function pipelineStage( type, planoId, floorId, filterByStatus, filterByApproval
1287
1313
  ],
1288
1314
  },
1289
1315
  },
1316
+ 'comments': { $first: '$commentData' },
1290
1317
  },
1291
1318
  },
1292
1319
  ];
@@ -1294,6 +1321,8 @@ function pipelineStage( type, planoId, floorId, filterByStatus, filterByApproval
1294
1321
  ...matchStage,
1295
1322
  taskLookup,
1296
1323
  unwindTask,
1324
+ commandLookup,
1325
+ unwindCommenTask,
1297
1326
  ...commonLookups,
1298
1327
  ...vmStages,
1299
1328
  ...finalGrouping,
@@ -151,6 +151,7 @@ export async function createTask( req, res ) {
151
151
  // if ( !taskDetails.length ) {
152
152
  // return res.sendError( 'No data found', 204 );
153
153
  // }
154
+ let response;
154
155
  let userDetails;
155
156
  let storeList;
156
157
  let endDate;
@@ -342,13 +343,13 @@ export async function createTask( req, res ) {
342
343
  // let currDate = dayjs().add( j, 'days' );
343
344
  // let time = j ? '12:00 AM' : currDate.format( 'hh:mm A' );
344
345
  let insertData = { ...taskData };
345
- await processedService.updateOne( { store_id: insertData.store_id, userEmail: insertData.userEmail, planoId: insertData.planoId, planoType: taskData.planoType, ...( taskData?.floorId ) ? { floorId: taskData.floorId }:{}, ...( [ 'merchRollout', 'vmRollout' ].includes( taskData.planoType ) && { sourceCheckList_id: taskData.sourceCheckList_id } ) }, insertData );
346
+ response = await processedService.updateOne( { store_id: insertData.store_id, userEmail: insertData.userEmail, planoId: insertData.planoId, planoType: taskData.planoType, ...( taskData?.floorId ) ? { floorId: taskData.floorId }:{}, ...( [ 'merchRollout', 'vmRollout' ].includes( taskData.planoType ) && { sourceCheckList_id: taskData.sourceCheckList_id } ) }, insertData );
346
347
  // }
347
348
  }
348
349
  }
349
350
  } ) );
350
351
  // } ) );
351
- return res.sendSuccess( 'Task created successfully' );
352
+ return res.sendSuccess( { message: 'Task created successfully', taskId: response?.upsertedId } );
352
353
  }
353
354
  } catch ( e ) {
354
355
  console.log( e );