tango-app-api-task 3.4.0-alpha-3 → 3.4.0-beta-0

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-task",
3
- "version": "3.4.0-alpha-3",
3
+ "version": "3.4.0-beta-0",
4
4
  "description": "Task",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -191,8 +191,8 @@ export async function createUpdateTask( req, res ) {
191
191
  delete ans.answeroptionNumber;
192
192
  } );
193
193
  let compare = findDifferences( qn, question );
194
- if ( Object.keys( compare ).length && ( compare?.answerType || compare?.answers || compare?.linkType ) ) {
195
- questionList.questionEdit.push( { sectionName: ele.section, questions: [ { previous: qn }, { new: question } ] } );
194
+ if ( Object.keys( compare ).length && ( compare?.answerType || compare?.answers || compare?.linkType || compare?.qname) ) {
195
+ questionList.questionEdit.push( { sectionName: ele.section, questions: [ { previous: qn ,new: question} ] } );
196
196
  }
197
197
  } else {
198
198
  let sectionIndex = questionList.questionDelete.findIndex( ( sec ) => sec.sectionName === ele.section );
@@ -231,7 +231,7 @@ export async function createUpdateTask( req, res ) {
231
231
  sourceCheckList_id: inputBody._id,
232
232
  checkListName: inputBody.checklistName,
233
233
  fromCheckListName: '',
234
- type: 'checklist',
234
+ type: 'task',
235
235
  action: 'edited',
236
236
  storeName: '',
237
237
  store_id: '',
@@ -1000,7 +1000,7 @@ export async function taskConfig( req, res ) {
1000
1000
  };
1001
1001
  await checklistLogs.create( logInsertData );
1002
1002
 
1003
- checklistDetails = await taskService.findOne( { _id: inputBody._id, isdeleted: false, client_id: inputBody.clientId, checkListName: 1 } );
1003
+ checklistDetails = await taskService.findOne( { _id: inputBody._id, isdeleted: false, client_id: inputBody.clientId } );
1004
1004
 
1005
1005
  if ( !checklistDetails ) {
1006
1006
  return res.sendError( 'No data found', 204 );
@@ -2190,7 +2190,7 @@ export async function approveTask( req, res ) {
2190
2190
  if ( req.body?.storeId?.length ) {
2191
2191
  query['store_id'] = { $in: req.body.storeId };
2192
2192
  }
2193
- let taskDetails = await taskProcessedService.find( query, { _id: 1, checklistStatus: 1, storeName: 1, store_id: 1, userEmail: 1 } );
2193
+ let taskDetails = await taskProcessedService.find( query, { _id: 1, checklistStatus: 1, storeName: 1, store_id: 1, userEmail: 1,client_id: 1, coverage: 1 } );
2194
2194
  if ( !taskDetails.length ) {
2195
2195
  return res.sendError( 'No data found', 204 );
2196
2196
  }
@@ -2199,7 +2199,7 @@ export async function approveTask( req, res ) {
2199
2199
  let updateResponse = await taskProcessedService.updateMany( { _id: { $in: idList } }, { approvalStatus: true } );
2200
2200
  if ( updateResponse.modifiedCount || updateResponse.matchedCount ) {
2201
2201
  let inputstores = taskDetails.filter( ( data ) => data.checklistStatus == 'submit' );
2202
-
2202
+ let storeNames = inputstores.map((data)=>data.storeName)
2203
2203
  let params = {
2204
2204
  'payload': {
2205
2205
  sourceCheckList_id: req.body.sourceCheckList_id,
@@ -2212,8 +2212,7 @@ export async function approveTask( req, res ) {
2212
2212
  approvalStatus: true,
2213
2213
  },
2214
2214
  };
2215
-
2216
-
2215
+
2217
2216
  const requestOptions = {
2218
2217
  method: 'POST',
2219
2218
  headers: {
@@ -2224,7 +2223,26 @@ export async function approveTask( req, res ) {
2224
2223
  let url = JSON.parse( process.env.LAMBDAURL );
2225
2224
 
2226
2225
  let searchResponse = await fetch( url.approveTask, requestOptions );
2227
-
2226
+ let logData= {
2227
+ 'client_id': taskDetails[0].client_id,
2228
+ 'createAt': new Date(),
2229
+ 'sourceCheckList_id': req.body.sourceCheckList_id,
2230
+ 'checkListName': taskDetails[0].checkListName,
2231
+ 'fromCheckListName': taskDetails[0].checkListName,
2232
+ 'type': 'checklist',
2233
+ 'action': 'approved',
2234
+ 'storeName': '',
2235
+ 'store_id': '',
2236
+ 'createdByEmail': req.user.email,
2237
+ 'createdBy': req.user._id,
2238
+ 'coverage': taskDetails[0].coverage,
2239
+ 'logDetails': {
2240
+ 'approved': storeNames
2241
+ },
2242
+ };
2243
+ let urlopensearch = JSON.parse( process.env.OPENSEARCH );
2244
+ console.log( 'logData', logData );
2245
+ await insertOpenSearchData( urlopensearch.traxActivityLog, logData );
2228
2246
  if ( searchResponse.ok ) {
2229
2247
  let pendingstores = taskDetails.filter( ( data ) => data.checklistStatus != 'submit' );
2230
2248
  if ( pendingstores && pendingstores.length > 0 ) {
@@ -2789,7 +2807,7 @@ export const updatePublish = async ( req, res ) => {
2789
2807
 
2790
2808
  if ( req.body.checklistId ) {
2791
2809
  query = { _id: req.body.checklistId };
2792
- getCheckDetails = await taskService.findOne( { _id: req.body.checklistId, client_id: req.body.clientId, checkListName: 1 } );
2810
+ getCheckDetails = await taskService.findOne( { _id: req.body.checklistId, client_id: req.body.clientId } );
2793
2811
  }
2794
2812
 
2795
2813
  if ( !getCheckDetails ) {