tango-app-api-task 1.0.0-alpha.1 → 1.0.0-alpha.2

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.1",
3
+ "version": "1.0.0-alpha.2",
4
4
  "description": "Task",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -24,7 +24,7 @@
24
24
  "mongodb": "^6.10.0",
25
25
  "nodemon": "^3.1.7",
26
26
  "tango-api-schema": "^2.1.88",
27
- "tango-app-api-middleware": "^3.1.43-alpha.9",
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"
30
30
  },
@@ -993,6 +993,20 @@ export async function reinitiateTask( req, res ) {
993
993
  export async function createChecklistTask( req, res ) {
994
994
  try {
995
995
  let inputBody = req.body;
996
+ let userId;
997
+ let userDetails = await userService.findOne( { email: inputBody.userEmail } );
998
+ if ( !userDetails ) {
999
+ let userData = {
1000
+ userName: inputBody.userName,
1001
+ email: inputBody.userEmail,
1002
+ mobileNumber: '',
1003
+ clientId: inputBody.clientId,
1004
+ };
1005
+ userId = await createUser( userData );
1006
+ } else {
1007
+ userId = userDetails._id;
1008
+ }
1009
+ let time = inputBody?.scheduleEndTime || '11:59 PM';
996
1010
  let data = {
997
1011
  checkListName: inputBody.checkListName,
998
1012
  checkListDescription: inputBody.checkListDescription,
@@ -1002,8 +1016,8 @@ export async function createChecklistTask( req, res ) {
1002
1016
  questionCount: 1,
1003
1017
  storeCount: 1,
1004
1018
  scheduleDate: inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' ),
1005
- scheduleEndTime: inputBody?.scheduleEndTime || '11:59 PM',
1006
- scheduleEndTimeISO: dayjs.utc( inputBody.scheduleEndTime, 'hh:mm A' ).format(),
1019
+ scheduleEndTime: time,
1020
+ scheduleEndTimeISO: dayjs.utc( time, 'hh:mm A' ).format(),
1007
1021
  priorityType: 'high',
1008
1022
  client_id: inputBody.clientId,
1009
1023
  checkListType: inputBody.checkListType,
@@ -1047,6 +1061,7 @@ export async function createChecklistTask( req, res ) {
1047
1061
  checkListId: response?._id,
1048
1062
  checkListName: inputBody.checkListName,
1049
1063
  client_id: inputBody.clientId,
1064
+ userId: userId,
1050
1065
  };
1051
1066
  await taskAssignService.create( userDetails );
1052
1067
  await insertSingleProcessData( response?._id );
@@ -4,13 +4,13 @@ import { logger } from 'tango-app-api-middleware';
4
4
  import * as processedChecklist from '../service/processedChecklist.service.js';
5
5
  import mongoose from 'mongoose';
6
6
  const ObjectId = mongoose.Types.ObjectId;
7
- export const overallCards = async ( req, res ) => {
7
+ export const overallCardsV1 = async ( req, res ) => {
8
8
  try {
9
9
  let query;
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 ) {
13
+ if ( ( req?.user?.userType == 'client' && req.user.role == 'superadmin' ) || req.body?.clientId ) {
14
14
  let clientId = req.user?.clientId || req.body?.clientId;
15
15
  query = { client_id: clientId };
16
16
  } else {
@@ -77,25 +77,7 @@ export const overallCards = async ( req, res ) => {
77
77
  }
78
78
  };
79
79
 
80
- // async function overallCardsData( requestData ) {
81
- // try {
82
- // let cardData = {
83
- // 'checklistApproval': {
84
- // 'count': 50, // Checklist Count
85
- // },
86
- // 'taskApproval': {
87
- // 'count': 40, // Task Count
88
- // },
89
- // };
90
- // // resultData.card = cardData;
91
- // return { cardData: cardData };
92
- // } catch ( error ) {
93
- // console.log( 'error =>', error );
94
- // logger.error( { error: error, message: data, function: 'overallCardsData' } );
95
- // }
96
- // }
97
-
98
- export const approvalTable = async ( req, res ) => {
80
+ export const approvalTableV1 = async ( req, res ) => {
99
81
  try {
100
82
  let query;
101
83
  let taskIdList = [];
@@ -103,7 +85,7 @@ export const approvalTable = async ( req, res ) => {
103
85
  let resultData;
104
86
  let taskResult = [];
105
87
  let checklistResult = [];
106
- if ( req?.user?.userType == 'client' && req.user.role == 'superadmin' || req.body?.clientId ) {
88
+ if ( ( req?.user?.userType == 'client' && req.user.role == 'superadmin' ) || req.body?.clientId ) {
107
89
  let clientId = req.user?.clientId || req.body?.clientId;
108
90
  query = { client_id: clientId };
109
91
  } else {
@@ -241,72 +223,112 @@ export const approvalTable = async ( req, res ) => {
241
223
  }
242
224
  };
243
225
 
244
- // async function approvalTableData( requestData ) {
245
- // try {
246
- // let tableData = {
247
- // 'totalCount': 50,
248
- // 'approvalList': [
249
- // {
250
- // 'taskName': 'Hustlr Tray',
251
- // 'createdBy': 'Olivia Rhye',
252
- // 'totalAssigned': 100,
253
- // 'totalSubmitted': 200,
254
- // 'scheduledRepeatedType': 'daily', // weekly or monthly,
255
- // 'dateString': '12 Jan,2024',
256
- // 'sorceTaskId': '4862896912909',
257
- // 'taskType': 'task', // checklist or redo
258
- // 'status': 'open', // inprogress or approved
259
- // 'priority': 'high',
260
- // 'approved': 90,
261
- // },
262
- // {
263
- // 'taskName': 'Hustlr Tray',
264
- // 'createdBy': 'Olivia Rhye',
265
- // 'totalAssigned': 100,
266
- // 'totalSubmitted': 200,
267
- // 'scheduledRepeatedType': 'daily', // weekly or monthly,
268
- // 'dateString': '12 Jan,2024',
269
- // 'sorceTaskId': '4862896912909',
270
- // 'taskType': 'redo', // checklist or redo
271
- // 'status': 'inprogress', // inprogress or approved
272
- // 'priority': 'low',
273
- // 'approved': 90,
274
- // },
275
- // {
276
- // 'taskName': 'Hustlr Tray',
277
- // 'createdBy': 'Olivia Rhye',
278
- // 'totalAssigned': 100,
279
- // 'totalSubmitted': 200,
280
- // 'scheduledRepeatedType': 'daily', // weekly or monthly,
281
- // 'dateString': '12 Jan,2024',
282
- // 'sorceTaskId': '4862896912909',
283
- // 'taskType': 'task', // checklist or redo
284
- // 'status': 'approved', // inprogress or approved
285
- // 'priority': 'low',
286
- // 'approved': 90,
287
- // },
288
- // {
289
- // 'taskName': 'Hustlr Tray',
290
- // 'createdBy': 'Olivia Rhye',
291
- // 'totalAssigned': 100,
292
- // 'totalSubmitted': 200,
293
- // 'scheduledRepeatedType': 'daily', // weekly or monthly,
294
- // 'dateString': '12 Jan,2024',
295
- // 'sorceTaskId': '4862896912909',
296
- // 'taskType': 'task', // checklist or redo
297
- // 'status': 'approved', // inprogress or approved
298
- // 'priority': 'low',
299
- // 'approved': 90,
300
- // },
301
- // ],
302
- // };
303
- // return tableData;
304
- // } catch ( error ) {
305
- // console.log( 'error =>', error );
306
- // logger.error( { error: error, message: requestData, function: 'approvalTableData' } );
307
- // return res.sendError( error, 500 );
308
- // }
309
- // }
226
+ export const overallCards = async ( req, res ) => {
227
+ try {
228
+ let requestData = req.body;
229
+ let resultData = await overallCardsData( requestData );
230
+ return res.sendSuccess( resultData );
231
+ } catch ( error ) {
232
+ console.log( 'error =>', error );
233
+ logger.error( { error: error, function: 'overallCards' } );
234
+ return res.sendError( error, 500 );
235
+ }
236
+ };
237
+ async function overallCardsData( requestData ) {
238
+ try {
239
+ let cardData = {
240
+ 'checklistApproval': {
241
+ 'count': 50, // Checklist Count
242
+ },
243
+ 'taskApproval': {
244
+ 'count': 40, // Task Count
245
+ },
246
+ };
247
+ // resultData.card = cardData;
248
+ return { cardData: cardData };
249
+ } catch ( error ) {
250
+ console.log( 'error =>', error );
251
+ logger.error( { error: error, message: data, function: 'overallCardsData' } );
252
+ }
253
+ }
254
+ export const approvalTable = async ( req, res ) => {
255
+ try {
256
+ let requestData = req.body;
257
+ let resultData = await approvalTableData( requestData );
258
+ return res.sendSuccess( resultData );
259
+ } catch ( error ) {
260
+ console.log( 'error =>', error );
261
+ logger.error( { error: error, function: 'taskTable' } );
262
+ return res.sendError( error, 500 );
263
+ }
264
+ };
265
+ async function approvalTableData( requestData ) {
266
+ try {
267
+ let tableData = {
268
+ 'totalCount': 50,
269
+ 'approvalList': [
270
+ {
271
+ 'taskName': 'Hustlr Tray',
272
+ 'createdBy': 'Olivia Rhye',
273
+ 'totalAssigned': 100,
274
+ 'totalSubmitted': 200,
275
+ 'scheduledRepeatedType': 'daily', // weekly or monthly,
276
+ 'dateString': '12 Jan,2024',
277
+ 'sorceTaskId': '4862896912909',
278
+ 'taskType': 'task', // checklist or redo
279
+ 'status': 'open', // inprogress or approved
280
+ 'priority': 'high',
281
+ 'approved': 90,
282
+ },
283
+ {
284
+ 'taskName': 'Hustlr Tray',
285
+ 'createdBy': 'Olivia Rhye',
286
+ 'totalAssigned': 100,
287
+ 'totalSubmitted': 200,
288
+ 'scheduledRepeatedType': 'daily', // weekly or monthly,
289
+ 'dateString': '12 Jan,2024',
290
+ 'sorceTaskId': '4862896912909',
291
+ 'taskType': 'redo', // checklist or redo
292
+ 'status': 'inprogress', // inprogress or approved
293
+ 'priority': 'low',
294
+ 'approved': 90,
295
+ },
296
+ {
297
+ 'taskName': 'Hustlr Tray',
298
+ 'createdBy': 'Olivia Rhye',
299
+ 'totalAssigned': 100,
300
+ 'totalSubmitted': 200,
301
+ 'scheduledRepeatedType': 'daily', // weekly or monthly,
302
+ 'dateString': '12 Jan,2024',
303
+ 'sorceTaskId': '4862896912909',
304
+ 'taskType': 'task', // checklist or redo
305
+ 'status': 'approved', // inprogress or approved
306
+ 'priority': 'low',
307
+ 'approved': 90,
308
+ },
309
+ {
310
+ 'taskName': 'Hustlr Tray',
311
+ 'createdBy': 'Olivia Rhye',
312
+ 'totalAssigned': 100,
313
+ 'totalSubmitted': 200,
314
+ 'scheduledRepeatedType': 'daily', // weekly or monthly,
315
+ 'dateString': '12 Jan,2024',
316
+ 'sorceTaskId': '4862896912909',
317
+ 'taskType': 'task', // checklist or redo
318
+ 'status': 'approved', // inprogress or approved
319
+ 'priority': 'low',
320
+ 'approved': 90,
321
+ },
322
+ ],
323
+ };
324
+ return tableData;
325
+ } catch ( error ) {
326
+ console.log( 'error =>', error );
327
+ logger.error( { error: error, message: requestData, function: 'approvalTableData' } );
328
+ return res.sendError( error, 500 );
329
+ }
330
+ }
331
+
310
332
 
311
333
  export const activityLog = async ( req, res ) => {
312
334
  try {
@@ -669,6 +669,7 @@ export const taskDropdownListV1 = async ( req, res ) => {
669
669
  findAndQuery.push(
670
670
  { client_id: requestData.clientId },
671
671
  { checkListType: 'task' },
672
+ { isdeleted: false },
672
673
  );
673
674
  findQuery.push( { $match: { $and: findAndQuery } } );
674
675
  findQuery.push( {
@@ -680,6 +681,7 @@ export const taskDropdownListV1 = async ( req, res ) => {
680
681
  createdByName: 1,
681
682
  storeCount: 1,
682
683
  scheduleEndTimeISO: 1,
684
+ submitTime_string: 1,
683
685
  },
684
686
  } );
685
687
  if ( requestData.sortColumnName && requestData.sortColumnName != '' && requestData.sortBy && requestData.sortBy !='' ) {
@@ -745,3 +747,35 @@ async function taskInfoViewData( requestData ) {
745
747
  return res.sendError( error, 500 );
746
748
  }
747
749
  }
750
+ export const taskDeleteV1 = async ( req, res ) => {
751
+ try {
752
+ let requestData = req.body;
753
+
754
+ if ( !requestData.taskId ) {
755
+ return res.sendError( 'Missing taskId in request body', 400 );
756
+ }
757
+
758
+ const taskConfig = await taskService.findOne( { _id: new mongoose.Types.ObjectId( requestData.taskId ) }, { _id: 1 } );
759
+ if ( !taskConfig ) {
760
+ console.log( 'Task found:', taskConfig );
761
+ return res.sendError( 'Task not found', 404 );
762
+ }
763
+
764
+ let resultData = await taskService.updateOne(
765
+ { _id: new mongoose.Types.ObjectId( requestData.taskId ) },
766
+ { isdeleted: true },
767
+ );
768
+
769
+ if ( resultData ) {
770
+ console.log( 'Update result:', resultData );
771
+ return res.sendSuccess( { message: 'Task deleted successfully' } );
772
+ } else {
773
+ return res.sendError( 'Something went wrong please try again', 500 );
774
+ }
775
+ } catch ( e ) {
776
+ logger.error( 'taskDeleteV1 =>', e );
777
+ return res.sendError( e, 500 );
778
+ }
779
+ };
780
+
781
+
@@ -3,14 +3,14 @@ import { isAllowedSessionHandler } from 'tango-app-api-middleware';
3
3
  export const taskActionCenterRouter = express.Router();
4
4
 
5
5
  import {
6
- overallCards, approvalTable, activityLog,
6
+ overallCards, approvalTable, activityLog, overallCardsV1, approvalTableV1,
7
7
  } from '../controllers/taskActionCenter.controllers.js';
8
8
 
9
9
  taskActionCenterRouter
10
- .post( '/overallcards', isAllowedSessionHandler, overallCards )
11
- // .post( '/overallcardsV1', overallCardsV1 )
12
- .post( '/approvalTable', isAllowedSessionHandler, approvalTable )
13
- // .post( '/approvalTableV1', approvalTableV1 )
10
+ .post( '/overallcardsV1', isAllowedSessionHandler, overallCardsV1 )
11
+ .post( '/overallcards', overallCards )
12
+ .post( '/approvalTableV1', isAllowedSessionHandler, approvalTableV1 )
13
+ .post( '/approvalTable', approvalTable )
14
14
  .post( '/activityLog', activityLog );
15
15
 
16
16
  export default taskActionCenterRouter;
@@ -2,7 +2,7 @@ import express from 'express';
2
2
  export const taskDashboardRouter = express.Router();
3
3
 
4
4
  import {
5
- overallCards, taskTable, taskInfoTable, taskDropdownList, taskTableV1, overallCardsV1, taskInfoTableV1, taskDropdownListV1,
5
+ overallCards, taskTable, taskInfoTable, taskDropdownList, taskTableV1, overallCardsV1, taskInfoTableV1, taskDropdownListV1, taskDeleteV1,
6
6
  } from '../controllers/taskDashboard.controllers.js';
7
7
 
8
8
  taskDashboardRouter
@@ -13,6 +13,7 @@ taskDashboardRouter
13
13
  .post( '/taskInfoTable', taskInfoTable )
14
14
  .post( '/taskInfoTableV1', taskInfoTableV1 )
15
15
  .post( '/taskDropdownList', taskDropdownList )
16
- .post( '/taskDropdownListV1', taskDropdownListV1 );
16
+ .post( '/taskDropdownListV1', taskDropdownListV1 )
17
+ .post( '/taskDeleteV1', taskDeleteV1 );
17
18
 
18
19
  export default taskDashboardRouter;