tango-app-api-task 3.6.2-bulktask-9 → 3.7.2-fairprice-1
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 +1 -1
- package/src/controllers/task.controller.js +403 -59
- package/src/dtos/task.dto.js +21 -0
- package/src/routes/task.routes.js +3 -2
package/package.json
CHANGED
|
@@ -117,26 +117,26 @@ export async function createUpdateTask( req, res ) {
|
|
|
117
117
|
for ( let i = 0; i < inputBody?.sections?.length; i++ ) {
|
|
118
118
|
let section = inputBody.sections[i];
|
|
119
119
|
section.questions.forEach( ( section ) => {
|
|
120
|
-
if ( section.questionReferenceImage && section.questionReferenceImage.length ) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
section.answers.forEach( ( answer ) => {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
} );
|
|
120
|
+
// if ( section.questionReferenceImage && section.questionReferenceImage.length ) {
|
|
121
|
+
// let image = [];
|
|
122
|
+
// for ( let img of section.questionReferenceImage ) {
|
|
123
|
+
// let imgUrl = decodeURIComponent( img.split( '?' )[0] );
|
|
124
|
+
// let url = imgUrl.split( '/' );
|
|
125
|
+
// url.splice( 0, 3 );
|
|
126
|
+
// image.push( url.join( '/' ) );
|
|
127
|
+
// }
|
|
128
|
+
// section.questionReferenceImage = image;
|
|
129
|
+
// }
|
|
130
|
+
// section.answers.forEach( ( answer ) => {
|
|
131
|
+
// if ( answer.referenceImage.length ) {
|
|
132
|
+
// answer.referenceImage = answer.referenceImage.map( ( value ) => {
|
|
133
|
+
// let imgUrl = decodeURIComponent( value?.split( '?' )[0] );
|
|
134
|
+
// let url = imgUrl.split( '/' );
|
|
135
|
+
// url.splice( 0, 3 );
|
|
136
|
+
// return url.join( '/' );
|
|
137
|
+
// } );
|
|
138
|
+
// }
|
|
139
|
+
// } );
|
|
140
140
|
} );
|
|
141
141
|
|
|
142
142
|
sectionList.push( {
|
|
@@ -256,7 +256,8 @@ export async function createUpdateTask( req, res ) {
|
|
|
256
256
|
},
|
|
257
257
|
userType: req?.user?.userType || '',
|
|
258
258
|
};
|
|
259
|
-
await insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, insertLogData );
|
|
259
|
+
// await insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, insertLogData );
|
|
260
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, insertLogData );
|
|
260
261
|
}
|
|
261
262
|
} else {
|
|
262
263
|
let logObj = {
|
|
@@ -275,7 +276,8 @@ export async function createUpdateTask( req, res ) {
|
|
|
275
276
|
logDetails: {},
|
|
276
277
|
userType: req?.user?.userType || '',
|
|
277
278
|
};
|
|
278
|
-
await insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, logObj );
|
|
279
|
+
// await insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, logObj );
|
|
280
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, logObj );
|
|
279
281
|
}
|
|
280
282
|
|
|
281
283
|
if ( inputBody?.submitType == 'save' ) {
|
|
@@ -295,7 +297,8 @@ export async function createUpdateTask( req, res ) {
|
|
|
295
297
|
logDetails: {},
|
|
296
298
|
userType: req?.user?.userType || '',
|
|
297
299
|
};
|
|
298
|
-
await insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, logObj );
|
|
300
|
+
// await insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, logObj );
|
|
301
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, logObj );
|
|
299
302
|
}
|
|
300
303
|
return res.sendSuccess( { checklistId: checkListId, message: message } );
|
|
301
304
|
} else {
|
|
@@ -360,42 +363,42 @@ export async function taskDetails( req, res ) {
|
|
|
360
363
|
let questionDetails = await taskQuestionService.find( query );
|
|
361
364
|
if ( questionDetails.length ) {
|
|
362
365
|
let sections = [];
|
|
363
|
-
let bucket = JSON.parse( process.env.BUCKET );
|
|
366
|
+
// let bucket = JSON.parse( process.env.BUCKET );
|
|
364
367
|
questionDetails.forEach( ( item ) => {
|
|
365
|
-
item.question.forEach( async ( question ) => {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
} );
|
|
368
|
+
// item.question.forEach( async ( question ) => {
|
|
369
|
+
// if ( question.questionReferenceImage && question.questionReferenceImage != '' && typeof question.questionReferenceImage == 'string' ) {
|
|
370
|
+
// let inputData = {
|
|
371
|
+
// Bucket: bucket.sop,
|
|
372
|
+
// file_path: decodeURIComponent( question.questionReferenceImage ),
|
|
373
|
+
// };
|
|
374
|
+
// question.questionReferenceImage = await signedUrl( inputData );
|
|
375
|
+
// } else {
|
|
376
|
+
// if ( question.questionReferenceImage.length ) {
|
|
377
|
+
// let image = [];
|
|
378
|
+
// for ( let img of question.questionReferenceImage ) {
|
|
379
|
+
// let inputData = {
|
|
380
|
+
// Bucket: bucket.sop,
|
|
381
|
+
// file_path: decodeURIComponent( img ),
|
|
382
|
+
// };
|
|
383
|
+
// image.push( await signedUrl( inputData ) );
|
|
384
|
+
// }
|
|
385
|
+
// question.questionReferenceImage = image;
|
|
386
|
+
// }
|
|
387
|
+
// }
|
|
388
|
+
// question.answers.forEach( async ( answer ) => {
|
|
389
|
+
// if ( answer.referenceImage.length > 0 ) {
|
|
390
|
+
// let updatedImages = [];
|
|
391
|
+
// for ( let refImage of answer.referenceImage ) {
|
|
392
|
+
// let inputData = {
|
|
393
|
+
// Bucket: bucket.sop,
|
|
394
|
+
// file_path: decodeURIComponent( refImage ),
|
|
395
|
+
// };
|
|
396
|
+
// updatedImages.push( await signedUrl( inputData ) );
|
|
397
|
+
// }
|
|
398
|
+
// answer.referenceImage = updatedImages;
|
|
399
|
+
// }
|
|
400
|
+
// } );
|
|
401
|
+
// } );
|
|
399
402
|
sections.push( {
|
|
400
403
|
id: item._id,
|
|
401
404
|
name: item.section,
|
|
@@ -4834,7 +4837,7 @@ export async function commonAiTask( req, res ) {
|
|
|
4834
4837
|
locationCount: 1,
|
|
4835
4838
|
...( inputBody?.checkListId ) ? { referenceCheckListId: inputBody?.checkListId } : {},
|
|
4836
4839
|
coverage: 'store',
|
|
4837
|
-
checkListFrom: '
|
|
4840
|
+
checkListFrom: '',
|
|
4838
4841
|
};
|
|
4839
4842
|
data['approver'] = userAdmin;
|
|
4840
4843
|
let answer = await findAnswer( inputBody?.answerType );
|
|
@@ -6075,3 +6078,344 @@ async function insertEyetestSingleProcessedTask( checkTask, inputBody, date, tim
|
|
|
6075
6078
|
return false;
|
|
6076
6079
|
}
|
|
6077
6080
|
}
|
|
6081
|
+
|
|
6082
|
+
export async function createTaskGroup( req, res ) {
|
|
6083
|
+
try {
|
|
6084
|
+
let inputBody = req.body;
|
|
6085
|
+
|
|
6086
|
+
// inputBody.clientId = 11;
|
|
6087
|
+
inputBody.taskDescription = '';
|
|
6088
|
+
let userId;
|
|
6089
|
+
let storeData = await storeService.findOne( { storeName: inputBody.storeName, clientId: inputBody.clientId, status: 'active' }, { storeId: 1, storeName: 1, storeProfile: 1, spocDetails: 1 } );
|
|
6090
|
+
if ( !storeData ) {
|
|
6091
|
+
return res.sendError( 'Store Not Found', 500 );
|
|
6092
|
+
}
|
|
6093
|
+
|
|
6094
|
+
// let url = JSON.parse( process.env.LAMBDAURL );
|
|
6095
|
+
// let dailychecklistId = new mongoose.Types.ObjectId( url.dailystoreChecklistId );
|
|
6096
|
+
// let KSAchecklistId = new mongoose.Types.ObjectId( url.KSAchecklist );
|
|
6097
|
+
// let UAEchecklistId = new mongoose.Types.ObjectId( url.UAEchecklist );
|
|
6098
|
+
// let singaporechecklistId = new mongoose.Types.ObjectId( url.singaporechecklist );
|
|
6099
|
+
// let finduser = await checklistassignconfigModel.findOne( { checkListId: { $in: [ dailychecklistId, KSAchecklistId, UAEchecklistId, singaporechecklistId ] }, store_id: storeData.storeId } );
|
|
6100
|
+
let finduser;
|
|
6101
|
+
if ( inputBody.userEmail ) {
|
|
6102
|
+
let userFind = [
|
|
6103
|
+
{
|
|
6104
|
+
$match: {
|
|
6105
|
+
email: inputBody.userEmail,
|
|
6106
|
+
clientId: inputBody.clientId,
|
|
6107
|
+
},
|
|
6108
|
+
},
|
|
6109
|
+
{
|
|
6110
|
+
$project: {
|
|
6111
|
+
_id: 0,
|
|
6112
|
+
userId: '$_id',
|
|
6113
|
+
userName: 1,
|
|
6114
|
+
userEmail: '$email',
|
|
6115
|
+
},
|
|
6116
|
+
},
|
|
6117
|
+
];
|
|
6118
|
+
let finduserData = await userService.aggregate( userFind );
|
|
6119
|
+
// console.log( 'finduserData =>', finduserData );
|
|
6120
|
+
if ( finduserData && finduserData.length > 0 ) {
|
|
6121
|
+
finduser = finduserData[0];
|
|
6122
|
+
} else {
|
|
6123
|
+
// Create User//
|
|
6124
|
+
let params = {
|
|
6125
|
+
userName: inputBody.userEmail.split( '@' )[0],
|
|
6126
|
+
email: inputBody.userEmail,
|
|
6127
|
+
mobileNumber: inputBody?.mobileNumber || '0000000000',
|
|
6128
|
+
clientId: inputBody.clientId,
|
|
6129
|
+
role: 'user',
|
|
6130
|
+
password: '5dqFKAJj29PsV6P+kL+3Dw==',
|
|
6131
|
+
isActive: true,
|
|
6132
|
+
userType: 'client',
|
|
6133
|
+
rolespermission: [
|
|
6134
|
+
{
|
|
6135
|
+
featureName: 'Global',
|
|
6136
|
+
modules: [
|
|
6137
|
+
{
|
|
6138
|
+
name: 'Store',
|
|
6139
|
+
isAdd: false,
|
|
6140
|
+
isEdit: false,
|
|
6141
|
+
|
|
6142
|
+
},
|
|
6143
|
+
{
|
|
6144
|
+
name: 'User',
|
|
6145
|
+
isAdd: false,
|
|
6146
|
+
isEdit: false,
|
|
6147
|
+
|
|
6148
|
+
},
|
|
6149
|
+
{
|
|
6150
|
+
name: 'Camera',
|
|
6151
|
+
isAdd: false,
|
|
6152
|
+
isEdit: false,
|
|
6153
|
+
|
|
6154
|
+
},
|
|
6155
|
+
{
|
|
6156
|
+
name: 'Configuration',
|
|
6157
|
+
isAdd: false,
|
|
6158
|
+
isEdit: false,
|
|
6159
|
+
|
|
6160
|
+
},
|
|
6161
|
+
{
|
|
6162
|
+
name: 'Subscription',
|
|
6163
|
+
isAdd: false,
|
|
6164
|
+
isEdit: false,
|
|
6165
|
+
|
|
6166
|
+
},
|
|
6167
|
+
{
|
|
6168
|
+
name: 'Billing',
|
|
6169
|
+
isAdd: false,
|
|
6170
|
+
isEdit: false,
|
|
6171
|
+
|
|
6172
|
+
},
|
|
6173
|
+
],
|
|
6174
|
+
},
|
|
6175
|
+
{
|
|
6176
|
+
featurName: 'TangoEye',
|
|
6177
|
+
modules: [
|
|
6178
|
+
{
|
|
6179
|
+
name: 'ZoneTag',
|
|
6180
|
+
isAdd: false,
|
|
6181
|
+
isEdit: false,
|
|
6182
|
+
|
|
6183
|
+
},
|
|
6184
|
+
],
|
|
6185
|
+
},
|
|
6186
|
+
{
|
|
6187
|
+
featurName: 'TangoTrax',
|
|
6188
|
+
modules: [
|
|
6189
|
+
{
|
|
6190
|
+
name: 'checklist',
|
|
6191
|
+
isAdd: false,
|
|
6192
|
+
isEdit: false,
|
|
6193
|
+
|
|
6194
|
+
},
|
|
6195
|
+
{
|
|
6196
|
+
name: 'Task',
|
|
6197
|
+
isAdd: false,
|
|
6198
|
+
isEdit: false,
|
|
6199
|
+
|
|
6200
|
+
},
|
|
6201
|
+
],
|
|
6202
|
+
},
|
|
6203
|
+
],
|
|
6204
|
+
};
|
|
6205
|
+
let response = await userService.create( params );
|
|
6206
|
+
if ( response ) {
|
|
6207
|
+
finduser = [ { userId: response._id, userName: response.userName, userEmail: response.email } ];
|
|
6208
|
+
}
|
|
6209
|
+
}
|
|
6210
|
+
} else {
|
|
6211
|
+
// get Store Spoc
|
|
6212
|
+
finduser = [ { userId: storeData.spocDetails[0]._id, userName: storeData.spocDetails[0].name, userEmail: storeData.spocDetails[0].email } ];
|
|
6213
|
+
}
|
|
6214
|
+
|
|
6215
|
+
// return finduser;
|
|
6216
|
+
// console.log( 'finduser =>', finduser );
|
|
6217
|
+
if ( !finduser ) {
|
|
6218
|
+
return res.sendError( 'No user Found For this store', 500 );
|
|
6219
|
+
}
|
|
6220
|
+
|
|
6221
|
+
userId = finduser.userId;
|
|
6222
|
+
inputBody.userName = finduser.userName;
|
|
6223
|
+
inputBody.userEmail = finduser.userEmail;
|
|
6224
|
+
let teamList = await findteams( { users: { $elemMatch: { email: finduser.userEmail } } } );
|
|
6225
|
+
|
|
6226
|
+
inputBody.approver = '';
|
|
6227
|
+
for ( let team of teamList ) {
|
|
6228
|
+
for ( let user of team.Teamlead ) {
|
|
6229
|
+
inputBody.approver = user.email + ',' + inputBody.approver;
|
|
6230
|
+
}
|
|
6231
|
+
}
|
|
6232
|
+
inputBody.approver = inputBody.approver.replace( /,$/, '' );
|
|
6233
|
+
let title = `New Task Alert ${inputBody.taskName}-${storeData.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
|
|
6234
|
+
let time = inputBody?.scheduleEndTime || '11:59 PM';
|
|
6235
|
+
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
6236
|
+
let description = `A new task has been assigned to ${storeData.storeName}. Please complete it before the due date of ${date}.`;
|
|
6237
|
+
let userDetails = await userService.findOne( { _id: new mongoose.Types.ObjectId( finduser.userId ) } );
|
|
6238
|
+
if ( userDetails && userDetails.fcmToken ) {
|
|
6239
|
+
const fcmToken = userDetails.fcmToken;
|
|
6240
|
+
await sendPushNotification( title, description, fcmToken );
|
|
6241
|
+
}
|
|
6242
|
+
const inputDateTime = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' );
|
|
6243
|
+
const currentTime = dayjs.utc();
|
|
6244
|
+
if ( inputDateTime.isBefore( currentTime ) ) {
|
|
6245
|
+
return res.sendError( 'The input date-time is before the current time.', 500 );
|
|
6246
|
+
}
|
|
6247
|
+
|
|
6248
|
+
let creatorData = await userService.findOne( { clientId: inputBody.clientId, role: 'superadmin', userType: 'client', isActive: true } );
|
|
6249
|
+
if ( !creatorData ) {
|
|
6250
|
+
return res.sendError( 'Invalid Creator Details', 500 );
|
|
6251
|
+
}
|
|
6252
|
+
let creator = [ { _id: creatorData._id, userName: creatorData.userName, userEmail: creatorData.email } ];
|
|
6253
|
+
|
|
6254
|
+
let approverList = inputBody?.approver.split( ',' );
|
|
6255
|
+
let userAdmin = await userService.find( { clientId: inputBody.clientId, email: { $in: approverList }, userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
|
|
6256
|
+
if ( userAdmin && userAdmin.length === 0 ) {
|
|
6257
|
+
userAdmin = creator;
|
|
6258
|
+
}
|
|
6259
|
+
|
|
6260
|
+
if ( req.body && req.body.referenceImage && req.body.referenceImage.length > 3 ) {
|
|
6261
|
+
return res.sendError( 'Maximum 3 referenceImage only allowed', 500 );
|
|
6262
|
+
}
|
|
6263
|
+
|
|
6264
|
+
let answer = await findAnswer( inputBody?.answerType );
|
|
6265
|
+
if ( answer.length == 0 ) {
|
|
6266
|
+
return res.sendError( 'please enter Valid AnswerType', 500 );
|
|
6267
|
+
}
|
|
6268
|
+
|
|
6269
|
+
// Check this Task Already Exist////
|
|
6270
|
+
let checkTask = await taskService.findOne( { checkListName: inputBody.taskName } );
|
|
6271
|
+
if ( checkTask ) {
|
|
6272
|
+
let singleInsert = await insertStoreHygienetaskSingleProcessedTask( checkTask, inputBody, date, time, storeData, finduser, answer );
|
|
6273
|
+
if ( singleInsert ) {
|
|
6274
|
+
return res.sendSuccess( 'Task created successfully' );
|
|
6275
|
+
} else {
|
|
6276
|
+
return res.sendError( 'something went wrong, please try again', 500 );
|
|
6277
|
+
}
|
|
6278
|
+
} else {
|
|
6279
|
+
let data = {
|
|
6280
|
+
// checkListName: `${inputBody.taskName}(${storeData.storeName}-${dayjs().format( 'YYYY-MM-DD' )}-${inputBody.zoneName ? inputBody.zoneName : ''})`,
|
|
6281
|
+
checkListName: inputBody.taskName,
|
|
6282
|
+
checkListDescription: inputBody.taskDescription,
|
|
6283
|
+
createdBy: creator[0]._id,
|
|
6284
|
+
createdByName: creator[0].userName,
|
|
6285
|
+
publish: true,
|
|
6286
|
+
questionCount: 1,
|
|
6287
|
+
storeCount: 1,
|
|
6288
|
+
scheduleDate: date,
|
|
6289
|
+
scheduleEndTime: time,
|
|
6290
|
+
scheduleEndTimeISO: dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' ).format(),
|
|
6291
|
+
priorityType: 'high',
|
|
6292
|
+
client_id: inputBody.clientId,
|
|
6293
|
+
checkListType: 'task',
|
|
6294
|
+
publishDate: new Date(),
|
|
6295
|
+
locationCount: 1,
|
|
6296
|
+
...( inputBody?.checkListId ) ? { referenceCheckListId: inputBody?.checkListId } : {},
|
|
6297
|
+
coverage: 'store',
|
|
6298
|
+
checkListFrom: 'api',
|
|
6299
|
+
zoneName: inputBody.zoneName || '',
|
|
6300
|
+
checkListType: 'task',
|
|
6301
|
+
};
|
|
6302
|
+
data['approver'] = userAdmin;
|
|
6303
|
+
|
|
6304
|
+
if ( inputBody?.answerType === 'multiplechoicesingle' || inputBody?.answerType === 'multiplechoicemultiple' ) {
|
|
6305
|
+
if ( inputBody?.options && inputBody?.options.length > 0 ) {
|
|
6306
|
+
let optionsResult = [];
|
|
6307
|
+
let optionList = inputBody?.options.split( ',' );
|
|
6308
|
+
for ( let option of optionList ) {
|
|
6309
|
+
let optiondata = {
|
|
6310
|
+
'answer': '',
|
|
6311
|
+
'sopFlag': false,
|
|
6312
|
+
'validation': false,
|
|
6313
|
+
'validationType': '',
|
|
6314
|
+
'referenceImage': [],
|
|
6315
|
+
'runAI': false,
|
|
6316
|
+
'allowUploadfromGallery': false,
|
|
6317
|
+
'descriptivetype': '',
|
|
6318
|
+
'showLinked': false,
|
|
6319
|
+
'linkedQuestion': 0,
|
|
6320
|
+
'nestedQuestion': [],
|
|
6321
|
+
};
|
|
6322
|
+
optiondata.answer = option;
|
|
6323
|
+
optionsResult.push( optiondata );
|
|
6324
|
+
}
|
|
6325
|
+
answer = optionsResult;
|
|
6326
|
+
} else {
|
|
6327
|
+
return res.sendError( 'please enter Valid Options', 500 );
|
|
6328
|
+
}
|
|
6329
|
+
}
|
|
6330
|
+
|
|
6331
|
+
let response = await taskService.create( data );
|
|
6332
|
+
if ( response?.approver.length ) {
|
|
6333
|
+
let inputData = [];
|
|
6334
|
+
response?.approver.forEach( ( ele ) => {
|
|
6335
|
+
inputData.push( {
|
|
6336
|
+
userEmail: ele.email,
|
|
6337
|
+
checkListId: response._id,
|
|
6338
|
+
type: 'task',
|
|
6339
|
+
client_id: inputBody.clientId,
|
|
6340
|
+
checkListName: data?.checkListName || '',
|
|
6341
|
+
} );
|
|
6342
|
+
} );
|
|
6343
|
+
await traxApprover.insertMany( inputData );
|
|
6344
|
+
}
|
|
6345
|
+
|
|
6346
|
+
if ( response?._id ) {
|
|
6347
|
+
let question = [
|
|
6348
|
+
{
|
|
6349
|
+
'qno': 1,
|
|
6350
|
+
'qname': inputBody.question,
|
|
6351
|
+
'answerType': inputBody?.answerType || 'yes/no',
|
|
6352
|
+
'runAI': false,
|
|
6353
|
+
'runAIDescription': '',
|
|
6354
|
+
'allowUploadfromGallery': false,
|
|
6355
|
+
'linkType': false,
|
|
6356
|
+
'questionReferenceImage': [],
|
|
6357
|
+
'answers': answer,
|
|
6358
|
+
'descriptivetype': 'text',
|
|
6359
|
+
},
|
|
6360
|
+
];
|
|
6361
|
+
|
|
6362
|
+
let images = [];
|
|
6363
|
+
for ( let imgpath of req.body.referenceImage ) {
|
|
6364
|
+
let configURL = JSON.parse( process.env.BUCKET );
|
|
6365
|
+
let inputData = {
|
|
6366
|
+
Bucket: configURL.aiTraxoutput,
|
|
6367
|
+
Key: imgpath,
|
|
6368
|
+
};
|
|
6369
|
+
let output = await getObject( inputData );
|
|
6370
|
+
let image = {
|
|
6371
|
+
data: output.Body,
|
|
6372
|
+
name: imgpath,
|
|
6373
|
+
mimetype: output.ContentType,
|
|
6374
|
+
};
|
|
6375
|
+
let uplaodedImage = await uploadmultiImage( image );
|
|
6376
|
+
let imgUrl = decodeURIComponent( uplaodedImage?.imgUrl.split( '?' )[0] );
|
|
6377
|
+
let url = imgUrl.split( '/' );
|
|
6378
|
+
if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
|
|
6379
|
+
url.splice( 0, 3 );
|
|
6380
|
+
}
|
|
6381
|
+
images.push( url.join( '/' ) );
|
|
6382
|
+
}
|
|
6383
|
+
question[0].questionReferenceImage = images;
|
|
6384
|
+
|
|
6385
|
+
if ( inputBody?.answerType === 'image' || inputBody?.answerType === 'descriptiveImage' || inputBody?.answerType === 'multipleImage' ) {
|
|
6386
|
+
answer[0].referenceImage = question[0].questionReferenceImage;
|
|
6387
|
+
}
|
|
6388
|
+
|
|
6389
|
+
question = {
|
|
6390
|
+
checkListId: response?._id,
|
|
6391
|
+
question: question,
|
|
6392
|
+
section: 'Section 1',
|
|
6393
|
+
checkList: data.checkListName,
|
|
6394
|
+
client_id: inputBody.clientId,
|
|
6395
|
+
};
|
|
6396
|
+
await taskQuestionService.create( question );
|
|
6397
|
+
|
|
6398
|
+
let userDetails = {
|
|
6399
|
+
userName: inputBody.userName,
|
|
6400
|
+
userEmail: inputBody.userEmail,
|
|
6401
|
+
store_id: storeData.storeId,
|
|
6402
|
+
storeName: storeData.storeName,
|
|
6403
|
+
city: storeData?.storeProfile?.city,
|
|
6404
|
+
checkFlag: true,
|
|
6405
|
+
checkListId: response?._id,
|
|
6406
|
+
checkListName: data.checkListName,
|
|
6407
|
+
client_id: inputBody.clientId,
|
|
6408
|
+
userId: userId,
|
|
6409
|
+
assignId: storeData?._id,
|
|
6410
|
+
};
|
|
6411
|
+
await taskAssignService.create( userDetails );
|
|
6412
|
+
await insertSingleProcessData( response?._id );
|
|
6413
|
+
return res.sendSuccess( 'Task created successfully' );
|
|
6414
|
+
}
|
|
6415
|
+
}
|
|
6416
|
+
} catch ( e ) {
|
|
6417
|
+
console.log( 'e =>', e );
|
|
6418
|
+
logger.error( { function: 'createTaskGroup', error: e } );
|
|
6419
|
+
return res.sendError( e, 500 );
|
|
6420
|
+
}
|
|
6421
|
+
}
|
package/src/dtos/task.dto.js
CHANGED
|
@@ -82,3 +82,24 @@ export const StoreHygienetaskvalidation = {
|
|
|
82
82
|
export const eyeTesttaskvalidation = {
|
|
83
83
|
body: eyeTesttaskSchema,
|
|
84
84
|
};
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
export const createTaskGroupSchema = Joi.object().keys( {
|
|
88
|
+
storeName: Joi.string().required(),
|
|
89
|
+
taskName: Joi.string().required(),
|
|
90
|
+
question: Joi.string().required(),
|
|
91
|
+
answerType: Joi.string().required(),
|
|
92
|
+
clientId: Joi.string().required(),
|
|
93
|
+
options: Joi.string().optional().allow( '' ),
|
|
94
|
+
scheduleDate: Joi.string().optional().allow( '' ),
|
|
95
|
+
scheduleEndTime: Joi.string().optional().allow( '' ),
|
|
96
|
+
referenceImage: Joi.array().optional().allow( '' ),
|
|
97
|
+
zoneName: Joi.string().optional().allow( '' ),
|
|
98
|
+
userEmail: Joi.string().optional().allow( '' ),
|
|
99
|
+
mobileNumber: Joi.string().optional().allow( '' ),
|
|
100
|
+
approverList: Joi.array().optional().allow( '' ),
|
|
101
|
+
} );
|
|
102
|
+
|
|
103
|
+
export const createTaskGroupvalidation = {
|
|
104
|
+
body: createTaskGroupSchema,
|
|
105
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as taskController from '../controllers/task.controller.js';
|
|
3
3
|
import { isAllowedSessionHandler, validate, accessVerification, isAllowedClient, isAllowedInternalAPIHandler, getAssinedStore } from 'tango-app-api-middleware';
|
|
4
4
|
import express from 'express';
|
|
5
|
-
import { aitaskvalidation, StoreHygienetaskvalidation, eyeTesttaskvalidation, commonAiTaskvalidation, taskcreationvalidation, gettaskvalidation } from '../dtos/task.dto.js';
|
|
5
|
+
import { aitaskvalidation, StoreHygienetaskvalidation, eyeTesttaskvalidation, commonAiTaskvalidation, taskcreationvalidation, gettaskvalidation, createTaskGroupvalidation } from '../dtos/task.dto.js';
|
|
6
6
|
export const taskRouter = express.Router();
|
|
7
7
|
|
|
8
8
|
taskRouter
|
|
@@ -42,6 +42,7 @@ taskRouter
|
|
|
42
42
|
.post( '/taskcreation', isAllowedInternalAPIHandler, validate( taskcreationvalidation ), taskController.taskcreation )
|
|
43
43
|
.get( '/getTask', isAllowedInternalAPIHandler, validate( gettaskvalidation ), taskController.getTask )
|
|
44
44
|
.post( '/breached-tasks', isAllowedInternalAPIHandler, validate( taskcreationvalidation ), taskController.breachedTasks )
|
|
45
|
-
.get( '/getcoustemer', taskController.customertrial )
|
|
45
|
+
.get( '/getcoustemer', taskController.customertrial )
|
|
46
|
+
.post( '/createTaskGroup', isAllowedInternalAPIHandler, validate( createTaskGroupvalidation ), taskController.createTaskGroup );
|
|
46
47
|
|
|
47
48
|
|