tango-app-api-task 3.7.45 → 3.7.46

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.45",
3
+ "version": "3.7.46",
4
4
  "description": "Task",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -17,8 +17,10 @@ const ObjectId = mongoose.Types.ObjectId;
17
17
  import dayjs from 'dayjs';
18
18
  import customParseFormat from 'dayjs/plugin/customParseFormat.js';
19
19
  import utc from 'dayjs/plugin/utc.js';
20
+ import timeZone from 'dayjs/plugin/timezone.js';
20
21
  dayjs.extend( utc );
21
22
  dayjs.extend( customParseFormat );
23
+ dayjs.extend( timeZone );
22
24
  import * as taskProcessedConfigService from '../service/processedTaskConfig.service.js';
23
25
  import * as taskProcessedService from '../service/processedTaskList.service.js';
24
26
  import * as ApproverModel from '../service/approver.service.js';
@@ -1238,7 +1240,7 @@ function findObjectDifference( oldObj, newObj ) {
1238
1240
 
1239
1241
  export async function insertSingleProcessData( checklistId, answerTypechange, inputBody, insertfrom ) {
1240
1242
  try {
1241
- let currentdate = new Date();
1243
+ let currentdate = dayjs.utc().format();
1242
1244
  let date = dayjs( currentdate ).format();
1243
1245
  let getCLconfig = await taskService.findOne( { _id: new ObjectId( checklistId ), publish: true } );
1244
1246
  if ( getCLconfig ) {
@@ -1256,13 +1258,13 @@ export async function insertSingleProcessData( checklistId, answerTypechange, in
1256
1258
  startTimeIso = dayjs.utc( sTime, 'hh:mm A' );
1257
1259
  endTimeIso = dayjs.utc( getCLconfig.scheduleEndTimeISO );
1258
1260
  let insertdata = {};
1259
- insertdata.date_iso = new Date( dayjs( date, 'YYYY-MM-DD' ).format( 'YYYY-MM-DD' ) );
1260
- insertdata.date_string = dayjs( currentdate ).format( 'YYYY-MM-DD' );
1261
+ insertdata.date_iso = startTimeIso.startOf( 'day' );
1262
+ insertdata.date_string = startTimeIso.format( 'YYYY-MM-DD' );
1261
1263
  insertdata.sourceCheckList_id = getCLconfig._id;
1262
1264
  insertdata.checkListName = getCLconfig.checkListName;
1263
1265
  insertdata.checkListDescription = getCLconfig.checkListDescription;
1264
1266
  insertdata.publish = getCLconfig.publish;
1265
- insertdata.scheduleStartTime = '12:00 AM';
1267
+ insertdata.scheduleStartTime = sTime;
1266
1268
  insertdata.scheduleStartTime_iso = startTimeIso.format();
1267
1269
  insertdata.scheduleEndTime = getCLconfig.scheduleEndTime;
1268
1270
  insertdata.scheduleEndTime_iso = endTimeIso.format();
@@ -1951,7 +1953,7 @@ export async function createChecklistTask( req, res ) {
1951
1953
  priorityType: 'high',
1952
1954
  client_id: inputBody.clientId,
1953
1955
  checkListType: inputBody.checkListType,
1954
- publishDate: new Date(),
1956
+ publishDate: dayjs.utc().format(),
1955
1957
  locationCount: 1,
1956
1958
  ...( inputBody?.checkListId ) ? { referenceCheckListId: inputBody?.checkListId } : {},
1957
1959
  coverage: checklistDetails?.coverage || 'store',
@@ -2824,6 +2826,7 @@ export const taskDropdown = async ( req, res ) => {
2824
2826
  scheduleStartTime: 1,
2825
2827
  scheduleEndTime: 1,
2826
2828
  coverage: 1,
2829
+ checkListDescription: 1,
2827
2830
  },
2828
2831
  } );
2829
2832
 
@@ -2839,6 +2842,7 @@ export const taskDropdown = async ( req, res ) => {
2839
2842
  scheduleStartTime: { $last: '$scheduleStartTime' },
2840
2843
  scheduleEndTime: { $last: '$scheduleEndTime' },
2841
2844
  coverage: { $last: '$coverage' },
2845
+ checkListDescription: { $last: '$checkListDescription' },
2842
2846
  },
2843
2847
  } );
2844
2848
 
@@ -2878,27 +2882,26 @@ export const taskDropdown = async ( req, res ) => {
2878
2882
  scheduleStartTime: 1,
2879
2883
  scheduleEndTime: 1,
2880
2884
  coverage: 1,
2881
- checkListDescription: '$checklistconfigs.checkListDescription',
2885
+ checkListDescription: 1,
2886
+ checklistconfigs: 1,
2882
2887
  publish: '$checklistconfigs.publish',
2883
2888
  },
2884
2889
  } );
