tango-app-api-task 1.0.0-alpha.3 → 1.0.0-alpha.5

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": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.5",
4
4
  "description": "Task",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,7 +23,7 @@
23
23
  "handlebars": "^4.7.8",
24
24
  "mongodb": "^6.10.0",
25
25
  "nodemon": "^3.1.7",
26
- "tango-api-schema": "^2.1.90",
26
+ "tango-api-schema": "^2.1.91",
27
27
  "tango-app-api-middleware": "^3.1.43-alpha.10",
28
28
  "winston": "^3.17.0",
29
29
  "winston-daily-rotate-file": "^5.0.0"
@@ -145,6 +145,8 @@ export async function createUpdateTask( req, res ) {
145
145
  return res.sendSuccess( { checklistId: checkListId, message: message } );
146
146
  }
147
147
  }
148
+ } else {
149
+ return res.sendError( { message: 'something went wrong' }, 500 );
148
150
  }
149
151
  } catch ( e ) {
150
152
  logger.error( { functionName: 'createTask', error: e } );
@@ -588,6 +590,7 @@ export async function taskConfig( req, res ) {
588
590
  let storeCount = 0;
589
591
  let locationCount = 0;
590
592
  let checklistDetails;
593
+ inputBody.client_id = inputBody.clientId;
591
594
  if ( !inputBody._id ) {
592
595
  return res.sendError( { message: 'Task Id is Required' }, 400 );
593
596
  }
@@ -605,7 +608,7 @@ export async function taskConfig( req, res ) {
605
608
  checkListName: inputBody?.checkListName,
606
609
  createdBy: req.user._id,
607
610
  createdByName: req.user.userName,
608
- client_id: req.body.client_id,
611
+ client_id: inputBody.client_id,
609
612
  };
610
613
  await checklistLogs.create( logInsertData );
611
614
 
@@ -617,6 +620,7 @@ export async function taskConfig( req, res ) {
617
620
 
618
621
  let configDetails = { ...req.body };
619
622
  configDetails.scheduleEndTimeISO = dayjs.utc( configDetails.scheduleEndTime, 'hh:mm A' ).format();
623
+ configDetails.publishDate = dayjs().format();
620
624
 
621
625
  let response = await taskService.updateOne( { _id: inputBody._id }, configDetails );
622
626
  if ( inputBody?.approver.length ) {
@@ -631,7 +635,7 @@ export async function taskConfig( req, res ) {
631
635
  userEmail: ele.value,
632
636
  checkListId: inputBody._id,
633
637
  type: 'task',
634
- client_id: req.body.client_id,
638
+ client_id: inputBody.client_id,
635
639
  } );
636
640
  }
637
641
  } );
