tango-app-api-task 3.7.19 → 3.7.21
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
|
@@ -5038,12 +5038,9 @@ export async function taskcreation( req, res ) {
|
|
|
5038
5038
|
inputBody.clientId = 458;
|
|
5039
5039
|
inputBody.taskDescription = '';
|
|
5040
5040
|
let userId;
|
|
5041
|
-
let storeDetails;
|
|
5042
|
-
if (
|
|
5043
|
-
|
|
5044
|
-
if ( !storeDetails ) {
|
|
5045
|
-
return res.sendError( 'Store Not Found', 500 );
|
|
5046
|
-
}
|
|
5041
|
+
let storeDetails = await storeService.findOne( { storeName: inputBody.storeName, clientId: inputBody.clientId, status: 'active' }, { storeId: 1, storeName: 1, storeProfile: 1 } );
|
|
5042
|
+
if ( !storeDetails ) {
|
|
5043
|
+
return res.sendError( 'Store Not Found', 500 );
|
|
5047
5044
|
}
|
|
5048
5045
|
|
|
5049
5046
|
|
|
@@ -5059,10 +5056,10 @@ export async function taskcreation( req, res ) {
|
|
|
5059
5056
|
inputBody.userEmail = finduser.email;
|
|
5060
5057
|
|
|
5061
5058
|
|
|
5062
|
-
let title = `New Task Alert ${inputBody.taskName}
|
|
5059
|
+
let title = `New Task Alert ${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
|
|
5063
5060
|
let time = inputBody?.scheduleEndTime || '11:59 PM';
|
|
5064
5061
|
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
5065
|
-
let description = `A new task has been assigned to
|
|
5062
|
+
let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
|
|
5066
5063
|
if ( userDetails && userDetails.fcmToken ) {
|
|
5067
5064
|
const fcmToken = userDetails.fcmToken;
|
|
5068
5065
|
await sendPushNotification( title, description, fcmToken );
|
|
@@ -5089,19 +5086,13 @@ export async function taskcreation( req, res ) {
|
|
|
5089
5086
|
if ( req.body && req.body.referenceImage && req.body.referenceImage.length > 3 ) {
|
|
5090
5087
|
return res.sendError( 'Maximum 3 referenceImage only allowed', 500 );
|
|
5091
5088
|
}
|
|
5092
|
-
let taskName;
|
|
5093
|
-
if ( inputBody?.storeName ) {
|
|
5094
|
-
taskName = `${inputBody.taskName}(${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )})`;
|
|
5095
|
-
} else {
|
|
5096
|
-
taskName = `${inputBody.taskName}(-${dayjs().format( 'YYYY-MM-DD' )})`;
|
|
5097
|
-
}
|
|
5098
5089
|
let data = {
|
|
5099
|
-
checkListName: taskName
|
|
5090
|
+
checkListName: `${inputBody.taskName}(${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )})`,
|
|
5100
5091
|
checkListDescription: inputBody.taskDescription,
|
|
5101
5092
|
createdBy: creator[0]._id,
|
|
5102
5093
|
createdByName: creator[0].userName,
|
|
5103
5094
|
publish: true,
|
|
5104
|
-
questionCount:
|
|
5095
|
+
questionCount: 1,
|
|
5105
5096
|
storeCount: 1,
|
|
5106
5097
|
scheduleDate: date,
|
|
5107
5098
|
scheduleEndTime: time,
|
|
@@ -5112,7 +5103,6 @@ export async function taskcreation( req, res ) {
|
|
|
5112
5103
|
publishDate: new Date(),
|
|
5113
5104
|
locationCount: 1,
|
|
5114
5105
|
...( inputBody?.checkListId ) ? { referenceCheckListId: inputBody?.checkListId } : {},
|
|
5115
|
-
coverage: inputBody?.storeName ? 'store' : 'user',
|
|
5116
5106
|
};
|
|
5117
5107
|
let clientDetails = await clientService.findOne( { clientId: inputBody?.clientId }, { traxVideoUploadTimeLimit: 1 } );
|
|
5118
5108
|
data['videoUploadTimeLimit'] = clientDetails?.traxVideoUploadTimeLimit || 0;
|
|
@@ -5220,8 +5210,8 @@ export async function taskcreation( req, res ) {
|
|
|
5220
5210
|
let userDetails = {
|
|
5221
5211
|
userName: inputBody.userName,
|
|
5222
5212
|
userEmail: inputBody.userEmail,
|
|
5223
|
-
store_id: storeDetails
|
|
5224
|
-
storeName: storeDetails
|
|
5213
|
+
store_id: storeDetails.storeId,
|
|
5214
|
+
storeName: storeDetails.storeName,
|
|
5225
5215
|
city: storeDetails?.storeProfile?.city,
|
|
5226
5216
|
checkFlag: true,
|
|
5227
5217
|
checkListId: response?._id,
|
|
@@ -5231,7 +5221,6 @@ export async function taskcreation( req, res ) {
|
|
|
5231
5221
|
assignId: storeDetails?._id,
|
|
5232
5222
|
country: storeDetails?.storeProfile?.country,
|
|
5233
5223
|
state: storeDetails?.storeProfile?.state,
|
|
5234
|
-
coverage: inputBody?.storeName ? 'store' : 'user',
|
|
5235
5224
|
};
|
|
5236
5225
|
await taskAssignService.create( userDetails );
|
|
5237
5226
|
await insertSingleProcessData( response?._id );
|
|
@@ -5549,11 +5538,12 @@ export async function userMigrations( req, res ) {
|
|
|
5549
5538
|
export async function StoreHygienetask( req, res ) {
|
|
5550
5539
|
try {
|
|
5551
5540
|
let inputBody = req.body;
|
|
5552
|
-
|
|
5553
|
-
|
|
5541
|
+
if ( !inputBody?.clientId ) {
|
|
5542
|
+
inputBody.clientId = 11;
|
|
5543
|
+
}
|
|
5554
5544
|
inputBody.taskDescription = '';
|
|
5555
5545
|
let userId;
|
|
5556
|
-
let storeDetails = await storeService.findOne( { storeName: inputBody.storeName, clientId: inputBody.clientId, status: 'active' }, { storeId: 1, storeName: 1, storeProfile: 1 } );
|
|
5546
|
+
let storeDetails = await storeService.findOne( { storeName: inputBody.storeName, clientId: inputBody.clientId, status: 'active' }, { storeId: 1, storeName: 1, storeProfile: 1, spocDetails: 1 } );
|
|
5557
5547
|
if ( !storeDetails ) {
|
|
5558
5548
|
return res.sendError( 'Store Not Found', 500 );
|
|
5559
5549
|
}
|
|
@@ -5566,7 +5556,25 @@ export async function StoreHygienetask( req, res ) {
|
|
|
5566
5556
|
|
|
5567
5557
|
let finduser = await checklistassignconfigModel.findOne( { checkListId: { $in: [ dailychecklistId, KSAchecklistId, UAEchecklistId, singaporechecklistId ] }, store_id: storeDetails.storeId } );
|
|
5568
5558
|
if ( !finduser ) {
|
|
5569
|
-
|
|
5559
|
+
finduser = await userService.findOne( { email: storeDetails?.spocDetails?.[0]?.email, clientId: inputBody.clientId }, { userId: '$_id', userName: 1, userEmail: '$email' } );
|
|
5560
|
+
if ( !finduser ) {
|
|
5561
|
+
finduser = await userService.findOne( { email: storeDetails?.spocDetails?.[0]?.email, clientId: { $ne: inputBody.clientId } }, { userId: '$_id', userName: 1, userEmail: '$email' } );
|
|
5562
|
+
if ( finduser ) {
|
|
5563
|
+
return res.sendError( 'UserEmail is mapped with another clientId', 400 );
|
|
5564
|
+
}
|
|
5565
|
+
let userData = {
|
|
5566
|
+
userName: storeDetails?.spocDetails?.[0]?.email.split( '@' )?.[0],
|
|
5567
|
+
email: storeDetails?.spocDetails?.[0]?.email,
|
|
5568
|
+
mobileNumber: '',
|
|
5569
|
+
clientId: inputBody.clientId,
|
|
5570
|
+
};
|
|
5571
|
+
|
|
5572
|
+
finduser = await createUser( userData );
|
|
5573
|
+
finduser.userId = finduser._id;
|
|
5574
|
+
finduser.userName = finduser.userName;
|
|
5575
|
+
finduser.userEmail = finduser.email;
|
|
5576
|
+
}
|
|
5577
|
+
// return res.sendError( 'No user Found For this store', 500 );
|
|
5570
5578
|
}
|
|
5571
5579
|
|
|
5572
5580
|
userId = finduser.userId;
|
|
@@ -5599,10 +5607,10 @@ export async function StoreHygienetask( req, res ) {
|
|
|
5599
5607
|
let approverList = inputBody?.approver.split( ',' );
|
|
5600
5608
|
let userAdmin = await userService.find( { clientId: inputBody.clientId, email: { $in: approverList }, userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
|
|
5601
5609
|
if ( userAdmin && userAdmin.length === 0 ) {
|
|
5602
|
-
userAdmin = await userService.find( { clientId: inputBody.clientId,
|
|
5610
|
+
userAdmin = await userService.find( { clientId: inputBody.clientId, role: 'superadmin', userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
|
|
5603
5611
|
}
|
|
5604
5612
|
|
|
5605
|
-
let creator = await userService.find( { clientId: inputBody.clientId,
|
|
5613
|
+
let creator = await userService.find( { clientId: inputBody.clientId, role: 'superadmin', userType: 'client', isActive: true } );
|
|
5606
5614
|
if ( creator && creator.length === 0 ) {
|
|
5607
5615
|
return res.sendError( 'Invalid Creator Details', 500 );
|
|
5608
5616
|
}
|
|
@@ -6077,19 +6085,19 @@ async function insertStoreHygienetaskSingleProcessedTask( checkTask, inputBody,
|
|
|
6077
6085
|
newData.checkListType = 'task' || '';
|
|
6078
6086
|
let insertprocessdata = await taskProcessedService.insert( newData );
|
|
6079
6087
|
if ( insertprocessdata ) {
|
|
6080
|
-
if ( response?.approver.length ) {
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
}
|
|
6088
|
+
// if ( response?.approver.length ) {
|
|
6089
|
+
// let inputData = [];
|
|
6090
|
+
// response?.approver.forEach( ( ele ) => {
|
|
6091
|
+
// inputData.push( {
|
|
6092
|
+
// userEmail: ele.email,
|
|
6093
|
+
// checkListId: response._id,
|
|
6094
|
+
// type: 'task',
|
|
6095
|
+
// client_id: inputBody.clientId,
|
|
6096
|
+
// checkListName: data?.checkListName || '',
|
|
6097
|
+
// } );
|
|
6098
|
+
// } );
|
|
6099
|
+
// await traxApprover.insertMany( inputData );
|
|
6100
|
+
// }
|
|
6093
6101
|
return true;
|
|
6094
6102
|
} else {
|
|
6095
6103
|
return false;
|
|
@@ -6742,7 +6750,7 @@ export async function createAITaskGroup( req, res ) {
|
|
|
6742
6750
|
],
|
|
6743
6751
|
},
|
|
6744
6752
|
{
|
|
6745
|
-
|
|
6753
|
+
featureName: 'TangoEye',
|
|
6746
6754
|
modules: [
|
|
6747
6755
|
{
|
|
6748
6756
|
name: 'ZoneTag',
|
|
@@ -6753,7 +6761,7 @@ export async function createAITaskGroup( req, res ) {
|
|
|
6753
6761
|
],
|
|
6754
6762
|
},
|
|
6755
6763
|
{
|
|
6756
|
-
|
|
6764
|
+
featureName: 'TangoTrax',
|
|
6757
6765
|
modules: [
|
|
6758
6766
|
{
|
|
6759
6767
|
name: 'checklist',
|
|
@@ -6769,6 +6777,29 @@ export async function createAITaskGroup( req, res ) {
|
|
|
6769
6777
|
},
|
|
6770
6778
|
],
|
|
6771
6779
|
},
|
|
6780
|
+
{
|
|
6781
|
+
featureName: 'FootfallDirectory',
|
|
6782
|
+
modules: [
|
|
6783
|
+
{
|
|
6784
|
+
name: 'creator',
|
|
6785
|
+
isAdd: true,
|
|
6786
|
+
isEdit: true,
|
|
6787
|
+
|
|
6788
|
+
},
|
|
6789
|
+
{
|
|
6790
|
+
name: 'reviewer',
|
|
6791
|
+
isAdd: false,
|
|
6792
|
+
isEdit: false,
|
|
6793
|
+
|
|
6794
|
+
},
|
|
6795
|
+
{
|
|
6796
|
+
name: 'approver',
|
|
6797
|
+
isAdd: false,
|
|
6798
|
+
isEdit: false,
|
|
6799
|
+
|
|
6800
|
+
},
|
|
6801
|
+
],
|
|
6802
|
+
},
|
|
6772
6803
|
],
|
|
6773
6804
|
};
|
|
6774
6805
|
let response = await userService.create( params );
|
package/src/dtos/task.dto.js
CHANGED
|
@@ -22,6 +22,7 @@ export const StoreHygienetaskSchema = Joi.object().keys( {
|
|
|
22
22
|
scheduleEndTime: Joi.string().optional(),
|
|
23
23
|
referenceImage: Joi.array().required(),
|
|
24
24
|
zoneName: Joi.string().required(),
|
|
25
|
+
clientId: Joi.string().optional(),
|
|
25
26
|
} );
|
|
26
27
|
|
|
27
28
|
|
|
@@ -55,7 +56,7 @@ const gettaskSchema = Joi.object( {
|
|
|
55
56
|
sourceCheckList_id: Joi.string().required(),
|
|
56
57
|
} );
|
|
57
58
|
export const taskcreationSchema = Joi.object().keys( {
|
|
58
|
-
storeName: Joi.string().
|
|
59
|
+
storeName: Joi.string().required(),
|
|
59
60
|
taskName: Joi.string().required(),
|
|
60
61
|
user: Joi.string().required(),
|
|
61
62
|
questions: Joi.array().items( questionSchema ).required(),
|
|
@@ -64,7 +65,6 @@ export const taskcreationSchema = Joi.object().keys( {
|
|
|
64
65
|
scheduleEndTime: Joi.string().optional(),
|
|
65
66
|
approver: Joi.string().required(),
|
|
66
67
|
creator: Joi.string().required(),
|
|
67
|
-
coverage: Joi.string().optional(),
|
|
68
68
|
} );
|
|
69
69
|
|
|
70
70
|
export const commonAiTaskvalidation = {
|