tango-app-api-task 3.5.0-alpha-2 → 3.5.0-alpha-3
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
|
@@ -236,14 +236,18 @@ export async function createUpdateTask( req, res ) {
|
|
|
236
236
|
createdBy: req.user.userName,
|
|
237
237
|
coverage: taskDetails?.coverage,
|
|
238
238
|
logDetails: {
|
|
239
|
-
...( inputBody.checklistName.toLowerCase() == taskDetails.checkListName.toLowerCase() ) ? { updatedChecklistName: {} } :
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
239
|
+
...( inputBody.checklistName.toLowerCase() == taskDetails.checkListName.toLowerCase() ) ? { updatedChecklistName: {} } : {
|
|
240
|
+
updatedChecklistName: {
|
|
241
|
+
previous: taskDetails.checkListName,
|
|
242
|
+
new: inputBody.checklistName,
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
...( inputBody.checklistDescription.toLowerCase() == taskDetails.checkListDescription.toLowerCase() ) ? { updatedChecklistDescription: {} } : {
|
|
246
|
+
updatedChecklistDescription: {
|
|
247
|
+
previous: taskDetails.checkListDescription,
|
|
248
|
+
new: inputBody.checklistDescription,
|
|
249
|
+
},
|
|
250
|
+
},
|
|
247
251
|
updatedSectionName: [],
|
|
248
252
|
questionAdd: questionList.questionAdd,
|
|
249
253
|
questionEdit: questionList.questionEdit,
|
|
@@ -416,7 +420,7 @@ export async function taskDetails( req, res ) {
|
|
|
416
420
|
return { id: item.assignId, type: 'cluster' };
|
|
417
421
|
} );
|
|
418
422
|
} else {
|
|
419
|
-
singleAssign = assignList.filter( ( item ) => typeof item?.userEmail != 'undefined' && item?.userEmail !='' ).map( ( item ) => {
|
|
423
|
+
singleAssign = assignList.filter( ( item ) => typeof item?.userEmail != 'undefined' && item?.userEmail != '' ).map( ( item ) => {
|
|
420
424
|
return { id: item.assignId, type: 'user' };
|
|
421
425
|
} );
|
|
422
426
|
groupAssign = assignList.filter( ( item ) => typeof item?.teamName != 'undefined' && item?.teamName != '' ).map( ( item ) => {
|
|
@@ -1134,12 +1138,12 @@ export async function taskConfig( req, res ) {
|
|
|
1134
1138
|
logDetails: {
|
|
1135
1139
|
schedule: {
|
|
1136
1140
|
previous: {
|
|
1137
|
-
...( showSchedule ) ? { scheduleDateString: checklistDetails?.scheduleDate } :{},
|
|
1141
|
+
...( showSchedule ) ? { scheduleDateString: checklistDetails?.scheduleDate } : {},
|
|
1138
1142
|
time: showSchedule ? checklistDetails.scheduleEndTime : '',
|
|
1139
1143
|
priority: showSchedule ? checklistDetails?.priorityType : '',
|
|
1140
1144
|
},
|
|
1141
1145
|
new: {
|
|
1142
|
-
...( showSchedule ) ? { scheduleDateString: configDetails?.scheduleDate } :{},
|
|
1146
|
+
...( showSchedule ) ? { scheduleDateString: configDetails?.scheduleDate } : {},
|
|
1143
1147
|
time: showSchedule ? configDetails.scheduleEndTime : '',
|
|
1144
1148
|
priority: showSchedule ? configDetails?.priorityType : '',
|
|
1145
1149
|
},
|
|
@@ -1152,15 +1156,18 @@ export async function taskConfig( req, res ) {
|
|
|
1152
1156
|
...( differences?.allowedStoreLocation && configDetails.allowedStoreLocation ? [ 'Geo fencing' ] : [] ),
|
|
1153
1157
|
],
|
|
1154
1158
|
},
|
|
1155
|
-
...( differences?.approver ) ? {
|
|
1156
|
-
|
|
1157
|
-
|
|
1159
|
+
...( differences?.approver ) ? {
|
|
1160
|
+
approver:
|
|
1161
|
+
{
|
|
1162
|
+
previous: checklistDetails?.approver.map( ( item ) => item.name ).toString(),
|
|
1163
|
+
new: configDetails?.approver.map( ( item ) => item.name ).toString(),
|
|
1164
|
+
},
|
|
1158
1165
|
} : { approver: {} },
|
|
1159
1166
|
owner: {},
|
|
1160
|
-
...( inputBody.coverage == 'store' ) ? { storeAdded: inputBody.added } :{ storeAdded: [] },
|
|
1161
|
-
...( req.body.removed.store.length ) ? { storeRemoved: inputBody.removed.store } :{ storeRemoved: [] },
|
|
1162
|
-
...( inputBody.coverage == 'user' ) ? { userAdded: inputBody.added } :{ userAdded: [] },
|
|
1163
|
-
...( req.body.removed.user.length ) ? { userRemoved: inputBody.removed.user } :{ userRemoved: [] },
|
|
1167
|
+
...( inputBody.coverage == 'store' ) ? { storeAdded: inputBody.added } : { storeAdded: [] },
|
|
1168
|
+
...( req.body.removed.store.length ) ? { storeRemoved: inputBody.removed.store } : { storeRemoved: [] },
|
|
1169
|
+
...( inputBody.coverage == 'user' ) ? { userAdded: inputBody.added } : { userAdded: [] },
|
|
1170
|
+
...( req.body.removed.user.length ) ? { userRemoved: inputBody.removed.user } : { userRemoved: [] },
|
|
1164
1171
|
},
|
|
1165
1172
|
userType: req?.user?.userType || '',
|
|
1166
1173
|
};
|
|
@@ -1513,11 +1520,11 @@ async function insertPCBulkV3( getCLconfig, checklistId, updatedchecklist, date,
|
|
|
1513
1520
|
element4.remainder = getCLconfig?.remainder || [];
|
|
1514
1521
|
element4.restrictAttendance = getCLconfig?.restrictAttendance;
|
|
1515
1522
|
element4.coverage = getCLconfig?.coverage;
|
|
1516
|
-
if ( inputBody&&inputBody?.streamId ) {
|
|
1523
|
+
if ( inputBody && inputBody?.streamId ) {
|
|
1517
1524
|
element4.streamId = inputBody?.streamId;
|
|
1518
1525
|
}
|
|
1519
1526
|
if ( answerTypechange ) {
|
|
1520
|
-
element4.questionAnswers= insertdata.questionAnswers;
|
|
1527
|
+
element4.questionAnswers = insertdata.questionAnswers;
|
|
1521
1528
|
element4.planoType = 'qrScan';
|
|
1522
1529
|
}
|
|
1523
1530
|
element4.coverage = getCLconfig?.coverage;
|
|
@@ -1809,12 +1816,12 @@ export async function reinitiateTask( req, res ) {
|
|
|
1809
1816
|
logDetails: {
|
|
1810
1817
|
schedule: {
|
|
1811
1818
|
previous: {
|
|
1812
|
-
...( showSchedule ) ? { scheduleDateString: taskDetails?.scheduleDate } :{},
|
|
1819
|
+
...( showSchedule ) ? { scheduleDateString: taskDetails?.scheduleDate } : {},
|
|
1813
1820
|
time: showSchedule ? taskDetails.scheduleEndTime : '',
|
|
1814
1821
|
priority: showSchedule ? taskDetails?.priorityType : '',
|
|
1815
1822
|
},
|
|
1816
1823
|
new: {
|
|
1817
|
-
...( showSchedule ) ? { scheduleDateString: req.body?.scheduleDate } :{},
|
|
1824
|
+
...( showSchedule ) ? { scheduleDateString: req.body?.scheduleDate } : {},
|
|
1818
1825
|
time: showSchedule ? req.body.scheduleEndTime : '',
|
|
1819
1826
|
priority: showSchedule ? req.body?.priorityType : '',
|
|
1820
1827
|
},
|
|
@@ -1827,8 +1834,10 @@ export async function reinitiateTask( req, res ) {
|
|
|
1827
1834
|
...( differences?.allowedStoreLocation && req.body.allowedStoreLocation ? [ 'Geo fencing' ] : [] ),
|
|
1828
1835
|
],
|
|
1829
1836
|
},
|
|
1830
|
-
approver: {
|
|
1831
|
-
|
|
1837
|
+
approver: {
|
|
1838
|
+
previous: taskDetails?.approver.map( ( item ) => item.name ).toString(),
|
|
1839
|
+
new: taskDetails?.approver.map( ( item ) => item.name ).toString(),
|
|
1840
|
+
},
|
|
1832
1841
|
owner: {},
|
|
1833
1842
|
storeAdded: [],
|
|
1834
1843
|
storeRemoved: [],
|
|
@@ -1974,9 +1983,9 @@ export async function createChecklistTask( req, res ) {
|
|
|
1974
1983
|
let userDetails = {
|
|
1975
1984
|
userName: inputBody.userName,
|
|
1976
1985
|
userEmail: inputBody.userEmail,
|
|
1977
|
-
store_id: storeDetails?.storeId?storeDetails.storeId:'',
|
|
1978
|
-
storeName: inputBody?.storeName?inputBody?.storeName:'',
|
|
1979
|
-
city: storeDetails?.storeProfile?.city?storeDetails?.storeProfile?.city:'',
|
|
1986
|
+
store_id: storeDetails?.storeId ? storeDetails.storeId : '',
|
|
1987
|
+
storeName: inputBody?.storeName ? inputBody?.storeName : '',
|
|
1988
|
+
city: storeDetails?.storeProfile?.city ? storeDetails?.storeProfile?.city : '',
|
|
1980
1989
|
checkFlag: true,
|
|
1981
1990
|
checkListId: response?._id,
|
|
1982
1991
|
checkListName: data.checkListName,
|
|
@@ -2037,7 +2046,7 @@ export async function createChecklistTask( req, res ) {
|
|
|
2037
2046
|
if ( !searchResponse.ok ) {
|
|
2038
2047
|
return res.sendError( 'Something went wrong', 500 );
|
|
2039
2048
|
}
|
|
2040
|
-
let logData= {
|
|
2049
|
+
let logData = {
|
|
2041
2050
|
'client_id': inputBody.clientId,
|
|
2042
2051
|
'createAt': new Date(),
|
|
2043
2052
|
'sourceCheckList_id': response._id,
|
|
@@ -2045,8 +2054,8 @@ export async function createChecklistTask( req, res ) {
|
|
|
2045
2054
|
'fromCheckListName': taskDetails.checkListName,
|
|
2046
2055
|
'type': 'task',
|
|
2047
2056
|
'action': 'task_created',
|
|
2048
|
-
'store_id': storeDetails?.storeId?storeDetails.storeId:'',
|
|
2049
|
-
'storeName': inputBody?.storeName?inputBody?.storeName:'',
|
|
2057
|
+
'store_id': storeDetails?.storeId ? storeDetails.storeId : '',
|
|
2058
|
+
'storeName': inputBody?.storeName ? inputBody?.storeName : '',
|
|
2050
2059
|
'createdByEmail': req.user.email,
|
|
2051
2060
|
'createdBy': req.user._id,
|
|
2052
2061
|
'userName': inputBody.userName,
|
|
@@ -2073,7 +2082,7 @@ export async function createChecklistMultiTask( req, res ) {
|
|
|
2073
2082
|
try {
|
|
2074
2083
|
let inputBody = req.body;
|
|
2075
2084
|
// console.log( inputBody );
|
|
2076
|
-
let inputData= inputBody.coverage==='user'?inputBody.userEmail:inputBody.storeName;
|
|
2085
|
+
let inputData = inputBody.coverage === 'user' ? inputBody.userEmail : inputBody.storeName;
|
|
2077
2086
|
let userDetailList;
|
|
2078
2087
|
for ( let user of inputData ) {
|
|
2079
2088
|
userDetailList = await userService.findOne( { email: user.userEmail } );
|
|
@@ -2189,16 +2198,16 @@ export async function createChecklistMultiTask( req, res ) {
|
|
|
2189
2198
|
}
|
|
2190
2199
|
|
|
2191
2200
|
let userDetails = {
|
|
2192
|
-
userName: originaldata.userName?originaldata.userName:'',
|
|
2193
|
-
userEmail: originaldata.userEmail?originaldata.userEmail:'',
|
|
2194
|
-
store_id: storeDetails?.storeId?storeDetails.storeId:'',
|
|
2195
|
-
storeName: originaldata?.storeName?originaldata?.storeName:'',
|
|
2196
|
-
city: storeDetails?.storeProfile?.city?storeDetails?.storeProfile?.city:'',
|
|
2201
|
+
userName: originaldata.userName ? originaldata.userName : '',
|
|
2202
|
+
userEmail: originaldata.userEmail ? originaldata.userEmail : '',
|
|
2203
|
+
store_id: storeDetails?.storeId ? storeDetails.storeId : '',
|
|
2204
|
+
storeName: originaldata?.storeName ? originaldata?.storeName : '',
|
|
2205
|
+
city: storeDetails?.storeProfile?.city ? storeDetails?.storeProfile?.city : '',
|
|
2197
2206
|
checkFlag: true,
|
|
2198
2207
|
checkListId: response?._id,
|
|
2199
2208
|
checkListName: data.checkListName,
|
|
2200
2209
|
client_id: inputBody.clientId,
|
|
2201
|
-
userId: userDetailList&&userDetailList._id?userDetailList._id:'',
|
|
2210
|
+
userId: userDetailList && userDetailList._id ? userDetailList._id : '',
|
|
2202
2211
|
assignId: response?.coverage == 'store' ? storeDetails?._id : userDetailList._id,
|
|
2203
2212
|
coverage: response?.coverage || 'store',
|
|
2204
2213
|
};
|
|
@@ -2257,7 +2266,7 @@ export async function createChecklistMultiTask( req, res ) {
|
|
|
2257
2266
|
if ( !searchResponse.ok ) {
|
|
2258
2267
|
return res.sendError( 'Something went wrong', 500 );
|
|
2259
2268
|
}
|
|
2260
|
-
let logData= {
|
|
2269
|
+
let logData = {
|
|
2261
2270
|
'client_id': inputBody.clientId,
|
|
2262
2271
|
'createAt': new Date(),
|
|
2263
2272
|
'sourceCheckList_id': response._id,
|
|
@@ -2265,8 +2274,8 @@ export async function createChecklistMultiTask( req, res ) {
|
|
|
2265
2274
|
'fromCheckListName': taskDetails.checkListName,
|
|
2266
2275
|
'type': 'task',
|
|
2267
2276
|
'action': 'task_created',
|
|
2268
|
-
'store_id': storeDetails?.storeId?storeDetails.storeId:'',
|
|
2269
|
-
'storeName': originaldata?.storeName?originaldata?.storeName:'',
|
|
2277
|
+
'store_id': storeDetails?.storeId ? storeDetails.storeId : '',
|
|
2278
|
+
'storeName': originaldata?.storeName ? originaldata?.storeName : '',
|
|
2270
2279
|
'createdByEmail': req.user.email,
|
|
2271
2280
|
'createdBy': req.user._id,
|
|
2272
2281
|
// 'userName': inputBody.userName,
|
|
@@ -2342,7 +2351,7 @@ export async function approveTask( req, res ) {
|
|
|
2342
2351
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
2343
2352
|
|
|
2344
2353
|
let searchResponse = await fetch( url.approveTask, requestOptions );
|
|
2345
|
-
let logData= {
|
|
2354
|
+
let logData = {
|
|
2346
2355
|
'client_id': taskDetails[0].client_id,
|
|
2347
2356
|
'createAt': new Date(),
|
|
2348
2357
|
'sourceCheckList_id': req.body.sourceCheckList_id,
|
|
@@ -2438,8 +2447,8 @@ export async function redoTask( req, res ) {
|
|
|
2438
2447
|
sectionName: question[sectionIndex].sectionName,
|
|
2439
2448
|
questionName: question[sectionIndex].questions[req.body.payload.qno - 1].qname,
|
|
2440
2449
|
action: 'redo',
|
|
2441
|
-
store_id: taskDetails?.store_id?taskDetails?.store_id:'',
|
|
2442
|
-
storeName: taskDetails.storeName?taskDetails.storeName:'',
|
|
2450
|
+
store_id: taskDetails?.store_id ? taskDetails?.store_id : '',
|
|
2451
|
+
storeName: taskDetails.storeName ? taskDetails.storeName : '',
|
|
2443
2452
|
client_id: taskDetails.client_id,
|
|
2444
2453
|
processedChecklistId: taskDetails._id,
|
|
2445
2454
|
type: taskDetails.checkListType,
|
|
@@ -2462,7 +2471,7 @@ export async function redoTask( req, res ) {
|
|
|
2462
2471
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
2463
2472
|
let searchResponse = await fetch( url.redoTask, requestOptions );
|
|
2464
2473
|
// console.log( searchResponse.ok );
|
|
2465
|
-
let logData= {
|
|
2474
|
+
let logData = {
|
|
2466
2475
|
'client_id': taskDetails.client_id,
|
|
2467
2476
|
'createAt': new Date(),
|
|
2468
2477
|
'sourceCheckList_id': taskDetails.sourceCheckList_id,
|
|
@@ -2470,8 +2479,8 @@ export async function redoTask( req, res ) {
|
|
|
2470
2479
|
'fromCheckListName': taskDetails.checkListName,
|
|
2471
2480
|
'type': 'task',
|
|
2472
2481
|
'action': 'redo',
|
|
2473
|
-
'storeName': taskDetails?.storeName?taskDetails?.storeName:'',
|
|
2474
|
-
'store_id': taskDetails?.store_id?taskDetails?.store_id:'',
|
|
2482
|
+
'storeName': taskDetails?.storeName ? taskDetails?.storeName : '',
|
|
2483
|
+
'store_id': taskDetails?.store_id ? taskDetails?.store_id : '',
|
|
2475
2484
|
'userName': taskDetails.userName,
|
|
2476
2485
|
'userEmail': taskDetails.userEmail,
|
|
2477
2486
|
'createdByEmail': req.user.email,
|
|
@@ -2498,7 +2507,7 @@ export async function redoTask( req, res ) {
|
|
|
2498
2507
|
}
|
|
2499
2508
|
export async function redomultiTask( req, res ) {
|
|
2500
2509
|
try {
|
|
2501
|
-
let inputData = req.body.payload.coverage==='user'?req.body.payload.userEmail:req.body.payload.storeName;
|
|
2510
|
+
let inputData = req.body.payload.coverage === 'user' ? req.body.payload.userEmail : req.body.payload.storeName;
|
|
2502
2511
|
|
|
2503
2512
|
|
|
2504
2513
|
for ( let originalData of inputData ) {
|
|
@@ -2553,8 +2562,8 @@ export async function redomultiTask( req, res ) {
|
|
|
2553
2562
|
sectionName: question[sectionIndex].sectionName,
|
|
2554
2563
|
questionName: question[sectionIndex].questions[req.body.payload.qno - 1].qname,
|
|
2555
2564
|
action: 'multiredo',
|
|
2556
|
-
store_id: taskDetails?.store_id?taskDetails?.store_id:'',
|
|
2557
|
-
storeName: taskDetails.storeName?taskDetails.storeName:'',
|
|
2565
|
+
store_id: taskDetails?.store_id ? taskDetails?.store_id : '',
|
|
2566
|
+
storeName: taskDetails.storeName ? taskDetails.storeName : '',
|
|
2558
2567
|
client_id: taskDetails.client_id,
|
|
2559
2568
|
processedChecklistId: taskDetails._id,
|
|
2560
2569
|
type: taskDetails.checkListType,
|
|
@@ -2565,9 +2574,9 @@ export async function redomultiTask( req, res ) {
|
|
|
2565
2574
|
submitedBy: taskDetails.userName,
|
|
2566
2575
|
submitTime: taskDetails.submitTime,
|
|
2567
2576
|
};
|
|
2568
|
-
req.body.payload._id=originalData.checklistId;
|
|
2569
|
-
req.body.payload.section_id=originalData.section_id;
|
|
2570
|
-
req.body.payload.uniqueNo=originalData.uniqueNo;
|
|
2577
|
+
req.body.payload._id = originalData.checklistId;
|
|
2578
|
+
req.body.payload.section_id = originalData.section_id;
|
|
2579
|
+
req.body.payload.uniqueNo = originalData.uniqueNo;
|
|
2571
2580
|
await checklistLogs.create( data );
|
|
2572
2581
|
const requestOptions = {
|
|
2573
2582
|
method: 'POST',
|
|
@@ -2579,7 +2588,7 @@ export async function redomultiTask( req, res ) {
|
|
|
2579
2588
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
2580
2589
|
let searchResponse = await fetch( url.redoTask, requestOptions );
|
|
2581
2590
|
console.log( searchResponse.ok );
|
|
2582
|
-
let logData= {
|
|
2591
|
+
let logData = {
|
|
2583
2592
|
'client_id': taskDetails.client_id,
|
|
2584
2593
|
'createAt': new Date(),
|
|
2585
2594
|
'sourceCheckList_id': taskDetails.sourceCheckList_id,
|
|
@@ -2587,8 +2596,8 @@ export async function redomultiTask( req, res ) {
|
|
|
2587
2596
|
'fromCheckListName': taskDetails.checkListName,
|
|
2588
2597
|
'type': 'task',
|
|
2589
2598
|
'action': 'redo',
|
|
2590
|
-
'storeName': taskDetails?.storeName?taskDetails?.storeName:'',
|
|
2591
|
-
'store_id': taskDetails?.store_id?taskDetails?.store_id:'',
|
|
2599
|
+
'storeName': taskDetails?.storeName ? taskDetails?.storeName : '',
|
|
2600
|
+
'store_id': taskDetails?.store_id ? taskDetails?.store_id : '',
|
|
2592
2601
|
'userName': taskDetails.userName,
|
|
2593
2602
|
'userEmail': taskDetails.userEmail,
|
|
2594
2603
|
'createdByEmail': req.user.email,
|
|
@@ -3452,7 +3461,7 @@ export async function StoreHygienetask( req, res ) {
|
|
|
3452
3461
|
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
3453
3462
|
let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
|
|
3454
3463
|
let userDetails = await userService.findOne( { _id: new mongoose.Types.ObjectId( finduser.userId ) } );
|
|
3455
|
-
if ( userDetails&&userDetails.fcmToken ) {
|
|
3464
|
+
if ( userDetails && userDetails.fcmToken ) {
|
|
3456
3465
|
const fcmToken = userDetails.fcmToken;
|
|
3457
3466
|
await sendPushNotification( title, description, fcmToken );
|
|
3458
3467
|
}
|
|
@@ -3480,7 +3489,7 @@ export async function StoreHygienetask( req, res ) {
|
|
|
3480
3489
|
return res.sendError( 'Maximum 3 referenceImage only allowed', 500 );
|
|
3481
3490
|
}
|
|
3482
3491
|
let data = {
|
|
3483
|
-
checkListName: `${inputBody.taskName}(${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}-${inputBody.zoneName?inputBody.zoneName:''})`,
|
|
3492
|
+
checkListName: `${inputBody.taskName}(${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}-${inputBody.zoneName ? inputBody.zoneName : ''})`,
|
|
3484
3493
|
checkListDescription: inputBody.taskDescription,
|
|
3485
3494
|
createdBy: creator[0]._id,
|
|
3486
3495
|
createdByName: creator[0].userName,
|
|
@@ -3671,7 +3680,7 @@ export async function eyeTesttask( req, res ) {
|
|
|
3671
3680
|
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
3672
3681
|
let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
|
|
3673
3682
|
let userDetails = await userService.findOne( { _id: new mongoose.Types.ObjectId( finduser.userId ) } );
|
|
3674
|
-
if ( userDetails&&userDetails.fcmToken ) {
|
|
3683
|
+
if ( userDetails && userDetails.fcmToken ) {
|
|
3675
3684
|
const fcmToken = userDetails.fcmToken;
|
|
3676
3685
|
await sendPushNotification( title, description, fcmToken );
|
|
3677
3686
|
}
|
|
@@ -3803,7 +3812,7 @@ export async function eyeTesttask( req, res ) {
|
|
|
3803
3812
|
question[0].questionReferenceImage = images;
|
|
3804
3813
|
} else {
|
|
3805
3814
|
let images = [];
|
|
3806
|
-
if ( req.files&&req.files.referenceImage ) {
|
|
3815
|
+
if ( req.files && req.files.referenceImage ) {
|
|
3807
3816
|
let uplaodedImage = await uploadmultiImage( req.files.referenceImage );
|
|
3808
3817
|
let imgUrl = decodeURIComponent( uplaodedImage.imgUrl.split( '?' )[0] );
|
|
3809
3818
|
let url = imgUrl.split( '/' );
|
|
@@ -3879,7 +3888,7 @@ export async function createAiTask( req, res ) {
|
|
|
3879
3888
|
let time = inputBody?.scheduleEndTime || '11:59 PM';
|
|
3880
3889
|
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
3881
3890
|
let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
|
|
3882
|
-
if ( userDetails&&userDetails.fcmToken ) {
|
|
3891
|
+
if ( userDetails && userDetails.fcmToken ) {
|
|
3883
3892
|
const fcmToken = userDetails.fcmToken;
|
|
3884
3893
|
await sendPushNotification( title, description, fcmToken );
|
|
3885
3894
|
}
|
|
@@ -4424,11 +4433,11 @@ export async function taskAssign( req, res ) {
|
|
|
4424
4433
|
return acc;
|
|
4425
4434
|
}, {} );
|
|
4426
4435
|
|
|
4427
|
-
uniqueArr= Object.values( uniqueArr );
|
|
4436
|
+
uniqueArr = Object.values( uniqueArr );
|
|
4428
4437
|
} else {
|
|
4429
4438
|
uniqueArr = uniqueArr.reduce( ( acc, obj ) => {
|
|
4430
4439
|
if ( acc[obj.userEmail] ) {
|
|
4431
|
-
acc[obj.userEmail].teamName += ','+ obj.teamName;
|
|
4440
|
+
acc[obj.userEmail].teamName += ',' + obj.teamName;
|
|
4432
4441
|
acc[obj.userEmail].id.push( ...obj.id );
|
|
4433
4442
|
} else {
|
|
4434
4443
|
acc[obj.userEmail] = { ...obj };
|
|
@@ -4483,7 +4492,7 @@ export async function updateAssign( req, res ) {
|
|
|
4483
4492
|
let storeClusterDetails = getAssignedDetails.filter( ( ele ) => ele?.storeName || ele?.clusterName );
|
|
4484
4493
|
let userTeamDetails = getAssignedDetails.filter( ( ele ) => !ele?.storeName && ( ele?.userName || ele?.teamName ) );
|
|
4485
4494
|
storeClusterDetails = [ ...new Set( storeClusterDetails.map( ( ele ) => ele?.storeName || ele?.clusterName ) ) ];
|
|
4486
|
-
userTeamDetails= [ ...new Set( userTeamDetails.map( ( ele ) => ele?.userName || ele?.teamName ) ) ];
|
|
4495
|
+
userTeamDetails = [ ...new Set( userTeamDetails.map( ( ele ) => ele?.userName || ele?.teamName ) ) ];
|
|
4487
4496
|
getAssignedDetails = [ ...storeClusterDetails, ...userTeamDetails ];
|
|
4488
4497
|
}
|
|
4489
4498
|
|
|
@@ -4643,7 +4652,7 @@ export async function commonAiTask( req, res ) {
|
|
|
4643
4652
|
let time = inputBody?.scheduleEndTime || '11:59 PM';
|
|
4644
4653
|
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
4645
4654
|
let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
|
|
4646
|
-
if ( userDetails&&userDetails.fcmToken ) {
|
|
4655
|
+
if ( userDetails && userDetails.fcmToken ) {
|
|
4647
4656
|
const fcmToken = userDetails.fcmToken;
|
|
4648
4657
|
await sendPushNotification( title, description, fcmToken );
|
|
4649
4658
|
}
|
|
@@ -4838,7 +4847,7 @@ export async function taskcreation( req, res ) {
|
|
|
4838
4847
|
let time = inputBody?.scheduleEndTime || '11:59 PM';
|
|
4839
4848
|
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
4840
4849
|
let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
|
|
4841
|
-
if ( userDetails&&userDetails.fcmToken ) {
|
|
4850
|
+
if ( userDetails && userDetails.fcmToken ) {
|
|
4842
4851
|
const fcmToken = userDetails.fcmToken;
|
|
4843
4852
|
await sendPushNotification( title, description, fcmToken );
|
|
4844
4853
|
}
|
|
@@ -4931,7 +4940,7 @@ export async function taskcreation( req, res ) {
|
|
|
4931
4940
|
}
|
|
4932
4941
|
}
|
|
4933
4942
|
question.push( {
|
|
4934
|
-
'qno': index+1,
|
|
4943
|
+
'qno': index + 1,
|
|
4935
4944
|
'qname': ques.question,
|
|
4936
4945
|
'answerType': ques?.answerType || 'yes/no',
|
|
4937
4946
|
'runAI': false,
|
|
@@ -5003,6 +5012,38 @@ export async function taskcreation( req, res ) {
|
|
|
5003
5012
|
return res.sendError( e, 500 );
|
|
5004
5013
|
}
|
|
5005
5014
|
}
|
|
5015
|
+
|
|
5016
|
+
export async function getTask( req, res ) {
|
|
5017
|
+
try {
|
|
5018
|
+
let findTask = await taskProcessedService.findOne( { sourceCheckList_id: new mongoose.Types.ObjectId( req.query.sourceCheckList_id ), checklistStatus: 'submit' },
|
|
5019
|
+
{
|
|
5020
|
+
date_string: 1,
|
|
5021
|
+
checkListName: 1,
|
|
5022
|
+
createdByName: 1,
|
|
5023
|
+
store_id: 1,
|
|
5024
|
+
storeName: 1,
|
|
5025
|
+
submmitedBy: '$userName',
|
|
5026
|
+
submmitedByEmail: '$userEmail',
|
|
5027
|
+
checklistStatus: 1,
|
|
5028
|
+
submitTime: 1,
|
|
5029
|
+
approvalTime: 1,
|
|
5030
|
+
approvalTime_string: 1,
|
|
5031
|
+
approvalByName: 1,
|
|
5032
|
+
approvalByEmail: 1,
|
|
5033
|
+
} );
|
|
5034
|
+
if ( !findTask ) {
|
|
5035
|
+
return res.sendError( 'nodata', 204 );
|
|
5036
|
+
}
|
|
5037
|
+
|
|
5038
|
+
|
|
5039
|
+
res.sendSuccess( findTask );
|
|
5040
|
+
} catch ( e ) {
|
|
5041
|
+
logger.error( { function: 'getTask ventota', error: e } );
|
|
5042
|
+
return res.sendError( e, 500 );
|
|
5043
|
+
}
|
|
5044
|
+
}
|
|
5045
|
+
|
|
5046
|
+
|
|
5006
5047
|
export async function breachedTasks( req, res ) {
|
|
5007
5048
|
try {
|
|
5008
5049
|
let inputBody = req.body;
|
|
@@ -5043,7 +5084,7 @@ export async function breachedTasks( req, res ) {
|
|
|
5043
5084
|
let time = inputBody?.scheduleEndTime || '11:59 PM';
|
|
5044
5085
|
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
5045
5086
|
let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
|
|
5046
|
-
if ( userDetails&&userDetails.fcmToken ) {
|
|
5087
|
+
if ( userDetails && userDetails.fcmToken ) {
|
|
5047
5088
|
const fcmToken = userDetails.fcmToken;
|
|
5048
5089
|
await sendPushNotification( title, description, fcmToken );
|
|
5049
5090
|
}
|
|
@@ -5166,7 +5207,7 @@ export async function breachedTasks( req, res ) {
|
|
|
5166
5207
|
}
|
|
5167
5208
|
}
|
|
5168
5209
|
question.push( {
|
|
5169
|
-
'qno': index+1,
|
|
5210
|
+
'qno': index + 1,
|
|
5170
5211
|
'qname': ques.question,
|
|
5171
5212
|
'answerType': ques?.answerType || 'yes/no',
|
|
5172
5213
|
'runAI': false,
|
|
@@ -5242,3 +5283,27 @@ export async function breachedTasks( req, res ) {
|
|
|
5242
5283
|
}
|
|
5243
5284
|
}
|
|
5244
5285
|
|
|
5286
|
+
|
|
5287
|
+
export async function userMigrations( req, res ) {
|
|
5288
|
+
try {
|
|
5289
|
+
let array = [];
|
|
5290
|
+
for ( let user of array ) {
|
|
5291
|
+
let storeExists = await storeService.findOne( { storeName: user.storeName } );
|
|
5292
|
+
|
|
5293
|
+
let userexits = await userService.findOne( { email: user.userEmail } );
|
|
5294
|
+
|
|
5295
|
+
if ( userexits && storeExists ) {
|
|
5296
|
+
console.log( user.userEmail, storeExists.storeId );
|
|
5297
|
+
let update = await userService.update(
|
|
5298
|
+
{ email: user.userEmail },
|
|
5299
|
+
{ $push: { assignedStores: { storeId: storeExists.storeId, store: storeExists._id } } },
|
|
5300
|
+
);
|
|
5301
|
+
console.log( update );
|
|
5302
|
+
}
|
|
5303
|
+
}
|
|
5304
|
+
res.sendSuccess( 'completed' );
|
|
5305
|
+
} catch ( error ) {
|
|
5306
|
+
logger.error( { function: 'userMigrations', error: error } );
|
|
5307
|
+
return res.sendError( error, 500 );
|
|
5308
|
+
}
|
|
5309
|
+
}
|
package/src/dtos/task.dto.js
CHANGED
|
@@ -50,6 +50,9 @@ const questionSchema = Joi.object( {
|
|
|
50
50
|
answerType: Joi.string().required(),
|
|
51
51
|
options: Joi.array().items().optional(),
|
|
52
52
|
} );
|
|
53
|
+
const gettaskSchema = Joi.object( {
|
|
54
|
+
sourceCheckList_id: Joi.string().required(),
|
|
55
|
+
} );
|
|
53
56
|
export const taskcreationSchema = Joi.object().keys( {
|
|
54
57
|
storeName: Joi.string().required(),
|
|
55
58
|
taskName: Joi.string().required(),
|
|
@@ -67,6 +70,9 @@ export const commonAiTaskvalidation = {
|
|
|
67
70
|
export const taskcreationvalidation = {
|
|
68
71
|
body: taskcreationSchema,
|
|
69
72
|
};
|
|
73
|
+
export const gettaskvalidation = {
|
|
74
|
+
query: gettaskSchema,
|
|
75
|
+
};
|
|
70
76
|
export const aitaskvalidation = {
|
|
71
77
|
body: aitaskvalidationSchema,
|
|
72
78
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as taskController from '../controllers/task.controller.js';
|
|
3
3
|
import { isAllowedSessionHandler, validate, accessVerification, isAllowedClient, isAllowedInternalAPIHandler } from 'tango-app-api-middleware';
|
|
4
4
|
import express from 'express';
|
|
5
|
-
import { aitaskvalidation, StoreHygienetaskvalidation, eyeTesttaskvalidation, commonAiTaskvalidation, taskcreationvalidation } from '../dtos/task.dto.js';
|
|
5
|
+
import { aitaskvalidation, StoreHygienetaskvalidation, eyeTesttaskvalidation, commonAiTaskvalidation, taskcreationvalidation, gettaskvalidation } from '../dtos/task.dto.js';
|
|
6
6
|
export const taskRouter = express.Router();
|
|
7
7
|
|
|
8
8
|
taskRouter
|
|
@@ -29,6 +29,7 @@ taskRouter
|
|
|
29
29
|
.get( '/duplicateTask/:checklistId', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.duplicateChecklist )
|
|
30
30
|
.get( '/teamMigrations', taskController.teamMigrations )
|
|
31
31
|
.get( '/clusterMigrations', taskController.clusterMigrations )
|
|
32
|
+
.get( '/userMigrations', taskController.userMigrations )
|
|
32
33
|
.post( '/createaiChecklist', isAllowedInternalAPIHandler, taskController.createAiChecklist )
|
|
33
34
|
.post( '/createaiTask', isAllowedInternalAPIHandler, taskController.createAiTask )
|
|
34
35
|
.post( '/assign', isAllowedSessionHandler, taskController.taskAssign )
|
|
@@ -38,6 +39,7 @@ taskRouter
|
|
|
38
39
|
.post( '/commonAiTask', isAllowedInternalAPIHandler, validate( commonAiTaskvalidation ), taskController.commonAiTask )
|
|
39
40
|
.post( '/updateAssign', isAllowedSessionHandler, taskController.updateAssign )
|
|
40
41
|
.post( '/taskcreation', isAllowedInternalAPIHandler, validate( taskcreationvalidation ), taskController.taskcreation )
|
|
42
|
+
.get( '/getTask', isAllowedInternalAPIHandler, validate( gettaskvalidation ), taskController.getTask )
|
|
41
43
|
.post( '/breached-tasks', isAllowedInternalAPIHandler, validate( taskcreationvalidation ), taskController.breachedTasks )
|
|
42
44
|
.get( '/getcoustemer', taskController.customertrial );
|
|
43
45
|
|
|
@@ -19,6 +19,9 @@ export const deleteOne = async ( query = {} ) => {
|
|
|
19
19
|
export const updateOne = async ( query = {}, record={} ) => {
|
|
20
20
|
return model.userModel.updateOne( query, { $set: record } );
|
|
21
21
|
};
|
|
22
|
+
export const update= async ( query = {}, record={} ) => {
|
|
23
|
+
return model.userModel.updateOne( query, record );
|
|
24
|
+
};
|
|
22
25
|
|
|
23
26
|
export const upsert = async ( query = {}, record={} ) => {
|
|
24
27
|
return model.userModel.updateOne( query, { $set: record }, { upsert: true } );
|