tango-app-api-task 3.7.38 → 3.7.40

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.7.38",
3
+ "version": "3.7.40",
4
4
  "description": "Task",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -2029,7 +2029,7 @@ export async function createChecklistTask( req, res ) {
2029
2029
  await taskQuestionService.create( question );
2030
2030
  let storeDetails;
2031
2031
  if ( inputBody?.storeName ) {
2032
- storeDetails = await storeService.findOne( { storeName: inputBody.storeName, status: 'active' }, { storeId: 1, storeProfile: 1 } );
2032
+ storeDetails = await storeService.findOne( { storeName: inputBody.storeName, status: 'active', clientId: inputBody.clientId }, { storeId: 1, storeProfile: 1 } );
2033
2033
  }
2034
2034
 
2035
2035
  let userDetails = {
@@ -2277,7 +2277,7 @@ export async function createChecklistMultiTask( req, res ) {
2277
2277
 
2278
2278
  let storeDetails;
2279
2279
  if ( originaldata?.storeName ) {
2280
- storeDetails = await storeService.findOne( { storeName: originaldata.storeName, status: 'active' }, { storeId: 1, storeProfile: 1 } );
2280
+ storeDetails = await storeService.findOne( { storeName: originaldata.storeName, status: 'active', clientId: inputBody.clientId }, { storeId: 1, storeProfile: 1 } );
2281
2281
  }
2282
2282
  let findUser = await userService.findOne( { email: originaldata.userEmail } );
2283
2283
  let userDetails = {
@@ -7249,7 +7249,7 @@ export async function AITaskCreation( req, res ) {
7249
7249
  // Send Push Notification
7250
7250
  // inputBody.approver = inputBody.approver.replace( /,$/, '' );
7251
7251
  let title = `New Task Alert ${inputBody.taskName}-${storeData.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
7252
- let time = inputBody?.scheduleEndTime || '11:59 PM';
7252
+ let time = inputBody?.scheduleEndTime ? dayjs( inputBody?.scheduleEndTime, 'hh:mm A' ).format( 'HH:mm' ) :'23:59';
7253
7253
  let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
7254
7254
  let description = `A new task has been assigned to ${storeData.storeName}. Please complete it before the due date of ${date}.`;
7255
7255
  await Promise.all( finduser.map( async ( ele ) => {
@@ -7258,19 +7258,18 @@ export async function AITaskCreation( req, res ) {
7258
7258
  sendPushNotification( title, description, fcmToken );
7259
7259
  }
7260
7260
  } ) );
7261
-
7262
- inputBody['scheduleEndData'] = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' ).format();
7261
+ // inputBody['scheduleEndData'] = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD HH:mm' ).format();
7263
7262
  if ( checklistDetails?.aiConfig?.autoTaskConfig.taskValidity?.type == 'mins' ) {
7264
- inputBody['scheduleEndData'] = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' ).add( checklistDetails?.aiConfig?.autoTaskConfig.taskValidity.time, 'minute' ).format();
7263
+ inputBody['scheduleEndData'] = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD HH:mm' ).add( checklistDetails?.aiConfig?.autoTaskConfig.taskValidity.time, 'minute' ).format();
7265
7264
  }
7266
7265
  if ( checklistDetails?.aiConfig?.autoTaskConfig.taskValidity?.type == 'hours' ) {
7267
- inputBody['scheduleEndData'] = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' ).add( checklistDetails?.aiConfig?.autoTaskConfig.taskValidity.time, 'hour' ).format();
7266
+ inputBody['scheduleEndData'] = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD HH:mm' ).add( checklistDetails?.aiConfig?.autoTaskConfig.taskValidity.time, 'hour' ).format();
7268
7267
  }
7269
7268
  if ( checklistDetails?.aiConfig?.autoTaskConfig.taskValidity?.type == 'days' ) {
7270
- inputBody['scheduleEndData'] = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' ).add( checklistDetails?.aiConfig?.autoTaskConfig.taskValidity.time, 'day' ).format();
7269
+ inputBody['scheduleEndData'] = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD HH:mm' ).add( checklistDetails?.aiConfig?.autoTaskConfig.taskValidity.time, 'day' ).format();
7271
7270
  }
7272
7271
 
7273
- const inputDateTime = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' );
7272
+ const inputDateTime = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD HH:mm' );
7274
7273
  const currentTime = dayjs.utc();
7275
7274
  if ( inputDateTime.isBefore( currentTime ) ) {
7276
7275
  return res.sendError( 'The input date-time is before the current time.', 500 );
@@ -7566,11 +7565,11 @@ async function insertAItaskProcessedTaskCreation( checkTask, inputBody, date, ti
7566
7565
  delete oldData.submitMobileTime;
7567
7566
  delete oldData.startMobileTime;
7568
7567
  oldData.date_iso = new Date( dayjs( date, 'YYYY-MM-DD' ).format( 'YYYY-MM-DD' ) );
7569
- oldData.date_string = dayjs( date ).format( 'YYYY-MM-DD' );
7568
+ oldData.date_string = date;
7570
7569
  oldData.scheduleStartTime_iso = inputBody?.scheduleEndTime ?dayjs.utc( inputBody?.scheduleEndTime, 'hh:mm A' ).format() : date;
7571
- oldData.scheduleEndTime_iso = dayjs.utc( inputBody.scheduleEndData, 'YYYY-MM-DD hh:mm A' ).format();
7572
- oldData.scheduleEndTime = dayjs.utc( inputBody.scheduleEndData, 'YYYY-MM-DD hh:mm A' ).format( 'hh:mm A' );
7573
- oldData.scheduleStartTime = inputBody?.scheduleEndTime ?? dayjs.utc().format( 'hh:mm A' );
7570
+ oldData.scheduleEndTime_iso = dayjs.utc( inputBody.scheduleEndData ).format();
7571
+ oldData.scheduleEndTime = dayjs.utc( inputBody.scheduleEndData ).format( 'hh:mm A' );
7572
+ oldData.scheduleStartTime = inputBody?.scheduleEndTime ?? dayjs.format( 'hh:mm A' );
7574
7573
  oldData.store_id = storeDetails.storeId;
7575
7574
  oldData.storeName = storeDetails.storeName;
7576
7575
  oldData.country = storeDetails.storeProfile.country;
@@ -7589,6 +7588,9 @@ async function insertAItaskProcessedTaskCreation( checkTask, inputBody, date, ti
7589
7588
  oldData.questionAnswers = [ questions ];
7590
7589
  oldData.zoneName = inputBody.zoneName || '';
7591
7590
  oldData.checkListType = 'task' || '';
7591
+ if ( inputBody.streamId ) {
7592
+ oldData.streamId = inputBody?.streamId;
7593
+ }
7592
7594
  if ( inputBody.aiType ) {
7593
7595
  oldData.aiType = inputBody.aiType;
7594
7596
  }