tango-app-api-task 3.2.1-beta-15 → 3.2.1-beta-17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-task",
3
- "version": "3.2.1-beta-15",
3
+ "version": "3.2.1-beta-17",
4
4
  "description": "Task",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,4 +1,4 @@
1
- import { logger, fileUpload, signedUrl } from 'tango-app-api-middleware';
1
+ import { logger, fileUpload, signedUrl, getObject } from 'tango-app-api-middleware';
2
2
  import * as taskService from '../service/task.service.js';
3
3
  import * as checklistLogs from '../service/checklistLog.service.js';
4
4
  import * as taskQuestionService from '../service/taskQuestion.service.js';
@@ -1420,9 +1420,9 @@ export async function createChecklistTask( req, res ) {
1420
1420
  body: JSON.stringify( params ),
1421
1421
  };
1422
1422
  let url = JSON.parse( process.env.LAMBDAURL );
1423
- console.log( url.redoChecklist );
1423
+
1424
1424
  let searchResponse = await fetch( url.redoChecklist, requestOptions );
1425
- console.log( searchResponse.ok );
1425
+
1426
1426
 
1427
1427
  if ( !searchResponse.ok ) {
1428
1428
  return res.sendError( 'Something went wrong', 500 );
@@ -1456,7 +1456,7 @@ export async function approveTask( req, res ) {
1456
1456
  let updateResponse = await taskProcessedService.updateMany( { _id: { $in: idList } }, { approvalStatus: true } );
1457
1457
  if ( updateResponse.modifiedCount || updateResponse.matchedCount ) {
1458
1458
  let inputstores = taskDetails.filter( ( data ) => data.checklistStatus == 'submit' );
1459
- console.log( inputstores );
1459
+
1460
1460
  let params = {
1461
1461
  'payload': {
1462
1462
  sourceCheckList_id: req.body.sourceCheckList_id,
@@ -1468,7 +1468,7 @@ export async function approveTask( req, res ) {
1468
1468
  approvalStatus: true,
1469
1469
  },
1470
1470
  };
1471
- console.log( params );
1471
+
1472
1472
 
1473
1473
  const requestOptions = {
1474
1474
  method: 'POST',
@@ -1478,9 +1478,9 @@ export async function approveTask( req, res ) {
1478
1478
  body: JSON.stringify( params ),
1479
1479
  };
1480
1480
  let url = JSON.parse( process.env.LAMBDAURL );
1481
- console.log( url.approveTask );
1481
+
1482
1482
  let searchResponse = await fetch( url.approveTask, requestOptions );
1483
- console.log( searchResponse.ok );
1483
+
1484
1484
  if ( searchResponse.ok ) {
1485
1485
  let pendingstores = taskDetails.filter( ( data ) => data.checklistStatus != 'submit' );
1486
1486
  if ( pendingstores && pendingstores.length > 0 ) {
@@ -1526,7 +1526,7 @@ export async function redoTask( req, res ) {
1526
1526
  }
1527
1527
  let data = { ...question[sectionIndex].questions[req.body.payload.qno - 1], redo: true, redoComment: req.body.payload?.checklistDescription || '' };
1528
1528
  let userAnswer = data.userAnswer;
1529
- console.log( userAnswer );
1529
+
1530
1530
  question[sectionIndex].questions[req.body.payload.qno - 1] = data;
1531
1531
  question[sectionIndex].questions[req.body.payload.qno - 1].remarks = '';
1532
1532
  question[sectionIndex].questions[req.body.payload.qno - 1].userAnswer = [];
@@ -1567,7 +1567,7 @@ export async function redoTask( req, res ) {
1567
1567
  submitedBy: taskDetails.userName,
1568
1568
  submitTime: taskDetails.submitTime,
1569
1569
  };
1570
- console.log( data );
1570
+
1571
1571
  await checklistLogs.create( data );
1572
1572
  const requestOptions = {
1573
1573
  method: 'POST',
@@ -1762,7 +1762,6 @@ export async function approvalstatus( req, res ) {
1762
1762
  let url = JSON.parse( process.env.LAMBDAURL );
1763
1763
  let resultData = await LamdaServiceCall( url.approvalstatustask, req.body );
1764
1764
  if ( resultData ) {
1765
- console.log( resultData.status_code );
1766
1765
  if ( resultData.status_code == '200' ) {
1767
1766
  return res.sendSuccess( resultData );
1768
1767
  }
@@ -1775,7 +1774,7 @@ export async function approvalstatus( req, res ) {
1775
1774
 
1776
1775
  let url = JSON.parse( process.env.LAMBDAURL );
1777
1776
  let resultData = await LamdaServiceCall( url.approvalstatustask, req.body );
1778
- console.log( resultData );
1777
+
1779
1778
  if ( resultData ) {
1780
1779
  if ( resultData.status_code == '200' ) {
1781
1780
  return res.sendSuccess( resultData );
@@ -2101,11 +2100,9 @@ export async function teamMigrations( req, res ) {
2101
2100
  store: findStore._id,
2102
2101
  },
2103
2102
  ];
2104
- console.log( user.userEmail );
2105
- console.log( '***********' );
2106
- console.log( updateStore );
2107
2103
  let updateUser = await userService.updateOne( { email: user.userEmail }, { assignedStores: updateStore } );
2108
2104
  console.log( updateUser );
2105
+
2109
2106
  let leamexits = await userService.findOne( { email: user.AomMailId } );
2110
2107
  if ( leamexits ) {
2111
2108
  let teamsExist = await findOneTeams( { 'teamName': user.AomUserName } );
@@ -2232,7 +2229,7 @@ export async function createAiChecklist( req, res ) {
2232
2229
  }
2233
2230
 
2234
2231
  let userAdmin = await userService.findOne( { clientId: inputBody.clientId, role: 'superadmin', isActive: true } );
2235
- console.log( userAdmin );
2232
+
2236
2233
 
2237
2234
  let data = {
2238
2235
  checkListName: `${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`,
@@ -2356,10 +2353,10 @@ export async function createAiChecklist( req, res ) {
2356
2353
  return res.sendError( e, 500 );
2357
2354
  }
2358
2355
  }
2359
- export async function createAiTaskNew( req, res ) {
2356
+ export async function StoreHygienetask( req, res ) {
2360
2357
  try {
2361
2358
  let inputBody = req.body;
2362
- console.log( inputBody );
2359
+
2363
2360
  inputBody.clientId = 11;
2364
2361
  inputBody.taskDescription = '';
2365
2362
  let userId;
@@ -2367,21 +2364,22 @@ export async function createAiTaskNew( req, res ) {
2367
2364
  if ( !storeDetails ) {
2368
2365
  return res.sendError( 'Store Not Found', 500 );
2369
2366
  }
2370
- console.log( storeDetails );
2367
+
2371
2368
  let url = JSON.parse( process.env.LAMBDAURL );
2372
2369
  let checklistId = url.dailystoreChecklistId;
2373
2370
  let finduser = await checklistassignconfigModel.findOne( { checkListId: new mongoose.Types.ObjectId( checklistId ), store_id: storeDetails.storeId } );
2374
- console.log( finduser );
2371
+
2375
2372
  if ( !finduser ) {
2376
2373
  return res.sendError( 'No user Found For this store', 500 );
2377
2374
  }
2375
+
2378
2376
  userId = finduser.userId;
2379
2377
  inputBody.userName = finduser.userName;
2380
2378
  inputBody.userEmail = finduser.userEmail;
2381
2379
 
2382
2380
 
2383
2381
  let teamList = await findteams( { users: { $elemMatch: { email: finduser.userEmail } } } );
2384
- console.log( teamList );
2382
+
2385
2383
  inputBody.approver = '';
2386
2384
  for ( let team of teamList ) {
2387
2385
  for ( let user of team.Teamlead ) {
@@ -2389,8 +2387,6 @@ export async function createAiTaskNew( req, res ) {
2389
2387
  }
2390
2388
  }
2391
2389
  inputBody.approver = inputBody.approver.replace( /,$/, '' );
2392
- console.log( inputBody?.approver );
2393
- // return;
2394
2390
 
2395
2391
 
2396
2392
  // let title = `New Task Alert ${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
@@ -2408,10 +2404,10 @@ export async function createAiTaskNew( req, res ) {
2408
2404
  }
2409
2405
 
2410
2406
  let approverList = inputBody?.approver.split( ',' );
2411
- console.log( approverList );
2407
+
2412
2408
 
2413
2409
  let userAdmin = await userService.find( { clientId: inputBody.clientId, email: { $in: approverList }, userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
2414
- console.log( userAdmin );
2410
+
2415
2411
  if ( userAdmin && userAdmin.length === 0 ) {
2416
2412
  userAdmin = await userService.find( { clientId: inputBody.clientId, email: 'rohit.chawla@lenskart.com', userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
2417
2413
  }
@@ -2420,12 +2416,231 @@ export async function createAiTaskNew( req, res ) {
2420
2416
  if ( creator && creator.length === 0 ) {
2421
2417
  return res.sendError( 'Invalid Creator Details', 500 );
2422
2418
  }
2423
- if ( req.files && req.files.referenceImage && req.files.referenceImage.length > 3 ) {
2419
+
2420
+ if ( req.body && req.body.referenceImage && req.body.referenceImage.length > 3 ) {
2424
2421
  return res.sendError( 'Maximum 3 referenceImage only allowed', 500 );
2425
2422
  }
2423
+ let data = {
2424
+ checkListName: `${inputBody.taskName}(${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}-${inputBody.count})`,
2425
+ checkListDescription: inputBody.taskDescription,
2426
+ createdBy: creator[0]._id,
2427
+ createdByName: creator[0].userName,
2428
+ publish: true,
2429
+ questionCount: 1,
2430
+ storeCount: 1,
2431
+ scheduleDate: date,
2432
+ scheduleEndTime: time,
2433
+ scheduleEndTimeISO: dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' ).format(),
2434
+ priorityType: 'high',
2435
+ client_id: inputBody.clientId,
2436
+ checkListType: 'task',
2437
+ publishDate: new Date(),
2438
+ locationCount: 1,
2439
+ ...( inputBody?.checkListId ) ? { referenceCheckListId: inputBody?.checkListId } : {},
2440
+ };
2441
+
2426
2442
 
2443
+ data['approver'] = userAdmin;
2444
+
2445
+
2446
+ let answer = await findAnswer( inputBody?.answerType );
2447
+ if ( answer.length == 0 ) {
2448
+ return res.sendError( 'please enter Valid AnswerType', 500 );
2449
+ }
2450
+ if ( inputBody?.answerType === 'multiplechoicesingle' || inputBody?.answerType === 'multiplechoicemultiple' ) {
2451
+ if ( inputBody?.options && inputBody?.options.length > 0 ) {
2452
+ let optionsResult = [];
2453
+ let optionList = inputBody?.options.split( ',' );
2454
+ for ( let option of optionList ) {
2455
+ let optiondata = {
2456
+ 'answer': '',
2457
+ 'sopFlag': false,
2458
+ 'validation': false,
2459
+ 'validationType': '',
2460
+ 'referenceImage': [],
2461
+ 'runAI': false,
2462
+ 'allowUploadfromGallery': false,
2463
+ 'descriptivetype': '',
2464
+ 'showLinked': false,
2465
+ 'linkedQuestion': 0,
2466
+ 'nestedQuestion': [],
2467
+ };
2468
+ optiondata.answer = option;
2469
+ optionsResult.push( optiondata );
2470
+ }
2471
+ answer = optionsResult;
2472
+ } else {
2473
+ return res.sendError( 'please enter Valid Options', 500 );
2474
+ }
2475
+ }
2476
+
2477
+
2478
+ let response = await taskService.create( data );
2479
+ if ( response?.approver.length ) {
2480
+ let inputData = [];
2481
+ response?.approver.forEach( ( ele ) => {
2482
+ inputData.push( {
2483
+ userEmail: ele.email,
2484
+ checkListId: response._id,
2485
+ type: 'task',
2486
+ client_id: inputBody.clientId,
2487
+ checkListName: data?.checkListName || '',
2488
+ } );
2489
+ } );
2490
+
2491
+ await traxApprover.insertMany( inputData );
2492
+ }
2493
+
2494
+ if ( response?._id ) {
2495
+ let question = [
2496
+ {
2497
+ 'qno': 1,
2498
+ 'qname': inputBody.question,
2499
+ 'answerType': inputBody?.answerType || 'yes/no',
2500
+ 'runAI': false,
2501
+ 'runAIDescription': '',
2502
+ 'allowUploadfromGallery': false,
2503
+ 'linkType': false,
2504
+ 'questionReferenceImage': [],
2505
+ 'answers': answer,
2506
+ 'descriptivetype': 'text',
2507
+ },
2508
+ ];
2509
+
2510
+
2511
+ let images = [];
2512
+
2513
+ for ( let imgpath of req.body.referenceImage ) {
2514
+ let configURL = JSON.parse( process.env.BUCKET );
2515
+ let inputData = {
2516
+ Bucket: configURL.aiTraxoutput,
2517
+ Key: imgpath,
2518
+ };
2519
+
2520
+
2521
+ let output = await getObject( inputData );
2522
+
2523
+
2524
+ let image = {
2525
+ data: output.Body,
2526
+ name: imgpath,
2527
+ mimetype: output.ContentType,
2528
+ };
2529
+ let uplaodedImage = await uploadmultiImage( image );
2530
+
2531
+ let imgUrl = decodeURIComponent( uplaodedImage.imgUrl.split( '?' )[0] );
2532
+ let url = imgUrl.split( '/' );
2533
+ if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
2534
+ url.splice( 0, 3 );
2535
+ }
2536
+ images.push( url.join( '/' ) );
2537
+ }
2538
+ question[0].questionReferenceImage = images;
2539
+
2540
+ if ( inputBody?.answerType === 'image' || inputBody?.answerType === 'descriptiveImage' || inputBody?.answerType === 'multipleImage' ) {
2541
+ answer[0].referenceImage = question[0].questionReferenceImage;
2542
+ }
2543
+
2544
+
2545
+ question = {
2546
+ checkListId: response?._id,
2547
+ question: question,
2548
+ section: 'Section 1',
2549
+ checkList: data.checkListName,
2550
+ client_id: inputBody.clientId,
2551
+ };
2552
+ await taskQuestionService.create( question );
2553
+
2554
+ let userDetails = {
2555
+ userName: inputBody.userName,
2556
+ userEmail: inputBody.userEmail,
2557
+ store_id: storeDetails.storeId,
2558
+ storeName: storeDetails.storeName,
2559
+ city: storeDetails?.storeProfile?.city,
2560
+ checkFlag: true,
2561
+ checkListId: response?._id,
2562
+ checkListName: data.checkListName,
2563
+ client_id: inputBody.clientId,
2564
+ userId: userId,
2565
+ };
2566
+ await taskAssignService.create( userDetails );
2567
+ await insertSingleProcessData( response?._id );
2568
+ return res.sendSuccess( 'Task created successfully' );
2569
+ }
2570
+ } catch ( e ) {
2571
+ logger.error( { function: 'StoreHygienetask', error: e } );
2572
+ return res.sendError( e, 500 );
2573
+ }
2574
+ }
2575
+ export async function eyeTesttask( req, res ) {
2576
+ try {
2577
+ let inputBody = req.body;
2578
+ inputBody.clientId = 11;
2579
+ inputBody.taskDescription = '';
2580
+ let userId;
2581
+ let storeDetails = await storeService.findOne( { storeName: inputBody.storeName, clientId: inputBody.clientId, status: 'active' }, { storeId: 1, storeName: 1, storeProfile: 1 } );
2582
+ if ( !storeDetails ) {
2583
+ return res.sendError( 'Store Not Found', 500 );
2584
+ }
2585
+
2586
+ let url = JSON.parse( process.env.LAMBDAURL );
2587
+ let checklistId = url.dailystoreChecklistId;
2588
+ let finduser = await checklistassignconfigModel.findOne( { checkListId: new mongoose.Types.ObjectId( checklistId ), store_id: storeDetails.storeId } );
2589
+
2590
+ if ( !finduser ) {
2591
+ return res.sendError( 'No user Found For this store', 500 );
2592
+ }
2593
+
2594
+ userId = finduser.userId;
2595
+ inputBody.userName = finduser.userName;
2596
+ inputBody.userEmail = finduser.userEmail;
2597
+
2598
+
2599
+ let teamList = await findteams( { users: { $elemMatch: { email: finduser.userEmail } } } );
2600
+
2601
+ inputBody.approver = '';
2602
+ for ( let team of teamList ) {
2603
+ for ( let user of team.Teamlead ) {
2604
+ inputBody.approver = user.email + ',' + inputBody.approver;
2605
+ }
2606
+ }
2607
+ inputBody.approver = inputBody.approver.replace( /,$/, '' );
2608
+
2609
+
2610
+ // let title = `New Task Alert ${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
2611
+ let time = inputBody?.scheduleEndTime || '11:59 PM';
2612
+ let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
2613
+ // let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
2614
+ // if ( userDetails&&userDetails.fcmToken ) {
2615
+ // const fcmToken = userDetails.fcmToken;
2616
+ // await sendPushNotification( title, description, fcmToken );
2617
+ // }
2618
+ const inputDateTime = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' );
2619
+ const currentTime = dayjs.utc();
2620
+ if ( inputDateTime.isBefore( currentTime ) ) {
2621
+ return res.sendError( 'The input date-time is before the current time.', 500 );
2622
+ }
2623
+
2624
+ let approverList = inputBody?.approver.split( ',' );
2625
+
2626
+
2627
+ let userAdmin = await userService.find( { clientId: inputBody.clientId, email: { $in: approverList }, userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
2628
+
2629
+ if ( userAdmin && userAdmin.length === 0 ) {
2630
+ userAdmin = await userService.find( { clientId: inputBody.clientId, email: 'rohit.chawla@lenskart.com', userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
2631
+ }
2632
+
2633
+ let creator = await userService.find( { clientId: inputBody.clientId, email: 'rohit.chawla@lenskart.com', userType: 'client', isActive: true } );
2634
+ if ( creator && creator.length === 0 ) {
2635
+ return res.sendError( 'Invalid Creator Details', 500 );
2636
+ }
2637
+
2638
+
2639
+ if ( req.body && req.body.referenceImage && req.body.referenceImage.length > 3 ) {
2640
+ return res.sendError( 'Maximum 3 referenceImage only allowed', 500 );
2641
+ }
2427
2642
  let data = {
2428
- checkListName: `${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`,
2643
+ checkListName: `${inputBody.taskName}(${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}-${inputBody.count})`,
2429
2644
  checkListDescription: inputBody.taskDescription,
2430
2645
  createdBy: creator[0]._id,
2431
2646
  createdByName: creator[0].userName,
@@ -2445,14 +2660,13 @@ export async function createAiTaskNew( req, res ) {
2445
2660
 
2446
2661
 
2447
2662
  data['approver'] = userAdmin;
2448
- console.log( data );
2663
+
2449
2664
 
2450
2665
  let answer = await findAnswer( inputBody?.answerType );
2451
2666
  if ( answer.length == 0 ) {
2452
2667
  return res.sendError( 'please enter Valid AnswerType', 500 );
2453
2668
  }
2454
2669
  if ( inputBody?.answerType === 'multiplechoicesingle' || inputBody?.answerType === 'multiplechoicemultiple' ) {
2455
- console.log( inputBody?.options );
2456
2670
  if ( inputBody?.options && inputBody?.options.length > 0 ) {
2457
2671
  let optionsResult = [];
2458
2672
  let optionList = inputBody?.options.split( ',' );
@@ -2484,7 +2698,6 @@ export async function createAiTaskNew( req, res ) {
2484
2698
  if ( response?.approver.length ) {
2485
2699
  let inputData = [];
2486
2700
  response?.approver.forEach( ( ele ) => {
2487
- console.log( data );
2488
2701
  inputData.push( {
2489
2702
  userEmail: ele.email,
2490
2703
  checkListId: response._id,
@@ -2493,7 +2706,7 @@ export async function createAiTaskNew( req, res ) {
2493
2706
  checkListName: data?.checkListName || '',
2494
2707
  } );
2495
2708
  } );
2496
- console.log( inputData );
2709
+
2497
2710
  await traxApprover.insertMany( inputData );
2498
2711
  }
2499
2712
 
@@ -2516,7 +2729,6 @@ export async function createAiTaskNew( req, res ) {
2516
2729
 
2517
2730
  if ( req.files && req.files.referenceImage && req.files.referenceImage.length ) {
2518
2731
  let images = [];
2519
- console.log( req.files.referenceImage.length );
2520
2732
 
2521
2733
 
2522
2734
  for ( let image of req.files.referenceImage ) {
@@ -2528,8 +2740,20 @@ export async function createAiTaskNew( req, res ) {
2528
2740
  }
2529
2741
  images.push( url.join( '/' ) );
2530
2742
  }
2743
+ question[0].questionReferenceImage = images;
2744
+ } else {
2745
+ let images = [];
2746
+ let uplaodedImage = await uploadmultiImage( req.files.referenceImage );
2747
+ let imgUrl = decodeURIComponent( uplaodedImage.imgUrl.split( '?' )[0] );
2748
+ let url = imgUrl.split( '/' );
2749
+ if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
2750
+ url.splice( 0, 3 );
2751
+ }
2752
+ images.push( url.join( '/' ) );
2753
+
2531
2754
  question[0].questionReferenceImage = images;
2532
2755
  }
2756
+
2533
2757
  if ( inputBody?.answerType === 'image' || inputBody?.answerType === 'descriptiveImage' || inputBody?.answerType === 'multipleImage' ) {
2534
2758
  answer[0].referenceImage = question[0].questionReferenceImage;
2535
2759
  }
@@ -2556,13 +2780,12 @@ export async function createAiTaskNew( req, res ) {
2556
2780
  client_id: inputBody.clientId,
2557
2781
  userId: userId,
2558
2782
  };
2559
- console.log( userDetails );
2560
2783
  await taskAssignService.create( userDetails );
2561
2784
  await insertSingleProcessData( response?._id );
2562
2785
  return res.sendSuccess( 'Task created successfully' );
2563
2786
  }
2564
2787
  } catch ( e ) {
2565
- logger.error( { function: 'createAiTaskNew', error: e } );
2788
+ logger.error( { function: 'eyeTesttask', error: e } );
2566
2789
  return res.sendError( e, 500 );
2567
2790
  }
2568
2791
  }
@@ -2576,11 +2799,11 @@ export async function createAiTask( req, res ) {
2576
2799
  if ( !storeDetails ) {
2577
2800
  return res.sendError( 'Store Not Found', 500 );
2578
2801
  }
2579
- console.log( storeDetails );
2802
+
2580
2803
  let url = JSON.parse( process.env.LAMBDAURL );
2581
2804
  let checklistId = url.dailystoreChecklistId;
2582
2805
  let finduser = await checklistassignconfigModel.findOne( { checkListId: new mongoose.Types.ObjectId( checklistId ), store_id: storeDetails.storeId } );
2583
- console.log( finduser );
2806
+
2584
2807
  if ( !finduser ) {
2585
2808
  return res.sendError( 'No user Found For this store', 500 );
2586
2809
  }
@@ -2604,10 +2827,10 @@ export async function createAiTask( req, res ) {
2604
2827
  }
2605
2828
 
2606
2829
  let approverList = inputBody?.approver.split( ',' );
2607
- console.log( approverList );
2830
+
2608
2831
 
2609
2832
  let userAdmin = await userService.find( { clientId: inputBody.clientId, email: { $in: approverList }, userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
2610
- console.log( userAdmin );
2833
+
2611
2834
  if ( userAdmin && userAdmin.length === 0 ) {
2612
2835
  return res.sendError( 'Invalid Approver Details', 500 );
2613
2836
  }
@@ -2641,14 +2864,13 @@ export async function createAiTask( req, res ) {
2641
2864
 
2642
2865
 
2643
2866
  data['approver'] = userAdmin;
2644
- console.log( data );
2867
+
2645
2868
 
2646
2869
  let answer = await findAnswer( inputBody?.answerType );
2647
2870
  if ( answer.length == 0 ) {
2648
2871
  return res.sendError( 'please enter Valid AnswerType', 500 );
2649
2872
  }
2650
2873
  if ( inputBody?.answerType === 'multiplechoicesingle' || inputBody?.answerType === 'multiplechoicemultiple' ) {
2651
- console.log( inputBody?.options );
2652
2874
  if ( inputBody?.options && inputBody?.options.length > 0 ) {
2653
2875
  let optionsResult = [];
2654
2876
  let optionList = inputBody?.options.split( ',' );
@@ -2680,7 +2902,6 @@ export async function createAiTask( req, res ) {
2680
2902
  if ( response?.approver.length ) {
2681
2903
  let inputData = [];
2682
2904
  response?.approver.forEach( ( ele ) => {
2683
- console.log( data );
2684
2905
  inputData.push( {
2685
2906
  userEmail: ele.email,
2686
2907
  checkListId: response._id,
@@ -2689,7 +2910,7 @@ export async function createAiTask( req, res ) {
2689
2910
  checkListName: data?.checkListName || '',
2690
2911
  } );
2691
2912
  } );
2692
- console.log( inputData );
2913
+
2693
2914
  await traxApprover.insertMany( inputData );
2694
2915
  }
2695
2916
 
@@ -2712,7 +2933,6 @@ export async function createAiTask( req, res ) {
2712
2933
 
2713
2934
  if ( req.files && req.files.referenceImage && req.files.referenceImage.length ) {
2714
2935
  let images = [];
2715
- console.log( req.files.referenceImage.length );
2716
2936
 
2717
2937
 
2718
2938
  for ( let image of req.files.referenceImage ) {
@@ -2752,7 +2972,7 @@ export async function createAiTask( req, res ) {
2752
2972
  client_id: inputBody.clientId,
2753
2973
  userId: userId,
2754
2974
  };
2755
- console.log( userDetails );
2975
+
2756
2976
  await taskAssignService.create( userDetails );
2757
2977
  await insertSingleProcessData( response?._id );
2758
2978
  return res.sendSuccess( 'Task created successfully' );
@@ -3040,14 +3260,25 @@ export async function uploadmultiImage( images ) {
3040
3260
 
3041
3261
  export async function customertrial( params ) {
3042
3262
  try {
3263
+ // let inputData = {
3264
+ // Bucket: 'tango-trax-audit',
3265
+ // file_path: 'trail/59-147/b1c5b15c0133dec0c45640d923fda221_10_09_59_000_24_01_2025_false.mp4',
3266
+ // };
3267
+ // let url = await signedUrl( inputData );
3268
+ // console.log( url );
3269
+
3270
+
3043
3271
  let inputData = {
3044
3272
  Bucket: 'tango-trax-audit',
3045
- file_path: 'trail/59-147/b1c5b15c0133dec0c45640d923fda221_10_09_59_000_24_01_2025_false.mp4',
3273
+ Key: 'hygiene/16-01-2025/11-2212/11-2212_13d76f2dd3ea3123aa476a885893c9fd_labelled.jpeg',
3046
3274
  };
3047
- let url = await signedUrl( inputData );
3275
+
3276
+
3277
+ let url = await getObject( inputData );
3048
3278
  console.log( url );
3049
3279
  } catch ( e ) {
3050
3280
  logger.error( 'uploadImage =>', e );
3051
3281
  return e;
3052
3282
  }
3053
3283
  };
3284
+
@@ -12,7 +12,7 @@ export const aitaskvalidationSchema = Joi.object().keys( {
12
12
  scheduleDate: Joi.string().optional(),
13
13
  scheduleEndTime: Joi.string().optional(),
14
14
  } );
15
- export const aitaskvalidationSchemanew = Joi.object().keys( {
15
+ export const StoreHygienetaskSchema = Joi.object().keys( {
16
16
  storeName: Joi.string().required(),
17
17
  taskName: Joi.string().required(),
18
18
  question: Joi.string().required(),
@@ -20,12 +20,27 @@ export const aitaskvalidationSchemanew = Joi.object().keys( {
20
20
  options: Joi.string().optional(),
21
21
  scheduleDate: Joi.string().optional(),
22
22
  scheduleEndTime: Joi.string().optional(),
23
- referenceImage: Joi.string().optional(),
23
+ referenceImage: Joi.array().required(),
24
+ count: Joi.number().required(),
25
+ } );
26
+
27
+
28
+ export const eyeTesttaskSchema = Joi.object().keys( {
29
+ storeName: Joi.string().required(),
30
+ taskName: Joi.string().required(),
31
+ question: Joi.string().required(),
32
+ answerType: Joi.string().required(),
33
+ scheduleDate: Joi.string().required(),
34
+ scheduleEndTime: Joi.string().required(),
35
+ referenceImage: Joi.any().optional(),
24
36
  } );
25
37
 
26
38
  export const aitaskvalidation = {
27
39
  body: aitaskvalidationSchema,
28
40
  };
29
- export const aitaskvalidationNew = {
30
- body: aitaskvalidationSchemanew,
41
+ export const StoreHygienetaskvalidation = {
42
+ body: StoreHygienetaskSchema,
43
+ };
44
+ export const eyeTesttaskvalidation = {
45
+ body: eyeTesttaskSchema,
31
46
  };
@@ -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, aitaskvalidationNew } from '../dtos/task.dto.js';
5
+ import { aitaskvalidation, StoreHygienetaskvalidation, eyeTesttaskvalidation } from '../dtos/task.dto.js';
6
6
  export const taskRouter = express.Router();
7
7
 
8
8
  taskRouter
@@ -29,7 +29,8 @@ taskRouter
29
29
  .get( '/clusterMigrations', taskController.clusterMigrations )
30
30
  .post( '/createaiChecklist', isAllowedInternalAPIHandler, taskController.createAiChecklist )
31
31
  .post( '/createaiTask', isAllowedInternalAPIHandler, validate( aitaskvalidation ), taskController.createAiTask )
32
- .post( '/createAiTaskNew', isAllowedInternalAPIHandler, validate( aitaskvalidationNew ), taskController.createAiTaskNew )
32
+ .post( '/StoreHygienetask', isAllowedInternalAPIHandler, validate( StoreHygienetaskvalidation ), taskController.StoreHygienetask )
33
+ .post( '/eyeTesttask', isAllowedInternalAPIHandler, validate( eyeTesttaskvalidation ), taskController.eyeTesttask )
33
34
  .get( '/getcoustemer', taskController.customertrial );
34
35
 
35
36