2885
2890
 
2886
- let getTotalCount = await taskProcessedConfigService.aggregate( findQuery );
2887
- if ( !getTotalCount.length ) {
2888
- return res.sendError( { error: 'No Data Found' }, 204 );
2889
- }
2890
-
2891
2891
  if ( requestData.sortColumnName && requestData.sortColumnName != '' && requestData.sortBy && requestData.sortBy != '' ) {
2892
- findQuery.push( { $sort: { [requestData.sortColumnName]: requestData.sortBy } } );
2892
+ findQuery.push( { $sort: { [requestData.sortColumnName]: Number( requestData.sortBy ) } } );
2893
2893
  } else {
2894
2894
  findQuery.push( { $sort: { ['checkListName']: -1 } } );
2895
2895
  }
2896
2896
 
2897
2897
  let getChecklistData = await taskProcessedConfigService.aggregate( findQuery );
2898
+ if ( !getChecklistData.length ) {
2899
+ return res.sendError( { error: 'No Data Found' }, 204 );
2900
+ }
2898
2901
  result.checklistData = getChecklistData;
2899
2902
  return res.sendSuccess( result );
2900
2903
  } catch ( error ) {
2901
- logger.error( { error: error, message: req.query, function: 'checklistDropdown' } );
2904
+ logger.error( { error: error, message: req.query, function: 'taskDropdown' } );
2902
2905
  return res.sendError( { error: error }, 500 );
2903
2906
  }
2904
2907
  };
@@ -5078,7 +5081,7 @@ export async function taskcreation( req, res ) {
5078
5081
  }
5079
5082
 
5080
5083
 
5081
- let finduser = await userService.findOne( { clientId: inputBody.clientId, email: req.body.user, userType: 'client', isActive: true }, { userName: '$userName', email: 1, userId: '$_id' } );
5084
+ let finduser = await userService.findOne( { clientId: inputBody.clientId, email: req.body.user, userType: 'client', isActive: true }, { userName: '$userName', email: 1, userId: '$_id', fcmToken: 1 } );
5082
5085
  // console.log( finduser );
5083
5086
 
5084
5087
  if ( !finduser ) {
@@ -5092,10 +5095,10 @@ export async function taskcreation( req, res ) {
5092
5095
 
5093
5096
  let title = `New Task Alert ${inputBody.taskName}-`+storeDetails?.storeName ? storeDetails?.storeName : ``+`-${dayjs().format( 'YYYY-MM-DD' )}`;
5094
5097
  let time = inputBody?.scheduleEndTime || '11:59 PM';
5095
- let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
5098
+ let date = inputBody?.scheduleDate || dayjs.utc().format( 'YYYY-MM-DD' );
5096
5099
  let description = `A new task has been assigned to`+storeDetails?.storeName ? storeDetails?.storeName : `you` +`. Please complete it before the due date of ${date}.`;
5097
- if ( userDetails && userDetails.fcmToken ) {
5098
- const fcmToken = userDetails.fcmToken;
5100
+ if ( finduser && finduser.fcmToken ) {
5101
+ const fcmToken = finduser.fcmToken;
5099
5102
  await sendPushNotification( title, description, fcmToken );
5100
5103
  }
5101
5104
  const inputDateTime = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' );
@@ -5134,13 +5137,13 @@ export async function taskcreation( req, res ) {
5134
5137
  publish: true,
5135
5138
  questionCount: inputBody?.questions?.length || 1,
5136
5139
  storeCount: 1,
5137
- scheduleDate: date,
5140
+ scheduleDate: dayjs.utc( inputBody.scheduleDate ).format(),
5138
5141
  scheduleEndTime: time,
5139
5142
  scheduleEndTimeISO: dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' ).format(),
5140
5143
  priorityType: 'high',
5141
5144
  client_id: inputBody.clientId,
5142
5145
  checkListType: 'task',
5143
- publishDate: new Date(),
5146
+ publishDate: dayjs().format(),
5144
5147
  locationCount: 1,
5145
5148
  ...( inputBody?.checkListId ) ? { referenceCheckListId: inputBody?.checkListId } : {},
5146
5149
  coverage: inputBody?.storeName ? 'store' : 'user',