tango-app-api-task 3.2.0-beta.8 → 3.2.1-beta-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
|
@@ -436,9 +436,9 @@ export async function validateUser( req, res ) {
|
|
|
436
436
|
if ( !storeExists.length ) {
|
|
437
437
|
storeId.push( { store: item.storeName, message: '' } );
|
|
438
438
|
}
|
|
439
|
-
if ( storeExists.length && !storeExists[0]?.storeProfile?.city && !item.city ) {
|
|
440
|
-
|
|
441
|
-
}
|
|
439
|
+
// if ( storeExists.length && !storeExists[0]?.storeProfile?.city && !item.city ) {
|
|
440
|
+
// storeId.push( { store: item.storeName, message: 'city is required' } );
|
|
441
|
+
// }
|
|
442
442
|
if ( storeExists.length && storeExists[0].status != 'active' ) {
|
|
443
443
|
storeId.push( { store: item.storeName, message: 'store is inactive' } );
|
|
444
444
|
}
|
|
@@ -1087,6 +1087,78 @@ async function createUser( data ) {
|
|
|
1087
1087
|
role: 'user',
|
|
1088
1088
|
password: '5dqFKAJj29PsV6P+kL+3Dw==',
|
|
1089
1089
|
isActive: true,
|
|
1090
|
+
userType: 'client',
|
|
1091
|
+
rolespermission: [
|
|
1092
|
+
{
|
|
1093
|
+
featureName: 'Global',
|
|
1094
|
+
modules: [
|
|
1095
|
+
{
|
|
1096
|
+
name: 'Store',
|
|
1097
|
+
isAdd: false,
|
|
1098
|
+
isEdit: false,
|
|
1099
|
+
|
|
1100
|
+
},
|
|
1101
|
+
{
|
|
1102
|
+
name: 'User',
|
|
1103
|
+
isAdd: false,
|
|
1104
|
+
isEdit: false,
|
|
1105
|
+
|
|
1106
|
+
},
|
|
1107
|
+
{
|
|
1108
|
+
name: 'Camera',
|
|
1109
|
+
isAdd: false,
|
|
1110
|
+
isEdit: false,
|
|
1111
|
+
|
|
1112
|
+
},
|
|
1113
|
+
{
|
|
1114
|
+
name: 'Configuration',
|
|
1115
|
+
isAdd: false,
|
|
1116
|
+
isEdit: false,
|
|
1117
|
+
|
|
1118
|
+
},
|
|
1119
|
+
{
|
|
1120
|
+
name: 'Subscription',
|
|
1121
|
+
isAdd: false,
|
|
1122
|
+
isEdit: false,
|
|
1123
|
+
|
|
1124
|
+
},
|
|
1125
|
+
{
|
|
1126
|
+
name: 'Billing',
|
|
1127
|
+
isAdd: false,
|
|
1128
|
+
isEdit: false,
|
|
1129
|
+
|
|
1130
|
+
},
|
|
1131
|
+
],
|
|
1132
|
+
},
|
|
1133
|
+
{
|
|
1134
|
+
featurName: 'TangoEye',
|
|
1135
|
+
modules: [
|
|
1136
|
+
{
|
|
1137
|
+
name: 'ZoneTag',
|
|
1138
|
+
isAdd: false,
|
|
1139
|
+
isEdit: false,
|
|
1140
|
+
|
|
1141
|
+
},
|
|
1142
|
+
],
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
featurName: 'TangoTrax',
|
|
1146
|
+
modules: [
|
|
1147
|
+
{
|
|
1148
|
+
name: 'checklist',
|
|
1149
|
+
isAdd: false,
|
|
1150
|
+
isEdit: false,
|
|
1151
|
+
|
|
1152
|
+
},
|
|
1153
|
+
{
|
|
1154
|
+
name: 'Task',
|
|
1155
|
+
isAdd: false,
|
|
1156
|
+
isEdit: false,
|
|
1157
|
+
|
|
1158
|
+
},
|
|
1159
|
+
],
|
|
1160
|
+
},
|
|
1161
|
+
],
|
|
1090
1162
|
};
|
|
1091
1163
|
let response = await userService.create( params );
|
|
1092
1164
|
return response._id;
|
|
@@ -1211,7 +1283,6 @@ export async function createChecklistTask( req, res ) {
|
|
|
1211
1283
|
await sendPushNotification( title, description, fcmToken );
|
|
1212
1284
|
}
|
|
1213
1285
|
|
|
1214
|
-
|
|
1215
1286
|
let time = inputBody?.scheduleEndTime || '11:59 PM';
|
|
1216
1287
|
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
1217
1288
|
let data = {
|
|
@@ -1314,7 +1385,7 @@ export async function createChecklistTask( req, res ) {
|
|
|
1314
1385
|
return res.sendError( 'No data found', 204 );
|
|
1315
1386
|
}
|
|
1316
1387
|
let question = taskDetails.questionAnswers;
|
|
1317
|
-
let sectionIndex = question.findIndex( ( sec ) => sec
|
|
1388
|
+
let sectionIndex = question.findIndex( ( sec ) => sec?.sectionName == req.body?.sectionName );
|
|
1318
1389
|
if ( sectionIndex == -1 ) {
|
|
1319
1390
|
return res.sendError( 'section is not found', 400 );
|
|
1320
1391
|
}
|
|
@@ -15361,7 +15432,8 @@ export async function teamMigrations( req, res ) {
|
|
|
15361
15432
|
},
|
|
15362
15433
|
],
|
|
15363
15434
|
};
|
|
15364
|
-
|
|
15435
|
+
await createTeamsModel( payload );
|
|
15436
|
+
// const teams = await createTeamsModel( payload );
|
|
15365
15437
|
} else {
|
|
15366
15438
|
let userIn = teamsExist.users.filter( ( data ) => data.email === userexits.userName );
|
|
15367
15439
|
if ( userIn.length==0 ) {
|
|
@@ -15385,3 +15457,156 @@ export async function teamMigrations( req, res ) {
|
|
|
15385
15457
|
return res.sendError( error, 500 );
|
|
15386
15458
|
}
|
|
15387
15459
|
}
|
|
15460
|
+
|
|
15461
|
+
export async function createAiChecklist( req, res ) {
|
|
15462
|
+
try {
|
|
15463
|
+
let inputBody = req.body;
|
|
15464
|
+
let userId;
|
|
15465
|
+
let storeDetails = await storeService.findOne( { storeId: inputBody.storeId, status: 'active' }, { storeId: 1, storeName: 1, storeProfile: 1 } );
|
|
15466
|
+
let userDetails = await userService.findOne( { email: inputBody.userEmail } );
|
|
15467
|
+
if ( !userDetails ) {
|
|
15468
|
+
let userData = {
|
|
15469
|
+
userName: inputBody.name,
|
|
15470
|
+
email: inputBody.userEmail,
|
|
15471
|
+
mobileNumber: '',
|
|
15472
|
+
clientId: inputBody.clientId,
|
|
15473
|
+
};
|
|
15474
|
+
userId = await createUser( userData );
|
|
15475
|
+
} else {
|
|
15476
|
+
userId = userDetails._id;
|
|
15477
|
+
}
|
|
15478
|
+
|
|
15479
|
+
let title = `New Task Alert ${inputBody.taskName}`;
|
|
15480
|
+
let time = inputBody?.scheduleEndTime || '11:59 PM';
|
|
15481
|
+
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
15482
|
+
let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
|
|
15483
|
+
if ( userDetails.fcmToken ) {
|
|
15484
|
+
const fcmToken = userDetails.fcmToken;
|
|
15485
|
+
await sendPushNotification( title, description, fcmToken );
|
|
15486
|
+
}
|
|
15487
|
+
|
|
15488
|
+
let userAdmin = await userService.findOne( { clientId: inputBody.clientId, role: 'superadmin', isActive: true } );
|
|
15489
|
+
console.log( userAdmin );
|
|
15490
|
+
|
|
15491
|
+
let data = {
|
|
15492
|
+
checkListName: inputBody.taskName,
|
|
15493
|
+
checkListDescription: inputBody.checkListDescription,
|
|
15494
|
+
createdBy: userAdmin._id,
|
|
15495
|
+
createdByName: userAdmin.userName,
|
|
15496
|
+
publish: true,
|
|
15497
|
+
questionCount: 1,
|
|
15498
|
+
storeCount: 1,
|
|
15499
|
+
scheduleDate: date,
|
|
15500
|
+
scheduleEndTime: time,
|
|
15501
|
+
scheduleEndTimeISO: dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' ).format(),
|
|
15502
|
+
priorityType: 'high',
|
|
15503
|
+
client_id: inputBody.clientId,
|
|
15504
|
+
checkListType: 'task',
|
|
15505
|
+
publishDate: new Date(),
|
|
15506
|
+
locationCount: 1,
|
|
15507
|
+
...( inputBody?.checkListId ) ? { referenceCheckListId: inputBody?.checkListId } : {},
|
|
15508
|
+
};
|
|
15509
|
+
|
|
15510
|
+
|
|
15511
|
+
data['approver'] = { name: userAdmin.userName, value: userAdmin.email };
|
|
15512
|
+
|
|
15513
|
+
|
|
15514
|
+
let response = await taskService.create( data );
|
|
15515
|
+
if ( response?.approver.length ) {
|
|
15516
|
+
let data = [];
|
|
15517
|
+
response?.approver.forEach( ( ele ) => {
|
|
15518
|
+
data.push( {
|
|
15519
|
+
userEmail: ele.value,
|
|
15520
|
+
checkListId: response._id,
|
|
15521
|
+
type: 'task',
|
|
15522
|
+
client_id: inputBody.clientId,
|
|
15523
|
+
checkListName: inputBody?.taskName || '',
|
|
15524
|
+
} );
|
|
15525
|
+
} );
|
|
15526
|
+
await traxApprover.insertMany( data );
|
|
15527
|
+
}
|
|
15528
|
+
|
|
15529
|
+
if ( response?._id ) {
|
|
15530
|
+
let question = [
|
|
15531
|
+
{
|
|
15532
|
+
'qno': 1,
|
|
15533
|
+
'qname': inputBody.question,
|
|
15534
|
+
'answerType': inputBody?.answerType || 'yes/no',
|
|
15535
|
+
'runAI': false,
|
|
15536
|
+
'runAIDescription': '',
|
|
15537
|
+
'allowUploadfromGallery': false,
|
|
15538
|
+
'linkType': false,
|
|
15539
|
+
'questionReferenceImage': [],
|
|
15540
|
+
'answers': [
|
|
15541
|
+
{
|
|
15542
|
+
'answer': 'Yes',
|
|
15543
|
+
'answeroptionNumber': 1,
|
|
15544
|
+
'sopFlag': false,
|
|
15545
|
+
'validation': false,
|
|
15546
|
+
'validationType': '',
|
|
15547
|
+
'linkedQuestion': 0,
|
|
15548
|
+
'showLinked': false,
|
|
15549
|
+
'referenceImage': '',
|
|
15550
|
+
'runAI': false,
|
|
15551
|
+
'allowUploadfromGallery': false,
|
|
15552
|
+
'descriptivetype': '',
|
|
15553
|
+
},
|
|
15554
|
+
{
|
|
15555
|
+
'answer': 'No',
|
|
15556
|
+
'answeroptionNumber': 2,
|
|
15557
|
+
'sopFlag': false,
|
|
15558
|
+
'validation': false,
|
|
15559
|
+
'validationType': '',
|
|
15560
|
+
'linkedQuestion': 0,
|
|
15561
|
+
'showLinked': false,
|
|
15562
|
+
'referenceImage': '',
|
|
15563
|
+
'runAI': false,
|
|
15564
|
+
'allowUploadfromGallery': false,
|
|
15565
|
+
'descriptivetype': '',
|
|
15566
|
+
},
|
|
15567
|
+
],
|
|
15568
|
+
'descriptivetype': 'text',
|
|
15569
|
+
},
|
|
15570
|
+
];
|
|
15571
|
+
if ( inputBody.referenceImage.length ) {
|
|
15572
|
+
let images = [];
|
|
15573
|
+
question[0].questionReferenceImage.forEach( ( ele ) => {
|
|
15574
|
+
let imgUrl = decodeURIComponent( ele.split( '?' )[0] );
|
|
15575
|
+
let url = imgUrl.split( '/' );
|
|
15576
|
+
if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
|
|
15577
|
+
url.splice( 0, 3 );
|
|
15578
|
+
}
|
|
15579
|
+
images.push( url.join( '/' ) );
|
|
15580
|
+
} );
|
|
15581
|
+
question[0].questionReferenceImage = images;
|
|
15582
|
+
}
|
|
15583
|
+
question = {
|
|
15584
|
+
checkListId: response?._id,
|
|
15585
|
+
question: question,
|
|
15586
|
+
section: 'Section 1',
|
|
15587
|
+
checkList: data.checkListName,
|
|
15588
|
+
client_id: inputBody.clientId,
|
|
15589
|
+
};
|
|
15590
|
+
await taskQuestionService.create( question );
|
|
15591
|
+
|
|
15592
|
+
let userDetails = {
|
|
15593
|
+
userName: inputBody.userName,
|
|
15594
|
+
userEmail: inputBody.userEmail,
|
|
15595
|
+
store_id: storeDetails.storeId,
|
|
15596
|
+
storeName: storeDetails.storeName,
|
|
15597
|
+
city: storeDetails?.storeProfile?.city,
|
|
15598
|
+
checkFlag: true,
|
|
15599
|
+
checkListId: response?._id,
|
|
15600
|
+
checkListName: data.checkListName,
|
|
15601
|
+
client_id: inputBody.clientId,
|
|
15602
|
+
userId: userId,
|
|
15603
|
+
};
|
|
15604
|
+
await taskAssignService.create( userDetails );
|
|
15605
|
+
await insertSingleProcessData( response?._id );
|
|
15606
|
+
return res.sendSuccess( 'Task created successfully' );
|
|
15607
|
+
}
|
|
15608
|
+
} catch ( e ) {
|
|
15609
|
+
logger.error( { function: createAiChecklist, error: e } );
|
|
15610
|
+
return res.sendError( e, 500 );
|
|
15611
|
+
}
|
|
15612
|
+
}
|
|
@@ -990,7 +990,7 @@ export async function taskDetails( req, res ) {
|
|
|
990
990
|
$match: {
|
|
991
991
|
date_iso: { $gte: new Date( req.body.fromDate ), $lte: toDate },
|
|
992
992
|
client_id: req.body.clientId,
|
|
993
|
-
|
|
993
|
+
store_id: { $in: req.body.storeId },
|
|
994
994
|
...( idList.length ) ? { sourceCheckList_id: { $in: idList } } : {},
|
|
995
995
|
},
|
|
996
996
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import * as taskController from '../controllers/task.controller.js';
|
|
3
|
-
import { isAllowedSessionHandler, accessVerification, isAllowedClient } from 'tango-app-api-middleware';
|
|
3
|
+
import { isAllowedSessionHandler, accessVerification, isAllowedClient, isAllowedInternalAPIHandler } from 'tango-app-api-middleware';
|
|
4
4
|
import express from 'express';
|
|
5
5
|
|
|
6
6
|
export const taskRouter = express.Router();
|
|
@@ -25,6 +25,7 @@ taskRouter
|
|
|
25
25
|
.get( '/task-list', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ ] } ] } ), taskController.taskList )
|
|
26
26
|
.put( '/publish', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.updatePublish )
|
|
27
27
|
.get( '/duplicateTask/:checklistId', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.duplicateChecklist )
|
|
28
|
-
.get( '/teamMigrations', taskController.teamMigrations )
|
|
28
|
+
.get( '/teamMigrations', taskController.teamMigrations )
|
|
29
|
+
.post( '/createaiChecklist', isAllowedInternalAPIHandler, taskController.createAiChecklist );
|
|
29
30
|
|
|
30
31
|
|