tango-app-api-task 3.2.1-hotfix-1 → 3.2.1-hotfix-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
|
@@ -2400,7 +2400,6 @@ export async function StoreHygienetask( req, res ) {
|
|
|
2400
2400
|
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
2401
2401
|
let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
|
|
2402
2402
|
let userDetails = await userService.findOne( { _id: new mongoose.Types.ObjectId( finduser.userId ) } );
|
|
2403
|
-
console.log( userDetails.fcmToken );
|
|
2404
2403
|
if ( userDetails&&userDetails.fcmToken ) {
|
|
2405
2404
|
const fcmToken = userDetails.fcmToken;
|
|
2406
2405
|
await sendPushNotification( title, description, fcmToken );
|
|
@@ -2620,7 +2619,6 @@ export async function eyeTesttask( req, res ) {
|
|
|
2620
2619
|
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
2621
2620
|
let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
|
|
2622
2621
|
let userDetails = await userService.findOne( { _id: new mongoose.Types.ObjectId( finduser.userId ) } );
|
|
2623
|
-
console.log( userDetails.fcmToken );
|
|
2624
2622
|
if ( userDetails&&userDetails.fcmToken ) {
|
|
2625
2623
|
const fcmToken = userDetails.fcmToken;
|
|
2626
2624
|
await sendPushNotification( title, description, fcmToken );
|
|
@@ -3292,3 +3290,403 @@ export async function customertrial( params ) {
|
|
|
3292
3290
|
}
|
|
3293
3291
|
};
|
|
3294
3292
|
|
|
3293
|
+
export async function commonAiTask( req, res ) {
|
|
3294
|
+
try {
|
|
3295
|
+
let inputBody = req.body;
|
|
3296
|
+
|
|
3297
|
+
inputBody.clientId = 11;
|
|
3298
|
+
inputBody.taskDescription = '';
|
|
3299
|
+
let userId;
|
|
3300
|
+
let storeDetails = await storeService.findOne( { storeName: inputBody.storeName, clientId: inputBody.clientId, status: 'active' }, { storeId: 1, storeName: 1, storeProfile: 1 } );
|
|
3301
|
+
if ( !storeDetails ) {
|
|
3302
|
+
return res.sendError( 'Store Not Found', 500 );
|
|
3303
|
+
}
|
|
3304
|
+
|
|
3305
|
+
let url = JSON.parse( process.env.LAMBDAURL );
|
|
3306
|
+
let checklistId = url.dailystoreChecklistId;
|
|
3307
|
+
let finduser = await checklistassignconfigModel.findOne( { checkListId: new mongoose.Types.ObjectId( checklistId ), store_id: storeDetails.storeId } );
|
|
3308
|
+
|
|
3309
|
+
if ( !finduser ) {
|
|
3310
|
+
return res.sendError( 'No user Found For this store', 500 );
|
|
3311
|
+
}
|
|
3312
|
+
|
|
3313
|
+
userId = finduser.userId;
|
|
3314
|
+
inputBody.userName = finduser.userName;
|
|
3315
|
+
inputBody.userEmail = finduser.userEmail;
|
|
3316
|
+
|
|
3317
|
+
|
|
3318
|
+
let teamList = await findteams( { users: { $elemMatch: { email: finduser.userEmail } } } );
|
|
3319
|
+
|
|
3320
|
+
inputBody.approver = '';
|
|
3321
|
+
for ( let team of teamList ) {
|
|
3322
|
+
for ( let user of team.Teamlead ) {
|
|
3323
|
+
inputBody.approver = user.email + ',' + inputBody.approver;
|
|
3324
|
+
}
|
|
3325
|
+
}
|
|
3326
|
+
inputBody.approver = inputBody.approver.replace( /,$/, '' );
|
|
3327
|
+
|
|
3328
|
+
|
|
3329
|
+
let title = `New Task Alert ${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
|
|
3330
|
+
let time = inputBody?.scheduleEndTime || '11:59 PM';
|
|
3331
|
+
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
3332
|
+
let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
|
|
3333
|
+
if ( userDetails&&userDetails.fcmToken ) {
|
|
3334
|
+
const fcmToken = userDetails.fcmToken;
|
|
3335
|
+
await sendPushNotification( title, description, fcmToken );
|
|
3336
|
+
}
|
|
3337
|
+
const inputDateTime = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' );
|
|
3338
|
+
const currentTime = dayjs.utc();
|
|
3339
|
+
if ( inputDateTime.isBefore( currentTime ) ) {
|
|
3340
|
+
return res.sendError( 'The input date-time is before the current time.', 500 );
|
|
3341
|
+
}
|
|
3342
|
+
|
|
3343
|
+
let approverList = inputBody?.approver.split( ',' );
|
|
3344
|
+
|
|
3345
|
+
|
|
3346
|
+
let userAdmin = await userService.find( { clientId: inputBody.clientId, email: { $in: approverList }, userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
|
|
3347
|
+
|
|
3348
|
+
if ( userAdmin && userAdmin.length === 0 ) {
|
|
3349
|
+
userAdmin = await userService.find( { clientId: inputBody.clientId, email: 'rohit.chawla@lenskart.com', userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
|
|
3350
|
+
}
|
|
3351
|
+
|
|
3352
|
+
let creator = await userService.find( { clientId: inputBody.clientId, email: 'rohit.chawla@lenskart.com', userType: 'client', isActive: true } );
|
|
3353
|
+
if ( creator && creator.length === 0 ) {
|
|
3354
|
+
return res.sendError( 'Invalid Creator Details', 500 );
|
|
3355
|
+
}
|
|
3356
|
+
|
|
3357
|
+
if ( req.body && req.body.referenceImage && req.body.referenceImage.length > 3 ) {
|
|
3358
|
+
return res.sendError( 'Maximum 3 referenceImage only allowed', 500 );
|
|
3359
|
+
}
|
|
3360
|
+
let data = {
|
|
3361
|
+
checkListName: `${inputBody.taskName}(${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )})`,
|
|
3362
|
+
checkListDescription: inputBody.taskDescription,
|
|
3363
|
+
createdBy: creator[0]._id,
|
|
3364
|
+
createdByName: creator[0].userName,
|
|
3365
|
+
publish: true,
|
|
3366
|
+
questionCount: 1,
|
|
3367
|
+
storeCount: 1,
|
|
3368
|
+
scheduleDate: date,
|
|
3369
|
+
scheduleEndTime: time,
|
|
3370
|
+
scheduleEndTimeISO: dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' ).format(),
|
|
3371
|
+
priorityType: 'high',
|
|
3372
|
+
client_id: inputBody.clientId,
|
|
3373
|
+
checkListType: 'task',
|
|
3374
|
+
publishDate: new Date(),
|
|
3375
|
+
locationCount: 1,
|
|
3376
|
+
...( inputBody?.checkListId ) ? { referenceCheckListId: inputBody?.checkListId } : {},
|
|
3377
|
+
};
|
|
3378
|
+
data['approver'] = userAdmin;
|
|
3379
|
+
let answer = await findAnswer( inputBody?.answerType );
|
|
3380
|
+
if ( answer.length == 0 ) {
|
|
3381
|
+
return res.sendError( 'please enter Valid AnswerType', 500 );
|
|
3382
|
+
}
|
|
3383
|
+
if ( inputBody?.answerType === 'multiplechoicesingle' || inputBody?.answerType === 'multiplechoicemultiple' ) {
|
|
3384
|
+
if ( inputBody?.options && inputBody?.options.length > 0 ) {
|
|
3385
|
+
let optionsResult = [];
|
|
3386
|
+
let optionList = inputBody?.options.split( ',' );
|
|
3387
|
+
for ( let option of optionList ) {
|
|
3388
|
+
let optiondata = {
|
|
3389
|
+
'answer': '',
|
|
3390
|
+
'sopFlag': false,
|
|
3391
|
+
'validation': false,
|
|
3392
|
+
'validationType': '',
|
|
3393
|
+
'referenceImage': [],
|
|
3394
|
+
'runAI': false,
|
|
3395
|
+
'allowUploadfromGallery': false,
|
|
3396
|
+
'descriptivetype': '',
|
|
3397
|
+
'showLinked': false,
|
|
3398
|
+
'linkedQuestion': 0,
|
|
3399
|
+
'nestedQuestion': [],
|
|
3400
|
+
};
|
|
3401
|
+
optiondata.answer = option;
|
|
3402
|
+
optionsResult.push( optiondata );
|
|
3403
|
+
}
|
|
3404
|
+
answer = optionsResult;
|
|
3405
|
+
} else {
|
|
3406
|
+
return res.sendError( 'please enter Valid Options', 500 );
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
3409
|
+
let response = await taskService.create( data );
|
|
3410
|
+
if ( response?.approver.length ) {
|
|
3411
|
+
let inputData = [];
|
|
3412
|
+
response?.approver.forEach( ( ele ) => {
|
|
3413
|
+
inputData.push( {
|
|
3414
|
+
userEmail: ele.email,
|
|
3415
|
+
checkListId: response._id,
|
|
3416
|
+
type: 'task',
|
|
3417
|
+
client_id: inputBody.clientId,
|
|
3418
|
+
checkListName: data?.checkListName || '',
|
|
3419
|
+
} );
|
|
3420
|
+
} );
|
|
3421
|
+
await traxApprover.insertMany( inputData );
|
|
3422
|
+
}
|
|
3423
|
+
if ( response?._id ) {
|
|
3424
|
+
let question = [
|
|
3425
|
+
{
|
|
3426
|
+
'qno': 1,
|
|
3427
|
+
'qname': inputBody.question,
|
|
3428
|
+
'answerType': inputBody?.answerType || 'yes/no',
|
|
3429
|
+
'runAI': false,
|
|
3430
|
+
'runAIDescription': '',
|
|
3431
|
+
'allowUploadfromGallery': false,
|
|
3432
|
+
'linkType': false,
|
|
3433
|
+
'questionReferenceImage': [],
|
|
3434
|
+
'answers': answer,
|
|
3435
|
+
'descriptivetype': 'text',
|
|
3436
|
+
},
|
|
3437
|
+
];
|
|
3438
|
+
let images = [];
|
|
3439
|
+
for ( let imgpath of req.body.referenceImage ) {
|
|
3440
|
+
let configURL = JSON.parse( process.env.BUCKET );
|
|
3441
|
+
let inputData = {
|
|
3442
|
+
Bucket: configURL.commonAiTaskBucket,
|
|
3443
|
+
Key: imgpath,
|
|
3444
|
+
};
|
|
3445
|
+
let output = await getObject( inputData );
|
|
3446
|
+
let image = {
|
|
3447
|
+
data: output.Body,
|
|
3448
|
+
name: imgpath,
|
|
3449
|
+
mimetype: output.ContentType,
|
|
3450
|
+
};
|
|
3451
|
+
let uplaodedImage = await uploadmultiImage( image );
|
|
3452
|
+
|
|
3453
|
+
let imgUrl = decodeURIComponent( uplaodedImage.imgUrl.split( '?' )[0] );
|
|
3454
|
+
let url = imgUrl.split( '/' );
|
|
3455
|
+
if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
|
|
3456
|
+
url.splice( 0, 3 );
|
|
3457
|
+
}
|
|
3458
|
+
images.push( url.join( '/' ) );
|
|
3459
|
+
}
|
|
3460
|
+
question[0].questionReferenceImage = images;
|
|
3461
|
+
|
|
3462
|
+
if ( inputBody?.answerType === 'image' || inputBody?.answerType === 'descriptiveImage' || inputBody?.answerType === 'multipleImage' ) {
|
|
3463
|
+
answer[0].referenceImage = question[0].questionReferenceImage;
|
|
3464
|
+
}
|
|
3465
|
+
|
|
3466
|
+
|
|
3467
|
+
question = {
|
|
3468
|
+
checkListId: response?._id,
|
|
3469
|
+
question: question,
|
|
3470
|
+
section: 'Section 1',
|
|
3471
|
+
checkList: data.checkListName,
|
|
3472
|
+
client_id: inputBody.clientId,
|
|
3473
|
+
};
|
|
3474
|
+
await taskQuestionService.create( question );
|
|
3475
|
+
|
|
3476
|
+
let userDetails = {
|
|
3477
|
+
userName: inputBody.userName,
|
|
3478
|
+
userEmail: inputBody.userEmail,
|
|
3479
|
+
store_id: storeDetails.storeId,
|
|
3480
|
+
storeName: storeDetails.storeName,
|
|
3481
|
+
city: storeDetails?.storeProfile?.city,
|
|
3482
|
+
checkFlag: true,
|
|
3483
|
+
checkListId: response?._id,
|
|
3484
|
+
checkListName: data.checkListName,
|
|
3485
|
+
client_id: inputBody.clientId,
|
|
3486
|
+
userId: userId,
|
|
3487
|
+
};
|
|
3488
|
+
await taskAssignService.create( userDetails );
|
|
3489
|
+
await insertSingleProcessData( response?._id );
|
|
3490
|
+
return res.sendSuccess( 'Task created successfully' );
|
|
3491
|
+
}
|
|
3492
|
+
} catch ( e ) {
|
|
3493
|
+
logger.error( { function: 'commonAiTask', error: e } );
|
|
3494
|
+
return res.sendError( e, 500 );
|
|
3495
|
+
}
|
|
3496
|
+
}
|
|
3497
|
+
|
|
3498
|
+
|
|
3499
|
+
export async function taskcreation( req, res ) {
|
|
3500
|
+
try {
|
|
3501
|
+
let inputBody = req.body;
|
|
3502
|
+
|
|
3503
|
+
inputBody.clientId = 458;
|
|
3504
|
+
inputBody.taskDescription = '';
|
|
3505
|
+
let userId;
|
|
3506
|
+
let storeDetails = await storeService.findOne( { storeName: inputBody.storeName, clientId: inputBody.clientId, status: 'active' }, { storeId: 1, storeName: 1, storeProfile: 1 } );
|
|
3507
|
+
if ( !storeDetails ) {
|
|
3508
|
+
return res.sendError( 'Store Not Found', 500 );
|
|
3509
|
+
}
|
|
3510
|
+
|
|
3511
|
+
|
|
3512
|
+
let finduser = await userService.findOne( { clientId: inputBody.clientId, email: req.body.user, userType: 'client', isActive: true }, { userName: '$userName', email: 1, userId: '$_id' } );
|
|
3513
|
+
console.log( finduser );
|
|
3514
|
+
|
|
3515
|
+
if ( !finduser ) {
|
|
3516
|
+
return res.sendError( 'No user Found', 500 );
|
|
3517
|
+
}
|
|
3518
|
+
|
|
3519
|
+
userId = finduser._id;
|
|
3520
|
+
inputBody.userName = finduser.userName;
|
|
3521
|
+
inputBody.userEmail = finduser.email;
|
|
3522
|
+
|
|
3523
|
+
|
|
3524
|
+
let title = `New Task Alert ${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
|
|
3525
|
+
let time = inputBody?.scheduleEndTime || '11:59 PM';
|
|
3526
|
+
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
3527
|
+
let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
|
|
3528
|
+
if ( userDetails&&userDetails.fcmToken ) {
|
|
3529
|
+
const fcmToken = userDetails.fcmToken;
|
|
3530
|
+
await sendPushNotification( title, description, fcmToken );
|
|
3531
|
+
}
|
|
3532
|
+
const inputDateTime = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' );
|
|
3533
|
+
const currentTime = dayjs.utc();
|
|
3534
|
+
if ( inputDateTime.isBefore( currentTime ) ) {
|
|
3535
|
+
return res.sendError( 'The input date-time is before the current time.', 500 );
|
|
3536
|
+
}
|
|
3537
|
+
|
|
3538
|
+
|
|
3539
|
+
let userAdmin = await userService.find( { clientId: inputBody.clientId, email: inputBody?.approver, userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
|
|
3540
|
+
|
|
3541
|
+
|
|
3542
|
+
if ( userAdmin && userAdmin.length === 0 ) {
|
|
3543
|
+
return res.sendError( 'Invalid Creator Details', 500 );
|
|
3544
|
+
}
|
|
3545
|
+
|
|
3546
|
+
let creator = await userService.find( { clientId: inputBody.clientId, email: inputBody.creator, userType: 'client', isActive: true } );
|
|
3547
|
+
if ( creator && creator.length === 0 ) {
|
|
3548
|
+
return res.sendError( 'Invalid Creator Details', 500 );
|
|
3549
|
+
}
|
|
3550
|
+
|
|
3551
|
+
if ( req.body && req.body.referenceImage && req.body.referenceImage.length > 3 ) {
|
|
3552
|
+
return res.sendError( 'Maximum 3 referenceImage only allowed', 500 );
|
|
3553
|
+
}
|
|
3554
|
+
let data = {
|
|
3555
|
+
checkListName: `${inputBody.taskName}(${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )})`,
|
|
3556
|
+
checkListDescription: inputBody.taskDescription,
|
|
3557
|
+
createdBy: creator[0]._id,
|
|
3558
|
+
createdByName: creator[0].userName,
|
|
3559
|
+
publish: true,
|
|
3560
|
+
questionCount: 1,
|
|
3561
|
+
storeCount: 1,
|
|
3562
|
+
scheduleDate: date,
|
|
3563
|
+
scheduleEndTime: time,
|
|
3564
|
+
scheduleEndTimeISO: dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' ).format(),
|
|
3565
|
+
priorityType: 'high',
|
|
3566
|
+
client_id: inputBody.clientId,
|
|
3567
|
+
checkListType: 'task',
|
|
3568
|
+
publishDate: new Date(),
|
|
3569
|
+
locationCount: 1,
|
|
3570
|
+
...( inputBody?.checkListId ) ? { referenceCheckListId: inputBody?.checkListId } : {},
|
|
3571
|
+
};
|
|
3572
|
+
data['approver'] = userAdmin;
|
|
3573
|
+
let answer = await findAnswer( inputBody?.answerType );
|
|
3574
|
+
if ( answer.length == 0 ) {
|
|
3575
|
+
return res.sendError( 'please enter Valid AnswerType', 500 );
|
|
3576
|
+
}
|
|
3577
|
+
if ( inputBody?.answerType === 'multiplechoicesingle' || inputBody?.answerType === 'multiplechoicemultiple' ) {
|
|
3578
|
+
if ( inputBody?.options && inputBody?.options.length > 0 ) {
|
|
3579
|
+
let optionsResult = [];
|
|
3580
|
+
let optionList = inputBody?.options.split( ',' );
|
|
3581
|
+
for ( let option of optionList ) {
|
|
3582
|
+
let optiondata = {
|
|
3583
|
+
'answer': '',
|
|
3584
|
+
'sopFlag': false,
|
|
3585
|
+
'validation': false,
|
|
3586
|
+
'validationType': '',
|
|
3587
|
+
'referenceImage': [],
|
|
3588
|
+
'runAI': false,
|
|
3589
|
+
'allowUploadfromGallery': false,
|
|
3590
|
+
'descriptivetype': '',
|
|
3591
|
+
'showLinked': false,
|
|
3592
|
+
'linkedQuestion': 0,
|
|
3593
|
+
'nestedQuestion': [],
|
|
3594
|
+
};
|
|
3595
|
+
optiondata.answer = option;
|
|
3596
|
+
optionsResult.push( optiondata );
|
|
3597
|
+
}
|
|
3598
|
+
answer = optionsResult;
|
|
3599
|
+
} else {
|
|
3600
|
+
return res.sendError( 'please enter Valid Options', 500 );
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
let response = await taskService.create( data );
|
|
3604
|
+
if ( response?.approver.length ) {
|
|
3605
|
+
let inputData = [];
|
|
3606
|
+
response?.approver.forEach( ( ele ) => {
|
|
3607
|
+
inputData.push( {
|
|
3608
|
+
userEmail: ele.email,
|
|
3609
|
+
checkListId: response._id,
|
|
3610
|
+
type: 'task',
|
|
3611
|
+
client_id: inputBody.clientId,
|
|
3612
|
+
checkListName: data?.checkListName || '',
|
|
3613
|
+
} );
|
|
3614
|
+
} );
|
|
3615
|
+
await traxApprover.insertMany( inputData );
|
|
3616
|
+
}
|
|
3617
|
+
if ( response?._id ) {
|
|
3618
|
+
let question = [
|
|
3619
|
+
{
|
|
3620
|
+
'qno': 1,
|
|
3621
|
+
'qname': inputBody.question,
|
|
3622
|
+
'answerType': inputBody?.answerType || 'yes/no',
|
|
3623
|
+
'runAI': false,
|
|
3624
|
+
'runAIDescription': '',
|
|
3625
|
+
'allowUploadfromGallery': false,
|
|
3626
|
+
'linkType': false,
|
|
3627
|
+
'questionReferenceImage': [],
|
|
3628
|
+
'answers': answer,
|
|
3629
|
+
'descriptivetype': 'text',
|
|
3630
|
+
},
|
|
3631
|
+
];
|
|
3632
|
+
let images = [];
|
|
3633
|
+
|
|
3634
|
+
// for ( let imgpath of req.body.referenceImage ) {
|
|
3635
|
+
// let configURL = JSON.parse( process.env.BUCKET );
|
|
3636
|
+
// let inputData = {
|
|
3637
|
+
// Bucket: configURL.commonAiTaskBucket,
|
|
3638
|
+
// Key: imgpath,
|
|
3639
|
+
// };
|
|
3640
|
+
// let output = await getObject( inputData );
|
|
3641
|
+
// console.log( output );
|
|
3642
|
+
|
|
3643
|
+
// let image = {
|
|
3644
|
+
// data: output.Body,
|
|
3645
|
+
// name: imgpath,
|
|
3646
|
+
// mimetype: output.ContentType,
|
|
3647
|
+
// };
|
|
3648
|
+
// let uplaodedImage = await uploadmultiImage( image );
|
|
3649
|
+
|
|
3650
|
+
// let imgUrl = decodeURIComponent( uplaodedImage.imgUrl.split( '?' )[0] );
|
|
3651
|
+
// let url = imgUrl.split( '/' );
|
|
3652
|
+
// if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
|
|
3653
|
+
// url.splice( 0, 3 );
|
|
3654
|
+
// }
|
|
3655
|
+
// images.push( url.join( '/' ) );
|
|
3656
|
+
// }
|
|
3657
|
+
question[0].questionReferenceImage = images;
|
|
3658
|
+
|
|
3659
|
+
if ( inputBody?.answerType === 'image' || inputBody?.answerType === 'descriptiveImage' || inputBody?.answerType === 'multipleImage' ) {
|
|
3660
|
+
answer[0].referenceImage = question[0].questionReferenceImage;
|
|
3661
|
+
}
|
|
3662
|
+
|
|
3663
|
+
|
|
3664
|
+
question = {
|
|
3665
|
+
checkListId: response?._id,
|
|
3666
|
+
question: question,
|
|
3667
|
+
section: 'Section 1',
|
|
3668
|
+
checkList: data.checkListName,
|
|
3669
|
+
client_id: inputBody.clientId,
|
|
3670
|
+
};
|
|
3671
|
+
await taskQuestionService.create( question );
|
|
3672
|
+
let userDetails = {
|
|
3673
|
+
userName: inputBody.userName,
|
|
3674
|
+
userEmail: inputBody.userEmail,
|
|
3675
|
+
store_id: storeDetails.storeId,
|
|
3676
|
+
storeName: storeDetails.storeName,
|
|
3677
|
+
city: storeDetails?.storeProfile?.city,
|
|
3678
|
+
checkFlag: true,
|
|
3679
|
+
checkListId: response?._id,
|
|
3680
|
+
checkListName: data.checkListName,
|
|
3681
|
+
client_id: inputBody.clientId,
|
|
3682
|
+
userId: userId,
|
|
3683
|
+
};
|
|
3684
|
+
await taskAssignService.create( userDetails );
|
|
3685
|
+
await insertSingleProcessData( response?._id );
|
|
3686
|
+
return res.sendSuccess( 'Task created successfully' );
|
|
3687
|
+
}
|
|
3688
|
+
} catch ( e ) {
|
|
3689
|
+
logger.error( { function: 'taskcreation ventota', error: e } );
|
|
3690
|
+
return res.sendError( e, 500 );
|
|
3691
|
+
}
|
|
3692
|
+
}
|
package/src/dtos/task.dto.js
CHANGED
|
@@ -34,7 +34,35 @@ export const eyeTesttaskSchema = Joi.object().keys( {
|
|
|
34
34
|
scheduleEndTime: Joi.string().required(),
|
|
35
35
|
referenceImage: Joi.any().optional(),
|
|
36
36
|
} );
|
|
37
|
+
export const commonAiTaskSchema = Joi.object().keys( {
|
|
38
|
+
storeName: Joi.string().required(),
|
|
39
|
+
taskName: Joi.string().required(),
|
|
40
|
+
question: Joi.string().required(),
|
|
41
|
+
answerType: Joi.string().required(),
|
|
42
|
+
options: Joi.string().optional(),
|
|
43
|
+
scheduleDate: Joi.string().optional(),
|
|
44
|
+
scheduleEndTime: Joi.string().optional(),
|
|
45
|
+
referenceImage: Joi.array().required(),
|
|
46
|
+
} );
|
|
47
|
+
export const taskcreationSchema = Joi.object().keys( {
|
|
48
|
+
storeName: Joi.string().required(),
|
|
49
|
+
taskName: Joi.string().required(),
|
|
50
|
+
user: Joi.string().required(),
|
|
51
|
+
question: Joi.string().required(),
|
|
52
|
+
answerType: Joi.string().required(),
|
|
53
|
+
options: Joi.array().optional(),
|
|
54
|
+
scheduleDate: Joi.string().optional(),
|
|
55
|
+
scheduleEndTime: Joi.string().optional(),
|
|
56
|
+
approver: Joi.string().required(),
|
|
57
|
+
creator: Joi.string().required(),
|
|
58
|
+
} );
|
|
37
59
|
|
|
60
|
+
export const commonAiTaskvalidation = {
|
|
61
|
+
body: commonAiTaskSchema,
|
|
62
|
+
};
|
|
63
|
+
export const taskcreationvalidation = {
|
|
64
|
+
body: taskcreationSchema,
|
|
65
|
+
};
|
|
38
66
|
export const aitaskvalidation = {
|
|
39
67
|
body: aitaskvalidationSchema,
|
|
40
68
|
};
|
|
@@ -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 } from '../dtos/task.dto.js';
|
|
5
|
+
import { aitaskvalidation, StoreHygienetaskvalidation, eyeTesttaskvalidation, commonAiTaskvalidation, taskcreationvalidation } from '../dtos/task.dto.js';
|
|
6
6
|
export const taskRouter = express.Router();
|
|
7
7
|
|
|
8
8
|
taskRouter
|
|
@@ -31,6 +31,8 @@ taskRouter
|
|
|
31
31
|
.post( '/createaiTask', isAllowedInternalAPIHandler, validate( aitaskvalidation ), taskController.createAiTask )
|
|
32
32
|
.post( '/StoreHygienetask', isAllowedInternalAPIHandler, validate( StoreHygienetaskvalidation ), taskController.StoreHygienetask )
|
|
33
33
|
.post( '/eyeTesttask', isAllowedInternalAPIHandler, validate( eyeTesttaskvalidation ), taskController.eyeTesttask )
|
|
34
|
+
.post( '/commonAiTask', isAllowedInternalAPIHandler, validate( commonAiTaskvalidation ), taskController.commonAiTask )
|
|
35
|
+
.post( '/taskcreation', isAllowedInternalAPIHandler, validate( taskcreationvalidation ), taskController.taskcreation )
|
|
34
36
|
.get( '/getcoustemer', taskController.customertrial );
|
|
35
37
|
|
|
36
38
|
|