tango-app-api-task 3.7.2-multireff-3 → 3.7.5-halfshutter-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
|
@@ -1528,6 +1528,9 @@ async function insertPCBulkV3( getCLconfig, checklistId, updatedchecklist, date,
|
|
|
1528
1528
|
element4.coverage = getCLconfig?.coverage;
|
|
1529
1529
|
element4.checkListFrom = getCLconfig?.checkListFrom;
|
|
1530
1530
|
element4.zoneName = getCLconfig?.zoneName || '';
|
|
1531
|
+
element4.rawImageUpload = getCLconfig?.rawImageUpload || false;
|
|
1532
|
+
element4.rawVideoUpload = getCLconfig?.rawVideoUpload || false;
|
|
1533
|
+
element4.videoUploadTimeLimit = getCLconfig?.videoUploadTimeLimit || 0;
|
|
1531
1534
|
if ( inputBody && inputBody?.streamId ) {
|
|
1532
1535
|
element4.streamId = inputBody?.streamId;
|
|
1533
1536
|
}
|
|
@@ -5981,6 +5984,19 @@ async function insertStoreHygienetaskSingleProcessedTask( checkTask, inputBody,
|
|
|
5981
5984
|
newData.checkListType = 'task' || '';
|
|
5982
5985
|
let insertprocessdata = await taskProcessedService.insert( newData );
|
|
5983
5986
|
if ( insertprocessdata ) {
|
|
5987
|
+
if ( response?.approver.length ) {
|
|
5988
|
+
let inputData = [];
|
|
5989
|
+
response?.approver.forEach( ( ele ) => {
|
|
5990
|
+
inputData.push( {
|
|
5991
|
+
userEmail: ele.email,
|
|
5992
|
+
checkListId: response._id,
|
|
5993
|
+
type: 'task',
|
|
5994
|
+
client_id: inputBody.clientId,
|
|
5995
|
+
checkListName: data?.checkListName || '',
|
|
5996
|
+
} );
|
|
5997
|
+
} );
|
|
5998
|
+
await traxApprover.insertMany( inputData );
|
|
5999
|
+
}
|
|
5984
6000
|
return true;
|
|
5985
6001
|
} else {
|
|
5986
6002
|
return false;
|
|
@@ -6078,3 +6094,818 @@ async function insertEyetestSingleProcessedTask( checkTask, inputBody, date, tim
|
|
|
6078
6094
|
return false;
|
|
6079
6095
|
}
|
|
6080
6096
|
}
|
|
6097
|
+
|
|
6098
|
+
export async function createTaskGroup( req, res ) {
|
|
6099
|
+
try {
|
|
6100
|
+
let inputBody = req.body;
|
|
6101
|
+
|
|
6102
|
+
// inputBody.clientId = 11;
|
|
6103
|
+
inputBody.taskDescription = '';
|
|
6104
|
+
let userId;
|
|
6105
|
+
let storeData = await storeService.findOne( { storeName: inputBody.storeName, clientId: inputBody.clientId, status: 'active' }, { storeId: 1, storeName: 1, storeProfile: 1, spocDetails: 1 } );
|
|
6106
|
+
if ( !storeData ) {
|
|
6107
|
+
return res.sendError( 'Store Not Found', 500 );
|
|
6108
|
+
}
|
|
6109
|
+
|
|
6110
|
+
// let url = JSON.parse( process.env.LAMBDAURL );
|
|
6111
|
+
// let dailychecklistId = new mongoose.Types.ObjectId( url.dailystoreChecklistId );
|
|
6112
|
+
// let KSAchecklistId = new mongoose.Types.ObjectId( url.KSAchecklist );
|
|
6113
|
+
// let UAEchecklistId = new mongoose.Types.ObjectId( url.UAEchecklist );
|
|
6114
|
+
// let singaporechecklistId = new mongoose.Types.ObjectId( url.singaporechecklist );
|
|
6115
|
+
// let finduser = await checklistassignconfigModel.findOne( { checkListId: { $in: [ dailychecklistId, KSAchecklistId, UAEchecklistId, singaporechecklistId ] }, store_id: storeData.storeId } );
|
|
6116
|
+
let finduser;
|
|
6117
|
+
if ( inputBody.userEmail ) {
|
|
6118
|
+
let userFind = [
|
|
6119
|
+
{
|
|
6120
|
+
$match: {
|
|
6121
|
+
email: inputBody.userEmail,
|
|
6122
|
+
clientId: inputBody.clientId,
|
|
6123
|
+
},
|
|
6124
|
+
},
|
|
6125
|
+
{
|
|
6126
|
+
$project: {
|
|
6127
|
+
_id: 0,
|
|
6128
|
+
userId: '$_id',
|
|
6129
|
+
userName: 1,
|
|
6130
|
+
userEmail: '$email',
|
|
6131
|
+
},
|
|
6132
|
+
},
|
|
6133
|
+
];
|
|
6134
|
+
let finduserData = await userService.aggregate( userFind );
|
|
6135
|
+
// console.log( 'finduserData =>', finduserData );
|
|
6136
|
+
if ( finduserData && finduserData.length > 0 ) {
|
|
6137
|
+
finduser = finduserData[0];
|
|
6138
|
+
} else {
|
|
6139
|
+
// Create User//
|
|
6140
|
+
let params = {
|
|
6141
|
+
userName: inputBody.userEmail.split( '@' )[0],
|
|
6142
|
+
email: inputBody.userEmail,
|
|
6143
|
+
mobileNumber: inputBody?.mobileNumber || '0000000000',
|
|
6144
|
+
clientId: inputBody.clientId,
|
|
6145
|
+
role: 'user',
|
|
6146
|
+
password: '5dqFKAJj29PsV6P+kL+3Dw==',
|
|
6147
|
+
isActive: true,
|
|
6148
|
+
userType: 'client',
|
|
6149
|
+
rolespermission: [
|
|
6150
|
+
{
|
|
6151
|
+
featureName: 'Global',
|
|
6152
|
+
modules: [
|
|
6153
|
+
{
|
|
6154
|
+
name: 'Store',
|
|
6155
|
+
isAdd: false,
|
|
6156
|
+
isEdit: false,
|
|
6157
|
+
|
|
6158
|
+
},
|
|
6159
|
+
{
|
|
6160
|
+
name: 'User',
|
|
6161
|
+
isAdd: false,
|
|
6162
|
+
isEdit: false,
|
|
6163
|
+
|
|
6164
|
+
},
|
|
6165
|
+
{
|
|
6166
|
+
name: 'Camera',
|
|
6167
|
+
isAdd: false,
|
|
6168
|
+
isEdit: false,
|
|
6169
|
+
|
|
6170
|
+
},
|
|
6171
|
+
{
|
|
6172
|
+
name: 'Configuration',
|
|
6173
|
+
isAdd: false,
|
|
6174
|
+
isEdit: false,
|
|
6175
|
+
|
|
6176
|
+
},
|
|
6177
|
+
{
|
|
6178
|
+
name: 'Subscription',
|
|
6179
|
+
isAdd: false,
|
|
6180
|
+
isEdit: false,
|
|
6181
|
+
|
|
6182
|
+
},
|
|
6183
|
+
{
|
|
6184
|
+
name: 'Billing',
|
|
6185
|
+
isAdd: false,
|
|
6186
|
+
isEdit: false,
|
|
6187
|
+
|
|
6188
|
+
},
|
|
6189
|
+
],
|
|
6190
|
+
},
|
|
6191
|
+
{
|
|
6192
|
+
featurName: 'TangoEye',
|
|
6193
|
+
modules: [
|
|
6194
|
+
{
|
|
6195
|
+
name: 'ZoneTag',
|
|
6196
|
+
isAdd: false,
|
|
6197
|
+
isEdit: false,
|
|
6198
|
+
|
|
6199
|
+
},
|
|
6200
|
+
],
|
|
6201
|
+
},
|
|
6202
|
+
{
|
|
6203
|
+
featurName: 'TangoTrax',
|
|
6204
|
+
modules: [
|
|
6205
|
+
{
|
|
6206
|
+
name: 'checklist',
|
|
6207
|
+
isAdd: false,
|
|
6208
|
+
isEdit: false,
|
|
6209
|
+
|
|
6210
|
+
},
|
|
6211
|
+
{
|
|
6212
|
+
name: 'Task',
|
|
6213
|
+
isAdd: false,
|
|
6214
|
+
isEdit: false,
|
|
6215
|
+
|
|
6216
|
+
},
|
|
6217
|
+
],
|
|
6218
|
+
},
|
|
6219
|
+
],
|
|
6220
|
+
};
|
|
6221
|
+
let response = await userService.create( params );
|
|
6222
|
+
if ( response ) {
|
|
6223
|
+
finduser = [ { userId: response._id, userName: response.userName, userEmail: response.email } ];
|
|
6224
|
+
}
|
|
6225
|
+
}
|
|
6226
|
+
} else {
|
|
6227
|
+
// get Store Spoc
|
|
6228
|
+
finduser = [ { userId: storeData.spocDetails[0]._id, userName: storeData.spocDetails[0].name, userEmail: storeData.spocDetails[0].email } ];
|
|
6229
|
+
}
|
|
6230
|
+
|
|
6231
|
+
// return finduser;
|
|
6232
|
+
// console.log( 'finduser =>', finduser );
|
|
6233
|
+
if ( !finduser ) {
|
|
6234
|
+
return res.sendError( 'No user Found For this store', 500 );
|
|
6235
|
+
}
|
|
6236
|
+
|
|
6237
|
+
userId = finduser.userId;
|
|
6238
|
+
inputBody.userName = finduser.userName;
|
|
6239
|
+
inputBody.userEmail = finduser.userEmail;
|
|
6240
|
+
let teamList = await findteams( { users: { $elemMatch: { email: finduser.userEmail } } } );
|
|
6241
|
+
|
|
6242
|
+
inputBody.approver = '';
|
|
6243
|
+
for ( let team of teamList ) {
|
|
6244
|
+
for ( let user of team.Teamlead ) {
|
|
6245
|
+
inputBody.approver = user.email + ',' + inputBody.approver;
|
|
6246
|
+
}
|
|
6247
|
+
}
|
|
6248
|
+
inputBody.approver = inputBody.approver.replace( /,$/, '' );
|
|
6249
|
+
let title = `New Task Alert ${inputBody.taskName}-${storeData.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
|
|
6250
|
+
let time = inputBody?.scheduleEndTime || '11:59 PM';
|
|
6251
|
+
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
6252
|
+
let description = `A new task has been assigned to ${storeData.storeName}. Please complete it before the due date of ${date}.`;
|
|
6253
|
+
let userDetails = await userService.findOne( { _id: new mongoose.Types.ObjectId( finduser.userId ) } );
|
|
6254
|
+
if ( userDetails && userDetails.fcmToken ) {
|
|
6255
|
+
const fcmToken = userDetails.fcmToken;
|
|
6256
|
+
await sendPushNotification( title, description, fcmToken );
|
|
6257
|
+
}
|
|
6258
|
+
const inputDateTime = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' );
|
|
6259
|
+
const currentTime = dayjs.utc();
|
|
6260
|
+
if ( inputDateTime.isBefore( currentTime ) ) {
|
|
6261
|
+
return res.sendError( 'The input date-time is before the current time.', 500 );
|
|
6262
|
+
}
|
|
6263
|
+
|
|
6264
|
+
let creatorData = await userService.findOne( { clientId: inputBody.clientId, role: 'superadmin', userType: 'client', isActive: true } );
|
|
6265
|
+
if ( !creatorData ) {
|
|
6266
|
+
return res.sendError( 'Invalid Creator Details', 500 );
|
|
6267
|
+
}
|
|
6268
|
+
let creator = [ { _id: creatorData._id, userName: creatorData.userName, userEmail: creatorData.email } ];
|
|
6269
|
+
|
|
6270
|
+
let approverList = inputBody?.approver.split( ',' );
|
|
6271
|
+
let userAdmin = await userService.find( { clientId: inputBody.clientId, email: { $in: approverList }, userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
|
|
6272
|
+
if ( userAdmin && userAdmin.length === 0 ) {
|
|
6273
|
+
userAdmin = creator;
|
|
6274
|
+
}
|
|
6275
|
+
|
|
6276
|
+
if ( req.body && req.body.referenceImage && req.body.referenceImage.length > 3 ) {
|
|
6277
|
+
return res.sendError( 'Maximum 3 referenceImage only allowed', 500 );
|
|
6278
|
+
}
|
|
6279
|
+
|
|
6280
|
+
let answer = await findAnswer( inputBody?.answerType );
|
|
6281
|
+
if ( answer.length == 0 ) {
|
|
6282
|
+
return res.sendError( 'please enter Valid AnswerType', 500 );
|
|
6283
|
+
}
|
|
6284
|
+
|
|
6285
|
+
// Check this Task Already Exist////
|
|
6286
|
+
let checkTask = await taskService.findOne( { checkListName: inputBody.taskName } );
|
|
6287
|
+
if ( checkTask ) {
|
|
6288
|
+
let singleInsert = await insertStoreHygienetaskSingleProcessedTask( checkTask, inputBody, date, time, storeData, finduser, answer );
|
|
6289
|
+
if ( singleInsert ) {
|
|
6290
|
+
return res.sendSuccess( 'Task created successfully' );
|
|
6291
|
+
} else {
|
|
6292
|
+
return res.sendError( 'something went wrong, please try again', 500 );
|
|
6293
|
+
}
|
|
6294
|
+
} else {
|
|
6295
|
+
let data = {
|
|
6296
|
+
// checkListName: `${inputBody.taskName}(${storeData.storeName}-${dayjs().format( 'YYYY-MM-DD' )}-${inputBody.zoneName ? inputBody.zoneName : ''})`,
|
|
6297
|
+
checkListName: inputBody.taskName,
|
|
6298
|
+
checkListDescription: inputBody.taskDescription,
|
|
6299
|
+
createdBy: creator[0]._id,
|
|
6300
|
+
createdByName: creator[0].userName,
|
|
6301
|
+
publish: true,
|
|
6302
|
+
questionCount: 1,
|
|
6303
|
+
storeCount: 1,
|
|
6304
|
+
scheduleDate: date,
|
|
6305
|
+
scheduleEndTime: time,
|
|
6306
|
+
scheduleEndTimeISO: dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' ).format(),
|
|
6307
|
+
priorityType: 'high',
|
|
6308
|
+
client_id: inputBody.clientId,
|
|
6309
|
+
checkListType: 'task',
|
|
6310
|
+
publishDate: new Date(),
|
|
6311
|
+
locationCount: 1,
|
|
6312
|
+
...( inputBody?.checkListId ) ? { referenceCheckListId: inputBody?.checkListId } : {},
|
|
6313
|
+
coverage: 'store',
|
|
6314
|
+
checkListFrom: 'api',
|
|
6315
|
+
zoneName: inputBody.zoneName || '',
|
|
6316
|
+
checkListType: 'task',
|
|
6317
|
+
};
|
|
6318
|
+
data['approver'] = userAdmin;
|
|
6319
|
+
|
|
6320
|
+
if ( inputBody?.answerType === 'multiplechoicesingle' || inputBody?.answerType === 'multiplechoicemultiple' ) {
|
|
6321
|
+
if ( inputBody?.options && inputBody?.options.length > 0 ) {
|
|
6322
|
+
let optionsResult = [];
|
|
6323
|
+
let optionList = inputBody?.options.split( ',' );
|
|
6324
|
+
for ( let option of optionList ) {
|
|
6325
|
+
let optiondata = {
|
|
6326
|
+
'answer': '',
|
|
6327
|
+
'sopFlag': false,
|
|
6328
|
+
'validation': false,
|
|
6329
|
+
'validationType': '',
|
|
6330
|
+
'referenceImage': [],
|
|
6331
|
+
'runAI': false,
|
|
6332
|
+
'allowUploadfromGallery': false,
|
|
6333
|
+
'descriptivetype': '',
|
|
6334
|
+
'showLinked': false,
|
|
6335
|
+
'linkedQuestion': 0,
|
|
6336
|
+
'nestedQuestion': [],
|
|
6337
|
+
};
|
|
6338
|
+
optiondata.answer = option;
|
|
6339
|
+
optionsResult.push( optiondata );
|
|
6340
|
+
}
|
|
6341
|
+
answer = optionsResult;
|
|
6342
|
+
} else {
|
|
6343
|
+
return res.sendError( 'please enter Valid Options', 500 );
|
|
6344
|
+
}
|
|
6345
|
+
}
|
|
6346
|
+
|
|
6347
|
+
let response = await taskService.create( data );
|
|
6348
|
+
if ( response?.approver.length ) {
|
|
6349
|
+
let inputData = [];
|
|
6350
|
+
response?.approver.forEach( ( ele ) => {
|
|
6351
|
+
inputData.push( {
|
|
6352
|
+
userEmail: ele.email,
|
|
6353
|
+
checkListId: response._id,
|
|
6354
|
+
type: 'task',
|
|
6355
|
+
client_id: inputBody.clientId,
|
|
6356
|
+
checkListName: data?.checkListName || '',
|
|
6357
|
+
} );
|
|
6358
|
+
} );
|
|
6359
|
+
await traxApprover.insertMany( inputData );
|
|
6360
|
+
}
|
|
6361
|
+
|
|
6362
|
+
if ( response?._id ) {
|
|
6363
|
+
let question = [
|
|
6364
|
+
{
|
|
6365
|
+
'qno': 1,
|
|
6366
|
+
'qname': inputBody.question,
|
|
6367
|
+
'answerType': inputBody?.answerType || 'yes/no',
|
|
6368
|
+
'runAI': false,
|
|
6369
|
+
'runAIDescription': '',
|
|
6370
|
+
'allowUploadfromGallery': false,
|
|
6371
|
+
'linkType': false,
|
|
6372
|
+
'questionReferenceImage': [],
|
|
6373
|
+
'answers': answer,
|
|
6374
|
+
'descriptivetype': 'text',
|
|
6375
|
+
},
|
|
6376
|
+
];
|
|
6377
|
+
|
|
6378
|
+
let images = [];
|
|
6379
|
+
for ( let imgpath of req.body.referenceImage ) {
|
|
6380
|
+
let configURL = JSON.parse( process.env.BUCKET );
|
|
6381
|
+
let inputData = {
|
|
6382
|
+
Bucket: configURL.aiTraxoutput,
|
|
6383
|
+
Key: imgpath,
|
|
6384
|
+
};
|
|
6385
|
+
let output = await getObject( inputData );
|
|
6386
|
+
let image = {
|
|
6387
|
+
data: output.Body,
|
|
6388
|
+
name: imgpath,
|
|
6389
|
+
mimetype: output.ContentType,
|
|
6390
|
+
};
|
|
6391
|
+
let uplaodedImage = await uploadmultiImage( image );
|
|
6392
|
+
let imgUrl = decodeURIComponent( uplaodedImage?.imgUrl.split( '?' )[0] );
|
|
6393
|
+
let url = imgUrl.split( '/' );
|
|
6394
|
+
if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
|
|
6395
|
+
url.splice( 0, 3 );
|
|
6396
|
+
}
|
|
6397
|
+
images.push( url.join( '/' ) );
|
|
6398
|
+
}
|
|
6399
|
+
question[0].questionReferenceImage = images;
|
|
6400
|
+
|
|
6401
|
+
if ( inputBody?.answerType === 'image' || inputBody?.answerType === 'descriptiveImage' || inputBody?.answerType === 'multipleImage' ) {
|
|
6402
|
+
answer[0].referenceImage = question[0].questionReferenceImage;
|
|
6403
|
+
}
|
|
6404
|
+
|
|
6405
|
+
question = {
|
|
6406
|
+
checkListId: response?._id,
|
|
6407
|
+
question: question,
|
|
6408
|
+
section: 'Section 1',
|
|
6409
|
+
checkList: data.checkListName,
|
|
6410
|
+
client_id: inputBody.clientId,
|
|
6411
|
+
};
|
|
6412
|
+
await taskQuestionService.create( question );
|
|
6413
|
+
|
|
6414
|
+
let userDetails = {
|
|
6415
|
+
userName: inputBody.userName,
|
|
6416
|
+
userEmail: inputBody.userEmail,
|
|
6417
|
+
store_id: storeData.storeId,
|
|
6418
|
+
storeName: storeData.storeName,
|
|
6419
|
+
city: storeData?.storeProfile?.city,
|
|
6420
|
+
checkFlag: true,
|
|
6421
|
+
checkListId: response?._id,
|
|
6422
|
+
checkListName: data.checkListName,
|
|
6423
|
+
client_id: inputBody.clientId,
|
|
6424
|
+
userId: userId,
|
|
6425
|
+
assignId: storeData?._id,
|
|
6426
|
+
};
|
|
6427
|
+
await taskAssignService.create( userDetails );
|
|
6428
|
+
await insertSingleProcessData( response?._id );
|
|
6429
|
+
return res.sendSuccess( 'Task created successfully' );
|
|
6430
|
+
}
|
|
6431
|
+
}
|
|
6432
|
+
} catch ( e ) {
|
|
6433
|
+
console.log( 'e =>', e );
|
|
6434
|
+
logger.error( { function: 'createTaskGroup', error: e } );
|
|
6435
|
+
return res.sendError( e, 500 );
|
|
6436
|
+
}
|
|
6437
|
+
}
|
|
6438
|
+
|
|
6439
|
+
async function insertAItaskSingleProcessedTask( checkTask, inputBody, date, time, storeDetails, finduser, answer, userAdmin ) {
|
|
6440
|
+
try {
|
|
6441
|
+
let getquestion = await taskQuestionService.findOne( { checkListId: checkTask._id } );
|
|
6442
|
+
let getolddata = await taskProcessedService.findOne( { sourceCheckList_id: checkTask._id } );
|
|
6443
|
+
let getoldConfigdata = await taskService.findOne( { _id: checkTask._id } );
|
|
6444
|
+
|
|
6445
|
+
const uniqueUsers = mergeUnique( getoldConfigdata.approver, userAdmin, '_id' );
|
|
6446
|
+
// Question Patten Making
|
|
6447
|
+
let question = [
|
|
6448
|
+
{
|
|
6449
|
+
'qno': 1,
|
|
6450
|
+
'qname': inputBody.question,
|
|
6451
|
+
'answerType': inputBody?.answerType || 'yes/no',
|
|
6452
|
+
'runAI': false,
|
|
6453
|
+
'runAIDescription': '',
|
|
6454
|
+
'allowUploadfromGallery': false,
|
|
6455
|
+
'linkType': false,
|
|
6456
|
+
'questionReferenceImage': [],
|
|
6457
|
+
'answers': answer,
|
|
6458
|
+
'descriptivetype': 'text',
|
|
6459
|
+
},
|
|
6460
|
+
];
|
|
6461
|
+
|
|
6462
|
+
let images = [];
|
|
6463
|
+
for ( let imgpath of inputBody.referenceImage ) {
|
|
6464
|
+
let configURL = JSON.parse( process.env.BUCKET );
|
|
6465
|
+
let inputData = {
|
|
6466
|
+
Bucket: configURL.aiTraxoutput,
|
|
6467
|
+
Key: imgpath,
|
|
6468
|
+
};
|
|
6469
|
+
let output = await getObject( inputData );
|
|
6470
|
+
let image = {
|
|
6471
|
+
data: output.Body,
|
|
6472
|
+
name: imgpath,
|
|
6473
|
+
mimetype: output.ContentType,
|
|
6474
|
+
};
|
|
6475
|
+
let uplaodedImage = await uploadmultiImage( image );
|
|
6476
|
+
let imgUrl = decodeURIComponent( uplaodedImage?.imgUrl.split( '?' )[0] );
|
|
6477
|
+
let url = imgUrl.split( '/' );
|
|
6478
|
+
if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
|
|
6479
|
+
url.splice( 0, 3 );
|
|
6480
|
+
}
|
|
6481
|
+
images.push( url.join( '/' ) );
|
|
6482
|
+
}
|
|
6483
|
+
question[0].questionReferenceImage = images;
|
|
6484
|
+
|
|
6485
|
+
if ( inputBody?.answerType === 'image' || inputBody?.answerType === 'descriptiveImage' || inputBody?.answerType === 'multipleImage' ) {
|
|
6486
|
+
answer[0].referenceImage = question[0].questionReferenceImage;
|
|
6487
|
+
}
|
|
6488
|
+
|
|
6489
|
+
let questions = {
|
|
6490
|
+
questions: question,
|
|
6491
|
+
sectionName: getquestion.section,
|
|
6492
|
+
section_id: getquestion._id,
|
|
6493
|
+
};
|
|
6494
|
+
|
|
6495
|
+
let newData = getolddata.toObject();
|
|
6496
|
+
delete newData._id;
|
|
6497
|
+
newData.date_iso = new Date( dayjs( date, 'YYYY-MM-DD' ).format( 'YYYY-MM-DD' ) );
|
|
6498
|
+
newData.date_string = dayjs( date ).format( 'YYYY-MM-DD' );
|
|
6499
|
+
newData.scheduleStartTime_iso = date;
|
|
6500
|
+
newData.scheduleEndTime_iso = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' ).format();
|
|
6501
|
+
newData.store_id = storeDetails.storeId;
|
|
6502
|
+
newData.storeName = storeDetails.storeName;
|
|
6503
|
+
newData.country = storeDetails.storeProfile.country;
|
|
6504
|
+
newData.userId = finduser.userId;
|
|
6505
|
+
newData.userName = finduser.userName;
|
|
6506
|
+
newData.userEmail = finduser.userEmail;
|
|
6507
|
+
newData.checklistStatus = 'open';
|
|
6508
|
+
newData.timeFlagStatus = true;
|
|
6509
|
+
newData.checkListFrom = 'api';
|
|
6510
|
+
newData.createdAt = new Date();
|
|
6511
|
+
newData.updatedAt = new Date();
|
|
6512
|
+
newData.questionAnswers = [ questions ];
|
|
6513
|
+
newData.zoneName = inputBody.zoneName || '';
|
|
6514
|
+
newData.checkListType = 'task' || '';
|
|
6515
|
+
let insertprocessdata = await taskProcessedService.insert( newData );
|
|
6516
|
+
if ( insertprocessdata ) {
|
|
6517
|
+
if ( uniqueUsers && uniqueUsers.length>0 ) {
|
|
6518
|
+
// updated Task Approver//
|
|
6519
|
+
await taskService.updateOne( { _id: newData.sourceCheckList_id }, { approver: uniqueUsers } );
|
|
6520
|
+
for ( let k = 0; k < uniqueUsers.length; k++ ) {
|
|
6521
|
+
let checkapprover = {
|
|
6522
|
+
userEmail: uniqueUsers[k].email,
|
|
6523
|
+
checkListId: newData.sourceCheckList_id,
|
|
6524
|
+
type: 'task',
|
|
6525
|
+
client_id: newData.client_id,
|
|
6526
|
+
isDeleted: false,
|
|
6527
|
+
};
|
|
6528
|
+
let getapproverData = await traxApprover.findOne( checkapprover );
|
|
6529
|
+
if ( !getapproverData ) {
|
|
6530
|
+
let inserApproverData = {
|
|
6531
|
+
userEmail: uniqueUsers[k].email,
|
|
6532
|
+
checkListId: newData.sourceCheckList_id,
|
|
6533
|
+
type: 'task',
|
|
6534
|
+
client_id: newData.client_id,
|
|
6535
|
+
isDeleted: false,
|
|
6536
|
+
};
|
|
6537
|
+
await traxApprover.create( inserApproverData );
|
|
6538
|
+
}
|
|
6539
|
+
}
|
|
6540
|
+
}
|
|
6541
|
+
return true;
|
|
6542
|
+
} else {
|
|
6543
|
+
return false;
|
|
6544
|
+
}
|
|
6545
|
+
} catch ( error ) {
|
|
6546
|
+
logger.error( { error: error, function: 'insertSingleProcessedTask' } );
|
|
6547
|
+
return false;
|
|
6548
|
+
}
|
|
6549
|
+
}
|
|
6550
|
+
|
|
6551
|
+
export async function createAITaskGroup( req, res ) {
|
|
6552
|
+
try {
|
|
6553
|
+
let inputBody = req.body;
|
|
6554
|
+
|
|
6555
|
+
inputBody.taskDescription = '';
|
|
6556
|
+
let userId;
|
|
6557
|
+
// Step:1 Store Validation
|
|
6558
|
+
let storeData = await storeService.findOne( { storeName: inputBody.storeName, clientId: inputBody.clientId, status: 'active' }, { storeId: 1, storeName: 1, storeProfile: 1, spocDetails: 1 } );
|
|
6559
|
+
if ( !storeData ) {
|
|
6560
|
+
return res.sendError( 'Store Not Found', 500 );
|
|
6561
|
+
}
|
|
6562
|
+
|
|
6563
|
+
let finduser;
|
|
6564
|
+
// Step:2 User Validation
|
|
6565
|
+
if ( inputBody.userEmail ) {
|
|
6566
|
+
let userFind = [
|
|
6567
|
+
{
|
|
6568
|
+
$match: {
|
|
6569
|
+
email: inputBody.userEmail,
|
|
6570
|
+
clientId: inputBody.clientId,
|
|
6571
|
+
},
|
|
6572
|
+
},
|
|
6573
|
+
{
|
|
6574
|
+
$project: {
|
|
6575
|
+
_id: 0,
|
|
6576
|
+
userId: '$_id',
|
|
6577
|
+
userName: 1,
|
|
6578
|
+
userEmail: '$email',
|
|
6579
|
+
},
|
|
6580
|
+
},
|
|
6581
|
+
];
|
|
6582
|
+
let finduserData = await userService.aggregate( userFind );
|
|
6583
|
+
// console.log( 'finduserData =>', finduserData );
|
|
6584
|
+
if ( finduserData && finduserData.length > 0 ) {
|
|
6585
|
+
finduser = finduserData[0];
|
|
6586
|
+
} else {
|
|
6587
|
+
// Create User//
|
|
6588
|
+
let params = {
|
|
6589
|
+
userName: inputBody.userEmail.split( '@' )[0],
|
|
6590
|
+
email: inputBody.userEmail,
|
|
6591
|
+
mobileNumber: inputBody?.mobileNumber || '0000000000',
|
|
6592
|
+
clientId: inputBody.clientId,
|
|
6593
|
+
role: 'user',
|
|
6594
|
+
password: '5dqFKAJj29PsV6P+kL+3Dw==',
|
|
6595
|
+
isActive: true,
|
|
6596
|
+
userType: 'client',
|
|
6597
|
+
rolespermission: [
|
|
6598
|
+
{
|
|
6599
|
+
featureName: 'Global',
|
|
6600
|
+
modules: [
|
|
6601
|
+
{
|
|
6602
|
+
name: 'Store',
|
|
6603
|
+
isAdd: false,
|
|
6604
|
+
isEdit: false,
|
|
6605
|
+
|
|
6606
|
+
},
|
|
6607
|
+
{
|
|
6608
|
+
name: 'User',
|
|
6609
|
+
isAdd: false,
|
|
6610
|
+
isEdit: false,
|
|
6611
|
+
|
|
6612
|
+
},
|
|
6613
|
+
{
|
|
6614
|
+
name: 'Camera',
|
|
6615
|
+
isAdd: false,
|
|
6616
|
+
isEdit: false,
|
|
6617
|
+
|
|
6618
|
+
},
|
|
6619
|
+
{
|
|
6620
|
+
name: 'Configuration',
|
|
6621
|
+
isAdd: false,
|
|
6622
|
+
isEdit: false,
|
|
6623
|
+
|
|
6624
|
+
},
|
|
6625
|
+
{
|
|
6626
|
+
name: 'Subscription',
|
|
6627
|
+
isAdd: false,
|
|
6628
|
+
isEdit: false,
|
|
6629
|
+
|
|
6630
|
+
},
|
|
6631
|
+
{
|
|
6632
|
+
name: 'Billing',
|
|
6633
|
+
isAdd: false,
|
|
6634
|
+
isEdit: false,
|
|
6635
|
+
|
|
6636
|
+
},
|
|
6637
|
+
],
|
|
6638
|
+
},
|
|
6639
|
+
{
|
|
6640
|
+
featurName: 'TangoEye',
|
|
6641
|
+
modules: [
|
|
6642
|
+
{
|
|
6643
|
+
name: 'ZoneTag',
|
|
6644
|
+
isAdd: false,
|
|
6645
|
+
isEdit: false,
|
|
6646
|
+
|
|
6647
|
+
},
|
|
6648
|
+
],
|
|
6649
|
+
},
|
|
6650
|
+
{
|
|
6651
|
+
featurName: 'TangoTrax',
|
|
6652
|
+
modules: [
|
|
6653
|
+
{
|
|
6654
|
+
name: 'checklist',
|
|
6655
|
+
isAdd: false,
|
|
6656
|
+
isEdit: false,
|
|
6657
|
+
|
|
6658
|
+
},
|
|
6659
|
+
{
|
|
6660
|
+
name: 'Task',
|
|
6661
|
+
isAdd: false,
|
|
6662
|
+
isEdit: false,
|
|
6663
|
+
|
|
6664
|
+
},
|
|
6665
|
+
],
|
|
6666
|
+
},
|
|
6667
|
+
],
|
|
6668
|
+
};
|
|
6669
|
+
let response = await userService.create( params );
|
|
6670
|
+
if ( response ) {
|
|
6671
|
+
finduser = [ { userId: response._id, userName: response.userName, userEmail: response.email } ];
|
|
6672
|
+
}
|
|
6673
|
+
}
|
|
6674
|
+
} else {
|
|
6675
|
+
// get Store Spoc
|
|
6676
|
+
if ( storeData.spocDetails[0].email && storeData.spocDetails[0].email !='' ) {
|
|
6677
|
+
finduser ={ userId: storeData.spocDetails[0]._id, userName: storeData.spocDetails[0].name, userEmail: storeData.spocDetails[0].email };
|
|
6678
|
+
} else {
|
|
6679
|
+
return res.sendError( 'store spoc email invalid', 500 );
|
|
6680
|
+
}
|
|
6681
|
+
}
|
|
6682
|
+
|
|
6683
|
+
// return finduser;
|
|
6684
|
+
// console.log( 'finduser =>', finduser );
|
|
6685
|
+
if ( !finduser ) {
|
|
6686
|
+
return res.sendError( 'No user Found For this store', 500 );
|
|
6687
|
+
}
|
|
6688
|
+
|
|
6689
|
+
userId = finduser.userId;
|
|
6690
|
+
inputBody.userName = finduser.userName;
|
|
6691
|
+
inputBody.userEmail = finduser.userEmail;
|
|
6692
|
+
if ( inputBody.approver && !inputBody.approver.length ) {
|
|
6693
|
+
let teamList = await findteams( { users: { $elemMatch: { email: finduser.userEmail } } } );
|
|
6694
|
+
// console.log( 'teamList =>', teamList );
|
|
6695
|
+
if ( teamList && teamList.length>0 ) {
|
|
6696
|
+
for ( let team of teamList ) {
|
|
6697
|
+
for ( let user of team.Teamlead ) {
|
|
6698
|
+
inputBody.approver.push( user.email );
|
|
6699
|
+
}
|
|
6700
|
+
}
|
|
6701
|
+
}
|
|
6702
|
+
}
|
|
6703
|
+
|
|
6704
|
+
// Send Push Notification
|
|
6705
|
+
// inputBody.approver = inputBody.approver.replace( /,$/, '' );
|
|
6706
|
+
let title = `New Task Alert ${inputBody.taskName}-${storeData.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
|
|
6707
|
+
let time = inputBody?.scheduleEndTime || '11:59 PM';
|
|
6708
|
+
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
6709
|
+
let description = `A new task has been assigned to ${storeData.storeName}. Please complete it before the due date of ${date}.`;
|
|
6710
|
+
let userDetails = await userService.findOne( { _id: new mongoose.Types.ObjectId( finduser.userId ) } );
|
|
6711
|
+
if ( userDetails && userDetails.fcmToken ) {
|
|
6712
|
+
const fcmToken = userDetails.fcmToken;
|
|
6713
|
+
await sendPushNotification( title, description, fcmToken );
|
|
6714
|
+
}
|
|
6715
|
+
|
|
6716
|
+
const inputDateTime = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' );
|
|
6717
|
+
const currentTime = dayjs.utc();
|
|
6718
|
+
if ( inputDateTime.isBefore( currentTime ) ) {
|
|
6719
|
+
return res.sendError( 'The input date-time is before the current time.', 500 );
|
|
6720
|
+
}
|
|
6721
|
+
|
|
6722
|
+
let creatorData = await userService.findOne( { clientId: inputBody.clientId, role: 'superadmin', userType: 'client', isActive: true } );
|
|
6723
|
+
if ( !creatorData ) {
|
|
6724
|
+
return res.sendError( 'Invalid Creator Details', 500 );
|
|
6725
|
+
}
|
|
6726
|
+
let creator = [ { _id: creatorData._id, userName: creatorData.userName, userEmail: creatorData.email } ];
|
|
6727
|
+
|
|
6728
|
+
let userAdmin;
|
|
6729
|
+
if ( inputBody.approver && inputBody.approver.length ) {
|
|
6730
|
+
userAdmin = await userService.find( { clientId: inputBody.clientId, email: { $in: inputBody.approver }, userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
|
|
6731
|
+
// console.log( 'userAdmin 1=>', userAdmin );
|
|
6732
|
+
if ( userAdmin && userAdmin.length === 0 ) {
|
|
6733
|
+
userAdmin = creator;
|
|
6734
|
+
}
|
|
6735
|
+
// console.log( 'userAdmin 2=>', userAdmin );
|
|
6736
|
+
}
|
|
6737
|
+
|
|
6738
|
+
if ( req.body && req.body.referenceImage && req.body.referenceImage.length > 3 ) {
|
|
6739
|
+
return res.sendError( 'Maximum 3 referenceImage only allowed', 500 );
|
|
6740
|
+
}
|
|
6741
|
+
|
|
6742
|
+
let answer = await findAnswer( inputBody?.answerType );
|
|
6743
|
+
if ( answer.length == 0 ) {
|
|
6744
|
+
return res.sendError( 'please enter Valid AnswerType', 500 );
|
|
6745
|
+
}
|
|
6746
|
+
|
|
6747
|
+
// Check this Task Already Exist////
|
|
6748
|
+
let checkTask = await taskService.findOne( { checkListName: inputBody.taskName } );
|
|
6749
|
+
if ( checkTask ) {
|
|
6750
|
+
let singleInsert = await insertAItaskSingleProcessedTask( checkTask, inputBody, date, time, storeData, finduser, answer, userAdmin );
|
|
6751
|
+
if ( singleInsert ) {
|
|
6752
|
+
return res.sendSuccess( 'Task created successfully' );
|
|
6753
|
+
} else {
|
|
6754
|
+
return res.sendError( 'something went wrong, please try again', 500 );
|
|
6755
|
+
}
|
|
6756
|
+
} else {
|
|
6757
|
+
let data = {
|
|
6758
|
+
// checkListName: `${inputBody.taskName}(${storeData.storeName}-${dayjs().format( 'YYYY-MM-DD' )}-${inputBody.zoneName ? inputBody.zoneName : ''})`,
|
|
6759
|
+
checkListName: inputBody.taskName,
|
|
6760
|
+
checkListDescription: inputBody.taskDescription,
|
|
6761
|
+
createdBy: creator[0]._id,
|
|
6762
|
+
createdByName: creator[0].userName,
|
|
6763
|
+
publish: true,
|
|
6764
|
+
questionCount: 1,
|
|
6765
|
+
storeCount: 1,
|
|
6766
|
+
scheduleDate: date,
|
|
6767
|
+
scheduleEndTime: time,
|
|
6768
|
+
scheduleEndTimeISO: dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' ).format(),
|
|
6769
|
+
priorityType: 'high',
|
|
6770
|
+
client_id: inputBody.clientId,
|
|
6771
|
+
checkListType: 'task',
|
|
6772
|
+
publishDate: new Date(),
|
|
6773
|
+
locationCount: 1,
|
|
6774
|
+
...( inputBody?.checkListId ) ? { referenceCheckListId: inputBody?.checkListId } : {},
|
|
6775
|
+
coverage: 'store',
|
|
6776
|
+
checkListFrom: 'api',
|
|
6777
|
+
zoneName: inputBody.zoneName || '',
|
|
6778
|
+
checkListType: 'task',
|
|
6779
|
+
};
|
|
6780
|
+
data['approver'] = userAdmin;
|
|
6781
|
+
|
|
6782
|
+
if ( inputBody?.answerType === 'multiplechoicesingle' || inputBody?.answerType === 'multiplechoicemultiple' ) {
|
|
6783
|
+
if ( inputBody?.options && inputBody?.options.length > 0 ) {
|
|
6784
|
+
let optionsResult = [];
|
|
6785
|
+
let optionList = inputBody?.options.split( ',' );
|
|
6786
|
+
for ( let option of optionList ) {
|
|
6787
|
+
let optiondata = {
|
|
6788
|
+
'answer': '',
|
|
6789
|
+
'sopFlag': false,
|
|
6790
|
+
'validation': false,
|
|
6791
|
+
'validationType': '',
|
|
6792
|
+
'referenceImage': [],
|
|
6793
|
+
'runAI': false,
|
|
6794
|
+
'allowUploadfromGallery': false,
|
|
6795
|
+
'descriptivetype': '',
|
|
6796
|
+
'showLinked': false,
|
|
6797
|
+
'linkedQuestion': 0,
|
|
6798
|
+
'nestedQuestion': [],
|
|
6799
|
+
};
|
|
6800
|
+
optiondata.answer = option;
|
|
6801
|
+
optionsResult.push( optiondata );
|
|
6802
|
+
}
|
|
6803
|
+
answer = optionsResult;
|
|
6804
|
+
} else {
|
|
6805
|
+
return res.sendError( 'please enter Valid Options', 500 );
|
|
6806
|
+
}
|
|
6807
|
+
}
|
|
6808
|
+
|
|
6809
|
+
let response = await taskService.create( data );
|
|
6810
|
+
if ( response?.approver.length ) {
|
|
6811
|
+
let inputData = [];
|
|
6812
|
+
response?.approver.forEach( ( ele ) => {
|
|
6813
|
+
inputData.push( {
|
|
6814
|
+
userEmail: ele.email,
|
|
6815
|
+
checkListId: response._id,
|
|
6816
|
+
type: 'task',
|
|
6817
|
+
client_id: inputBody.clientId,
|
|
6818
|
+
checkListName: data?.checkListName || '',
|
|
6819
|
+
} );
|
|
6820
|
+
} );
|
|
6821
|
+
await traxApprover.insertMany( inputData );
|
|
6822
|
+
}
|
|
6823
|
+
|
|
6824
|
+
if ( response?._id ) {
|
|
6825
|
+
let question = [
|
|
6826
|
+
{
|
|
6827
|
+
'qno': 1,
|
|
6828
|
+
'qname': inputBody.question,
|
|
6829
|
+
'answerType': inputBody?.answerType || 'yes/no',
|
|
6830
|
+
'runAI': false,
|
|
6831
|
+
'runAIDescription': '',
|
|
6832
|
+
'allowUploadfromGallery': false,
|
|
6833
|
+
'linkType': false,
|
|
6834
|
+
'questionReferenceImage': [],
|
|
6835
|
+
'answers': answer,
|
|
6836
|
+
'descriptivetype': 'text',
|
|
6837
|
+
},
|
|
6838
|
+
];
|
|
6839
|
+
|
|
6840
|
+
let images = [];
|
|
6841
|
+
for ( let imgpath of req.body.referenceImage ) {
|
|
6842
|
+
let configURL = JSON.parse( process.env.BUCKET );
|
|
6843
|
+
let inputData = {
|
|
6844
|
+
Bucket: configURL.aiTraxoutput,
|
|
6845
|
+
Key: imgpath,
|
|
6846
|
+
};
|
|
6847
|
+
let output = await getObject( inputData );
|
|
6848
|
+
// / Check Bucket
|
|
6849
|
+
console.log( 'output =>', output );
|
|
6850
|
+
let image = {
|
|
6851
|
+
data: output.Body,
|
|
6852
|
+
name: imgpath,
|
|
6853
|
+
mimetype: output.ContentType,
|
|
6854
|
+
};
|
|
6855
|
+
let uplaodedImage = await uploadmultiImage( image );
|
|
6856
|
+
let imgUrl = decodeURIComponent( uplaodedImage?.imgUrl.split( '?' )[0] );
|
|
6857
|
+
let url = imgUrl.split( '/' );
|
|
6858
|
+
if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
|
|
6859
|
+
url.splice( 0, 3 );
|
|
6860
|
+
}
|
|
6861
|
+
images.push( url.join( '/' ) );
|
|
6862
|
+
}
|
|
6863
|
+
question[0].questionReferenceImage = images;
|
|
6864
|
+
|
|
6865
|
+
if ( inputBody?.answerType === 'image' || inputBody?.answerType === 'descriptiveImage' || inputBody?.answerType === 'multipleImage' ) {
|
|
6866
|
+
answer[0].referenceImage = question[0].questionReferenceImage;
|
|
6867
|
+
}
|
|
6868
|
+
|
|
6869
|
+
question = {
|
|
6870
|
+
checkListId: response?._id,
|
|
6871
|
+
question: question,
|
|
6872
|
+
section: 'Section 1',
|
|
6873
|
+
checkList: data.checkListName,
|
|
6874
|
+
client_id: inputBody.clientId,
|
|
6875
|
+
};
|
|
6876
|
+
await taskQuestionService.create( question );
|
|
6877
|
+
|
|
6878
|
+
let userDetails = {
|
|
6879
|
+
userName: inputBody.userName,
|
|
6880
|
+
userEmail: inputBody.userEmail,
|
|
6881
|
+
store_id: storeData.storeId,
|
|
6882
|
+
storeName: storeData.storeName,
|
|
6883
|
+
city: storeData?.storeProfile?.city,
|
|
6884
|
+
checkFlag: true,
|
|
6885
|
+
checkListId: response?._id,
|
|
6886
|
+
checkListName: data.checkListName,
|
|
6887
|
+
client_id: inputBody.clientId,
|
|
6888
|
+
userId: userId,
|
|
6889
|
+
assignId: storeData?._id,
|
|
6890
|
+
};
|
|
6891
|
+
await taskAssignService.create( userDetails );
|
|
6892
|
+
await insertSingleProcessData( response?._id );
|
|
6893
|
+
return res.sendSuccess( 'Task created successfully' );
|
|
6894
|
+
}
|
|
6895
|
+
}
|
|
6896
|
+
} catch ( e ) {
|
|
6897
|
+
console.log( 'e =>', e );
|
|
6898
|
+
logger.error( { function: 'createTaskGroup', error: e } );
|
|
6899
|
+
return res.sendError( e, 500 );
|
|
6900
|
+
}
|
|
6901
|
+
}
|
|
6902
|
+
|
|
6903
|
+
function mergeUnique( arr1 = [], arr2 = [], key = '_id' ) {
|
|
6904
|
+
const merged = [ ...arr1, ...arr2 ];
|
|
6905
|
+
|
|
6906
|
+
return Array.from(
|
|
6907
|
+
new Map(
|
|
6908
|
+
merged.map( ( item ) => [ item[key]?.toString?.() ?? item[key], item ] ),
|
|
6909
|
+
).values(),
|
|
6910
|
+
);
|
|
6911
|
+
}
|
package/src/dtos/task.dto.js
CHANGED
|
@@ -82,3 +82,25 @@ export const StoreHygienetaskvalidation = {
|
|
|
82
82
|
export const eyeTesttaskvalidation = {
|
|
83
83
|
body: eyeTesttaskSchema,
|
|
84
84
|
};
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
export const createTaskGroupSchema = Joi.object().keys( {
|
|
88
|
+
storeName: Joi.string().required(),
|
|
89
|
+
taskName: Joi.string().required(),
|
|
90
|
+
question: Joi.string().required(),
|
|
91
|
+
answerType: Joi.string().required(),
|
|
92
|
+
clientId: Joi.string().required(),
|
|
93
|
+
options: Joi.string().optional().allow( '' ),
|
|
94
|
+
scheduleDate: Joi.string().optional().allow( '' ),
|
|
95
|
+
scheduleEndTime: Joi.string().optional().allow( '' ),
|
|
96
|
+
referenceImage: Joi.array().optional().allow( '' ),
|
|
97
|
+
zoneName: Joi.string().optional().allow( '' ),
|
|
98
|
+
userEmail: Joi.string().optional().allow( '' ),
|
|
99
|
+
mobileNumber: Joi.string().optional().allow( '' ),
|
|
100
|
+
approverList: Joi.array().optional().allow( '' ),
|
|
101
|
+
approver: Joi.array().optional().allow( '' ),
|
|
102
|
+
} );
|
|
103
|
+
|
|
104
|
+
export const createTaskGroupvalidation = {
|
|
105
|
+
body: createTaskGroupSchema,
|
|
106
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as taskController from '../controllers/task.controller.js';
|
|
3
3
|
import { isAllowedSessionHandler, validate, accessVerification, isAllowedClient, isAllowedInternalAPIHandler, getAssinedStore } from 'tango-app-api-middleware';
|
|
4
4
|
import express from 'express';
|
|
5
|
-
import { aitaskvalidation, StoreHygienetaskvalidation, eyeTesttaskvalidation, commonAiTaskvalidation, taskcreationvalidation, gettaskvalidation } from '../dtos/task.dto.js';
|
|
5
|
+
import { aitaskvalidation, StoreHygienetaskvalidation, eyeTesttaskvalidation, commonAiTaskvalidation, taskcreationvalidation, gettaskvalidation, createTaskGroupvalidation } from '../dtos/task.dto.js';
|
|
6
6
|
export const taskRouter = express.Router();
|
|
7
7
|
|
|
8
8
|
taskRouter
|
|
@@ -42,6 +42,8 @@ taskRouter
|
|
|
42
42
|
.post( '/taskcreation', isAllowedInternalAPIHandler, validate( taskcreationvalidation ), taskController.taskcreation )
|
|
43
43
|
.get( '/getTask', isAllowedInternalAPIHandler, validate( gettaskvalidation ), taskController.getTask )
|
|
44
44
|
.post( '/breached-tasks', isAllowedInternalAPIHandler, validate( taskcreationvalidation ), taskController.breachedTasks )
|
|
45
|
-
.get( '/getcoustemer', taskController.customertrial )
|
|
45
|
+
.get( '/getcoustemer', taskController.customertrial )
|
|
46
|
+
.post( '/createTaskGroup', isAllowedInternalAPIHandler, validate( createTaskGroupvalidation ), taskController.createTaskGroup )
|
|
47
|
+
.post( '/createAITaskGroup', isAllowedInternalAPIHandler, validate( createTaskGroupvalidation ), taskController.createAITaskGroup );
|
|
46
48
|
|
|
47
49
|
|
|
@@ -15,3 +15,7 @@ export const insertMany = async ( data = [] ) => {
|
|
|
15
15
|
export const find = async ( query ={}, field={} ) => {
|
|
16
16
|
return model.traxApproverModel.find( query, field );
|
|
17
17
|
};
|
|
18
|
+
|
|
19
|
+
export const findOne = async ( query ={}, field={} ) => {
|
|
20
|
+
return model.traxApproverModel.findOne( query, field );
|
|
21
|
+
};
|