@@ -653,7 +657,7 @@ export async function taskConfig( req, res ) {
653
657
  let query = [
654
658
  {
655
659
  $match: {
656
- client_id: req.body.clientId,
660
+ client_id: inputBody.client_id,
657
661
  id: { $in: storeList },
658
662
  city: { $exists: true },
659
663
  },
@@ -850,6 +854,7 @@ async function insertPCBulkV3( getCLconfig, checklistId, currentdate, updatedche
850
854
  element4.publishDate = getCLconfig.publishDate;
851
855
  element4.locationCount = getCLconfig.locationCount;
852
856
  element4.scheduleRepeatedType = 'daily';
857
+ element4.approvalEnable = getCLconfig.approver.length ? true : false;
853
858
  }
854
859
  if ( userIdList.length ) {
855
860
  allQuestion = allQuestion.filter( ( item ) => typeof item._id == 'undefined' );
@@ -1047,7 +1052,7 @@ export async function createChecklistTask( req, res ) {
1047
1052
  client_id: inputBody.clientId,
1048
1053
  };
1049
1054
  await taskQuestionService.create( question );
1050
- let storeDetails = await storeService.findOne( { storeName: inputBody.storeName }, { storeId: 1, storeProfile: 1 } );
1055
+ let storeDetails = await storeService.findOne( { storeName: inputBody.storeName, status: 'active' }, { storeId: 1, storeProfile: 1 } );
1051
1056
  if ( !storeDetails ) {
1052
1057
  return res.sendError( 'No data found', 204 );
1053
1058
  }
@@ -1072,3 +1077,98 @@ export async function createChecklistTask( req, res ) {
1072
1077
  return res.sendError( e, 500 );
1073
1078
  }
1074
1079
  }
1080
+
1081
+ export async function approveTask( req, res ) {
1082
+ try {
1083
+ if ( !req.body.id ) {
1084
+ return res.sendError( 'id is required', 400 );
1085
+ }
1086
+ let taskDetails = await taskProcessedService.findOne( { _id: req.body.id }, { approvalEnable: 1, approvalStatus: 1 } );
1087
+ if ( !taskDetails ) {
1088
+ return res.sendError( 'No data found', 204 );
1089
+ }
1090
+ if ( !taskDetails.approvalEnable ) {
1091
+ return res.sendError( 'task has no approver', 400 );
1092
+ }
1093
+ taskDetails.approvalStatus = true;
1094
+ taskDetails.save().then( () => {
1095
+ return res.sendSuccess( 'task Approved Successfully' );
1096
+ } ).catch( ( e ) => {
1097
+ return res.sendError( e, 500 );
1098
+ } );
1099
+ } catch ( e ) {
1100
+ logger.error( { function: 'approveTask', error: e } );
1101
+ return res.sendError( e, 500 );
1102
+ }
1103
+ }
1104
+
1105
+ export async function redoTask( req, res ) {
1106
+ try {
1107
+ if ( !req.body.payload._id ) {
1108
+ return res.sendError( 'Id is Required', 400 );
1109
+ }
1110
+ if ( !req.body.payload.section_id ) {
1111
+ return res.sendError( 'Section id is Required', 400 );
1112
+ }
1113
+ if ( !req.body.payload.qno ) {
1114
+ return res.sendError( 'Question number is Required', 400 );
1115
+ }
1116
+
1117
+ let taskDetails = await taskProcessedService.findOne( { _id: req.body.payload._id }, { questionAnswers: 1, redoStatus: 1, checklistStatus: 1, client_id: 1, store_id: 1, storeName: 1, checkListType: 1, sourceCheckList_id: 1, checkListName: 1 } );
1118
+ if ( !taskDetails ) {
1119
+ return res.sendError( 'No data found', 204 );
1120
+ }
1121
+ let question = taskDetails.questionAnswers;
1122
+ let sectionIndex = question.findIndex( ( sec ) => sec.section_id == req.body.payload.section_id );
1123
+ if ( sectionIndex == -1 ) {
1124
+ return res.sendError( 'section is not found', 400 );
1125
+ }
1126
+ let data = { ...question[sectionIndex].questions[req.body.payload.qno - 1], redo: true };
1127
+ let userAnswer = data.userAnswer;
1128
+ question[sectionIndex].questions[req.body.payload.qno - 1] = data;
1129
+ question[sectionIndex].questions[req.body.payload.qno - 1].userAnswer = [];
1130
+ taskDetails.questionAnswers = question;
1131
+ let updateData = {
1132
+ checklistStatus: 'open',
1133
+ redoStatus: true,
1134
+ questionAnswers: question,
1135
+ };
1136
+
1137
+ let response = await taskProcessedService.updateOne( { _id: req.body.payload._id }, updateData );
1138
+ if ( response.modifiedCount || response.matchedCount ) {
1139
+ data = {
1140
+ checklistId: taskDetails.sourceCheckList_id,
1141
+ checkListName: taskDetails.checkListName,
1142
+ sectionId: req.body.payload.section_id,
1143
+ sectionName: question[sectionIndex].sectionName,
1144
+ questionName: question[sectionIndex].questions[req.body.payload.qno - 1].qname,
1145
+ action: 'redo',
1146
+ store_id: taskDetails.store_id,
1147
+ storeName: taskDetails.storeName,
1148
+ client_id: taskDetails.client_id,
1149
+ processedChecklistId: taskDetails._id,
1150
+ type: taskDetails.checkListType,
1151
+ userAnswer: userAnswer,
1152
+ };
1153
+ await checklistLogs.create( data );
1154
+ const requestOptions = {
1155
+ method: 'POST',
1156
+ headers: {
1157
+ 'Content-Type': 'application/json',
1158
+ },
1159
+ body: JSON.stringify( req.body ),
1160
+ };
1161
+ let searchResponse = await fetch( 'https://ottrgmadjmqptsxdmlckjxdjuy0qvpnt.lambda-url.ap-south-1.on.aws/', requestOptions );
1162
+ if ( searchResponse.ok ) {
1163
+ return res.sendSuccess( 'Question redo successfully' );
1164
+ } else {
1165
+ return res.sendError( 'Something went wrong', 500 );
1166
+ }
1167
+ } else {
1168
+ return res.sendError( 'Something went wrong', 500 );
1169
+ }
1170
+ } catch ( e ) {
1171
+ logger.error( { function: 'redoChecklist', error: e } );
1172
+ return res.sendError( e, 500 );
1173
+ }
1174
+ }
@@ -10,11 +10,11 @@ export const overallCardsV1 = async ( req, res ) => {
10
10
  let taskIdList = [];
11
11
  let checklistIdList = [];
12
12
  let resultData;
13
- if ( ( req?.user?.userType == 'client' && req.user.role == 'superadmin' ) || req.body?.clientId ) {
14
- let clientId = req.user?.clientId || req.body?.clientId;
13
+ if ( ( req?.user?.userType == 'client' && req.user.role == 'superadmin' ) ) {
14
+ let clientId = req.user?.clientId;
15
15
  query = { client_id: clientId };
16
16
  } else {
17
- query = { userEmail: req.user.userEmail };
17
+ query = { userEmail: req.user.email };
18
18
  }
19
19
  let details = await traxApprover.find( query );
20
20
  if ( details.length ) {
@@ -34,7 +34,7 @@ export const overallCardsV1 = async ( req, res ) => {
34
34
  ].map( ( item ) => new ObjectId( item ) );
35
35
  }
36
36
 
37
- let toDate = new Date( req.body.date );
37
+ let toDate = new Date( req.body.toDate );
38
38
  let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
39
39
  toDate = new Date( toDate.getTime() - userTimezoneOffset );
40
40
  toDate.setUTCHours( 23, 59, 59, 59 );
@@ -45,31 +45,37 @@ export const overallCardsV1 = async ( req, res ) => {
45
45
  },
46
46
  };
47
47
 
48
- query = [
48
+ let taskQuery = [
49
49
  {
50
50
  $match: {
51
- date_iso: { $gte: new Date( req.body.date ), $lte: toDate },
51
+ date_iso: { $gte: new Date( req.body.fromDate ), $lte: toDate },
52
52
  sourceCheckList_id: { $in: taskIdList },
53
+ ...( req.body.storeId.length ) ? { store_id: { $in: req.body.storeId } } :{},
53
54
  approvalStatus: false,
54
55
  },
55
56
  },
56
57
  { ...groupQuery },
57
58
  ];
58
- let taskCount = await processedTask.aggregate( query );
59
59
 
60
- query = [
60
+ let checklistQuery = [
61
61
  {
62
62
  $match: {
63
- date_iso: { $gte: new Date( req.body.date ), $lte: toDate },
63
+ date_iso: { $gte: new Date( req.body.fromDate ), $lte: toDate },
64
64
  sourceCheckList_id: { $in: checklistIdList },
65
+ ...( req.body.storeId.length ) ? { store_id: { $in: req.body.storeId } } :{},
65
66
  approvalStatus: false,
66
67
  },
67
68
  },
68
69
  { ...groupQuery },
69
70
  ];
70
- let checklistCount = await processedChecklist.aggregate( query );
71
- resultData = { taskCount: taskCount?.[0]?.count || 0, checklistCount: checklistCount?.[0]?.count || 0 };
72
- return res.sendSuccess( resultData );
71
+
72
+ let [ taskCount, checklistCount ] = await Promise.all( [
73
+ processedTask.aggregate( taskQuery ),
74
+ processedChecklist.aggregate( checklistQuery ),
75
+ ] );
76
+
77
+ resultData = { taskApproval: { count: taskCount?.[0]?.count || 0 }, checklistApproval: { count: checklistCount?.[0]?.count || 0 } };
78
+ return res.sendSuccess( { cardData: resultData } );
73
79
  } catch ( error ) {
74
80
  console.log( 'error =>', error );
75
81
  logger.error( { error: error, function: 'overallCards' } );
@@ -83,13 +89,11 @@ export const approvalTableV1 = async ( req, res ) => {
83
89
  let taskIdList = [];
84
90
  let checklistIdList = [];
85
91
  let resultData;
86
- let taskResult = [];
87
- let checklistResult = [];
88
- if ( ( req?.user?.userType == 'client' && req.user.role == 'superadmin' ) || req.body?.clientId ) {
89
- let clientId = req.user?.clientId || req.body?.clientId;
92
+ if ( ( req?.user?.userType == 'client' && req.user.role == 'superadmin' ) ) {
93
+ let clientId = req.user?.clientId;
90
94
  query = { client_id: clientId };
91
95
  } else {
92
- query = { userEmail: req.user.userEmail };
96
+ query = { userEmail: req.user.email };
93
97
  }
94
98
  let details = await traxApprover.find( query );
95
99
  if ( details.length ) {
@@ -100,6 +104,7 @@ export const approvalTableV1 = async ( req, res ) => {
100
104
  .map( ( ele ) => ele.checkListId.toString() ),
101
105
  ),
102
106
  ].map( ( item ) => new ObjectId( item ) );
107
+
103
108
  checklistIdList = [
104
109
  ...new Set(
105
110
  details
@@ -109,7 +114,7 @@ export const approvalTableV1 = async ( req, res ) => {
109
114
  ].map( ( item ) => new ObjectId( item ) );
110
115
  }
111
116
 
112
- let toDate = new Date( req.body.date );
117
+ let toDate = new Date( req.body.toDate );
113
118
  let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
114
119
  toDate = new Date( toDate.getTime() - userTimezoneOffset );
115
120
  toDate.setUTCHours( 23, 59, 59, 59 );
@@ -158,33 +163,65 @@ export const approvalTableV1 = async ( req, res ) => {
158
163
  },
159
164
  } ];
160
165
 
166
+ const promises = [];
161
167
 
162
168
  if ( [ 'task', 'all' ].includes( req.body.type ) ) {
163
169
  query = [
164
170
  {
165
171
  $match: {
166
- date_iso: { $gte: new Date( req.body.date ), $lte: toDate },
172
+ date_iso: { $gte: new Date( req.body.fromDate ), $lte: toDate },
167
173
  sourceCheckList_id: { $in: taskIdList },
174
+ ...( req.body.storeId.length ) ? { store_id: { $in: req.body.storeId } } :{},
168
175
  },
169
176
  },
170
177
  ...groupQuery,
171
178
  ];
172
- taskResult = await processedTask.aggregate( query );
179
+ if ( req.body?.searchValue?.trim() && req.body?.searchValue?.trim().length ) {
180
+ query.push( {
181
+ $match: {
182
+ checkListName: { $regex: req.body?.searchValue, $options: 'i' },
183
+ },
184
+ } );
185
+ }
186
+ if ( req.body?.filter?.trim() && req.body?.filter?.trim().length ) {
187
+ query.push( {
188
+ $match: {
189
+ priorityType: req.body?.filter,
190
+ },
191
+ } );
192
+ }
193
+ promises.push( processedTask.aggregate( query ) );
194
+ } else {
195
+ promises.push( Promise.resolve( null ) );
173
196
  }
197
+
198
+
174
199
  if ( [ 'checklist', 'all' ].includes( req.body.type ) ) {
175
200
  query = [
176
201
  {
177
202
  $match: {
178
- date_iso: { $gte: new Date( req.body.date ), $lte: toDate },
203
+ date_iso: { $gte: new Date( req.body.fromDate ), $lte: toDate },
179
204
  sourceCheckList_id: { $in: checklistIdList },
205
+ ...( req.body.storeId.length ) ? { store_id: { $in: req.body.storeId } } : {},
180
206
  },
181
207
  },
182
208
  ...groupQuery,
183
209
  ];
184
-
185
- checklistResult = await processedChecklist.aggregate( query );
210
+ promises.push( processedChecklist.aggregate( query ) );
211
+ if ( req.body?.searchValue.trim() && req.body?.searchValue.trim().length ) {
212
+ query.push( {
213
+ $match: {
214
+ checkListName: { $regex: req.body?.searchValue, $options: 'i' },
215
+ },
216
+ } );
217
+ }
218
+ } else {
219
+ promises.push( Promise.resolve( null ) );
186
220
  }
187
- const taskSummary = taskResult.reduce(
221
+
222
+ const [ taskResult, checklistResult ] = await Promise.all( promises );
223
+
224
+ const taskSummary = taskResult?.reduce(
188
225
  ( acc, ele ) => {
189
226
  if ( ele.unApproveCount === ele.storeCount ) {
190
227
  acc.openTask.push( ele );
@@ -199,7 +236,7 @@ export const approvalTableV1 = async ( req, res ) => {
199
236
  );
200
237
  const { openTask, inprogressTask, doneTask } = taskSummary;
201
238
 
202
- const checklistSummary = checklistResult.reduce(
239
+ const checklistSummary = checklistResult?.reduce(
203
240
  ( acc, ele ) => {
204
241
  if ( ele.unApproveCount === ele.storeCount ) {
205
242
  acc.openChecklist.push( ele );
@@ -234,6 +271,7 @@ export const overallCards = async ( req, res ) => {
234
271
  return res.sendError( error, 500 );
235
272
  }
236
273
  };
274
+
237
275
  async function overallCardsData( requestData ) {
238
276
  try {
239
277
  let cardData = {
@@ -251,6 +289,7 @@ async function overallCardsData( requestData ) {
251
289
  logger.error( { error: error, message: data, function: 'overallCardsData' } );
252
290
  }
253
291
  }
292
+
254
293
  export const approvalTable = async ( req, res ) => {
255
294
  try {
256
295
  let requestData = req.body;
@@ -262,6 +301,7 @@ export const approvalTable = async ( req, res ) => {
262
301
  return res.sendError( error, 500 );
263
302
  }
264
303
  };
304
+
265
305
  async function approvalTableData( requestData ) {
266
306
  try {
267
307
  let tableData = {
@@ -329,7 +369,6 @@ async function approvalTableData( requestData ) {
329
369
  }
330
370
  }
331
371
 
332
-
333
372
  export const activityLog = async ( req, res ) => {
334
373
  try {
335
374
  let requestData = req.body;
@@ -341,6 +380,7 @@ export const activityLog = async ( req, res ) => {
341
380
  return res.sendError( error, 500 );
342
381
  }
343
382
  };
383
+
344
384
  async function activityLogData( requestData ) {
345
385
  try {
346
386
  let activityLogData = {
@@ -58,7 +58,6 @@ export const overallCardsV1 = async ( req, res ) => {
58
58
  let findAndQuery = [];
59
59
 
60
60
  findAndQuery.push(
61
- { checkListType: { $eq: 'task' } },
62
61
  { date_iso: { $gte: fromDate, $lte: toDate } },
63
62
  { client_id: requestData.clientId },
64
63
  { store_id: { $in: requestData.storeId } },
@@ -67,7 +66,7 @@ export const overallCardsV1 = async ( req, res ) => {
67
66
  findQuery.push( { $match: { $and: findAndQuery } } );
68
67
  findQuery.push( {
69
68
  $group: {
70
- _id: '$checklistStatus',
69
+ _id: { status: '$checklistStatus', redoType: '$redoStatus', approvalStatus: '$approvalStatus' },
71
70
  count: { $sum: 1 },
72
71
  },
73
72
  },
@@ -75,11 +74,11 @@ export const overallCardsV1 = async ( req, res ) => {
75
74
  $group: {
76
75
  _id: null,
77
76
  TotalTasks: { $sum: '$count' },
78
- open: { $sum: { $cond: [ { $eq: [ '$_id', 'open' ] }, '$count', 0 ] } },
79
- inprogress: { $sum: { $cond: [ { $eq: [ '$_id', 'inprogress' ] }, '$count', 0 ] } },
80
- reopen: { $sum: { $cond: [ { $eq: [ '$_id', 'reopen' ] }, '$count', 0 ] } },
81
- submitted: { $sum: { $cond: [ { $eq: [ '$_id', 'submit' ] }, '$count', 0 ] } },
82
- closed: { $sum: { $cond: [ { $eq: [ '$_id', 'closed' ] }, '$count', 0 ] } },
77
+ open: { $sum: { $cond: [ { $and: [ { $eq: [ '$_id.status', 'open' ] }, { $eq: [ '$_id.redoType', false ] } ] }, '$count', 0 ] } },
78
+ inprogress: { $sum: { $cond: [ { $eq: [ '$_id.status', 'inprogress' ] }, '$count', 0 ] } },
79
+ reopen: { $sum: { $cond: [ { $and: [ { $eq: [ '$_id.status', 'open' ] }, { $eq: [ '$_id.redoType', true ] } ] }, '$count', 0 ] } },
80
+ submitted: { $sum: { $cond: [ { $and: [ { $eq: [ '$_id.status', 'submit' ] }, { $eq: [ '$_id.approvalStatus', false ] } ] }, '$count', 0 ] } },
81
+ closed: { $sum: { $cond: [ { $and: [ { $eq: [ '$_id.status', 'submit' ] }, { $eq: [ '$_id.approvalStatus', true ] } ] }, '$count', 0 ] } },
83
82
  },
84
83
  },
85
84
  {
@@ -112,7 +111,7 @@ export const taskTableV1 = async ( req, res ) => {
112
111
  query.push(
113
112
  {
114
113
  $match: {
115
- checkListType: 'task',
114
+ // checkListType: 'task',
116
115
  client_id: req.body.clientId,
117
116
  isdeleted: false,
118
117
  },
@@ -230,11 +229,10 @@ export const taskInfoTableV1 = async ( req, res ) => {
230
229
  let findAndQuery = [];
231
230
 
232
231
  findAndQuery.push(
232
+ { date_iso: { $gte: fromDate, $lte: toDate } },
233
233
  { client_id: requestData.clientId },
234
234
  { store_id: { $in: requestData.storeId } },
235
- { date_iso: { $gte: fromDate } },
236
- { date_iso: { $lte: toDate } },
237
- { checkListType: { $eq: 'task' } },
235
+ // { checkListType: { $eq: 'task' } },
238
236
  { sourceCheckList_id: new mongoose.Types.ObjectId( requestData.taskId ) },
239
237
  );
240
238
  if ( requestData.checklistStatus && requestData.checklistStatus != 'All' ) {
@@ -315,12 +313,6 @@ export const taskInfoTableV1 = async ( req, res ) => {
315
313
  },
316
314
  } );
317
315
 
318
- let getTotalCount = await processedTaskService.aggregate( findQuery );
319
- console.log( 'getTotalCount', getTotalCount );
320
- if ( !getTotalCount.length ) {
321
- return res.sendError( { error: 'No Data Found' }, 204 );
322
- }
323
-
324
316
  if ( requestData.sortColumnName && requestData.sortColumnName != '' && requestData.sortBy && requestData.sortBy !='' ) {
325
317
  findQuery.push( { $sort: { [requestData.sortColumnName]: requestData.sortBy } } );
326
318
  } else {
@@ -329,14 +321,30 @@ export const taskInfoTableV1 = async ( req, res ) => {
329
321
 
330
322
  let limit = parseInt( requestData?.limit ) || 10;
331
323
  let skip = limit * ( requestData?.offset -1 ) || 0;
332
- findQuery.push( { $skip: skip }, { $limit: limit } );
324
+
325
+ findQuery.push( {
326
+ $facet: {
327
+ data: [
328
+ { $skip: skip },
329
+ { $limit: limit },
330
+ ],
331
+ count: [
332
+ { $count: 'total' },
333
+ ],
334
+ },
335
+ } );
336
+
333
337
  let taskInfoData = await processedTaskService.aggregate( findQuery );
334
338
 
335
- result.totalCount = getTotalCount.length;
336
- for ( let i = 0; i < taskInfoData.length; i++ ) {
337
- taskInfoData[i].scheduleEndTime_iso = dayjs( taskInfoData[i].scheduleEndTime_iso ).format( 'DD MMM YYYY' );
339
+ if ( !taskInfoData[0].data.length ) {
340
+ return res.sendError( 'no data found', 204 );
341
+ }
342
+
343
+ result.totalCount = taskInfoData[0].count[0].total;
344
+ for ( let i = 0; i < taskInfoData[0].data.length; i++ ) {
345
+ taskInfoData[0].data[i].scheduleEndTime_iso = dayjs( taskInfoData[0].data[i].scheduleEndTime_iso ).format( 'DD MMM YYYY' );
338
346
  }
339
- result.taskInfo = taskInfoData;
347
+ result.taskInfo = taskInfoData[0].data;
340
348
  return res.sendSuccess( result );
341
349
  } catch ( error ) {
342
350
  console.log( 'error =>', error );
@@ -668,7 +676,7 @@ export const taskDropdownListV1 = async ( req, res ) => {
668
676
  let findAndQuery = [];
669
677
  findAndQuery.push(
670
678
  { client_id: requestData.clientId },
671
- { checkListType: 'task' },
679
+ // { checkListType: 'task' },
672
680
  { isdeleted: false },
673
681
  );
674
682
  findQuery.push( { $match: { $and: findAndQuery } } );
@@ -14,6 +14,8 @@ taskRouter
14
14
  .post( '/uploadImage', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.uploadImage )
15
15
  .post( '/config', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.taskConfig )
16
16
  .post( '/reinitiate', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.reinitiateTask )
17
- .post( '/checklistTask', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.createChecklistTask );
17
+ .post( '/checklistTask', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.createChecklistTask )
18
+ .post( '/updateApprove', isAllowedSessionHandler, taskController.approveTask )
19
+ .post( '/redo', isAllowedSessionHandler, taskController.redoTask );
18
20
 
19
21
 
@@ -12,6 +12,10 @@ export const updateMany = async ( query = {}, record={} ) => {
12
12
  return model.taskProcessedModel.updateMany( query, { $set: record } );
13
13
  };
14
14
 
15
+ export const updateOne = async ( query = {}, record={} ) => {
16
+ return model.taskProcessedModel.updateOne( query, { $set: record } );
17
+ };
18
+
15
19
  export const insertMany = async ( data = [] ) => {
16
20
  return model.taskProcessedModel.insertMany( data );
17
21
  };