tango-app-api-trax 3.4.1-alpha-19 → 3.4.1-alpha-0
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 +3 -3
- package/src/controllers/download.controller.js +117 -3
- package/src/controllers/internalTrax.controller.js +114 -6
- package/src/controllers/mobileTrax.controller.js +30 -931
- package/src/controllers/teaxFlag.controller.js +467 -2
- package/src/controllers/trax.controller.js +294 -155
- package/src/controllers/traxDashboard.controllers.js +1 -2
- package/src/dtos/downloadValidation.dtos.js +1 -1
- package/src/routes/download.router.js +4 -0
- package/src/routes/internalTraxApi.router.js +3 -1
- package/src/routes/mobileTrax.routes.js +0 -3
- package/src/routes/trax.routes.js +5 -3
- package/src/routes/traxFlag.router.js +13 -1
- package/src/services/processedchecklistconfig.services.js +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fileUpload, chunkArray, logger, sendPushNotification } from 'tango-app-api-middleware';
|
|
1
|
+
import { signedUrl, fileUpload, chunkArray, logger, sendPushNotification, sendTeamsNotification } from 'tango-app-api-middleware';
|
|
2
2
|
import * as checklistService from '../services/checklist.service.js';
|
|
3
3
|
import * as questionService from '../services/checklistQuestion.service.js';
|
|
4
4
|
import * as assignedService from '../services/checklistAssign.service.js';
|
|
@@ -247,15 +247,14 @@ export const create = async ( req, res ) => {
|
|
|
247
247
|
section.questions[qIdx].answers[index].nestedQuestion = [];
|
|
248
248
|
}
|
|
249
249
|
if ( answer.showLinked ) {
|
|
250
|
-
// section.questions[qIdx].answers[nestedIndex].nestedQuestion.push( answer.linkedQuestion );
|
|
251
250
|
if ( nestedIndex != -1 ) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
251
|
+
if ( !section.questions[qIdx].answers[nestedIndex].nestedQuestion.includes( answer.linkedQuestion ) ) {
|
|
252
|
+
section.questions[qIdx].answers[nestedIndex].nestedQuestion.push( answer.linkedQuestion );
|
|
253
|
+
}
|
|
255
254
|
} else {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
255
|
+
if ( !section.questions[qIdx].answers[index].nestedQuestion.includes( answer.linkedQuestion ) ) {
|
|
256
|
+
section.questions[qIdx].answers[index].nestedQuestion.push( answer.linkedQuestion );
|
|
257
|
+
}
|
|
259
258
|
}
|
|
260
259
|
let nestedLinkedQuestion = section.questions.find( ( item ) => item.qno == answer.linkedQuestion );
|
|
261
260
|
if ( nestedLinkedQuestion ) {
|
|
@@ -272,18 +271,6 @@ export const create = async ( req, res ) => {
|
|
|
272
271
|
}
|
|
273
272
|
}
|
|
274
273
|
}
|
|
275
|
-
let checkNestedLevel = false;
|
|
276
|
-
section.questions.forEach( ( qns ) => {
|
|
277
|
-
qns.answers.forEach( ( answ ) => {
|
|
278
|
-
if ( answ.nestedQuestion.length > 20 ) {
|
|
279
|
-
checkNestedLevel = true;
|
|
280
|
-
}
|
|
281
|
-
} );
|
|
282
|
-
} );
|
|
283
|
-
|
|
284
|
-
if ( checkNestedLevel ) {
|
|
285
|
-
return res.sendError( { message: 'Unable to create more than 20 linked questions.' }, 400 );
|
|
286
|
-
}
|
|
287
274
|
|
|
288
275
|
let sectionList = {
|
|
289
276
|
section: section.name,
|
|
@@ -296,10 +283,15 @@ export const create = async ( req, res ) => {
|
|
|
296
283
|
};
|
|
297
284
|
await questionService.create( sectionList ).then( async ( data ) => {
|
|
298
285
|
if ( i == inputBody.sections.length - 1 ) {
|
|
286
|
+
let actionType = 'created';
|
|
287
|
+
let teamsMsg;
|
|
288
|
+
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
289
|
+
actionType = 'Create';
|
|
290
|
+
teamsMsg = 'ClientId: '+ req.body.clientId + ', Action: '+ actionType + ', ChecklistId: '+ checkListId + ', Checklist Name: '+ inputBody.checklistName + ', UpDatedBy: '+ req.user.email;
|
|
291
|
+
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
299
292
|
return res.sendSuccess( { checklistId: checkListId, msg: 'CheckList Created Successfully' } );
|
|
300
293
|
}
|
|
301
294
|
} ).catch( ( e ) => {
|
|
302
|
-
console.log( e );
|
|
303
295
|
return res.sendError( e, 500 );
|
|
304
296
|
} );
|
|
305
297
|
}
|
|
@@ -309,7 +301,6 @@ export const create = async ( req, res ) => {
|
|
|
309
301
|
}
|
|
310
302
|
}
|
|
311
303
|
} ).catch( async ( e ) => {
|
|
312
|
-
console.log( e );
|
|
313
304
|
await checklistService.deleteOne( { _id: checkListId } );
|
|
314
305
|
return res.sendError( e, 500 );
|
|
315
306
|
} );
|
|
@@ -373,23 +364,23 @@ export const getConfigDetails = async ( req, res ) => {
|
|
|
373
364
|
let questionDetails = await questionService.find( query );
|
|
374
365
|
if ( questionDetails.length ) {
|
|
375
366
|
let sections = [];
|
|
376
|
-
|
|
367
|
+
let bucket = JSON.parse( process.env.BUCKET );
|
|
377
368
|
questionDetails.forEach( ( item ) => {
|
|
378
369
|
item.question.forEach( async ( question ) => {
|
|
379
370
|
if ( question.questionReferenceImage && question.questionReferenceImage !='' ) {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
question.questionReferenceImage =
|
|
371
|
+
let inputData = {
|
|
372
|
+
Bucket: bucket.sop,
|
|
373
|
+
file_path: decodeURIComponent( question.questionReferenceImage ),
|
|
374
|
+
};
|
|
375
|
+
question.questionReferenceImage = await signedUrl( inputData );
|
|
385
376
|
}
|
|
386
377
|
question.answers.forEach( async ( answer ) => {
|
|
387
378
|
if ( answer.referenceImage != '' ) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
answer.referenceImage =
|
|
379
|
+
let inputData = {
|
|
380
|
+
Bucket: bucket.sop,
|
|
381
|
+
file_path: decodeURIComponent( answer.referenceImage ),
|
|
382
|
+
};
|
|
383
|
+
answer.referenceImage = await signedUrl( inputData );
|
|
393
384
|
}
|
|
394
385
|
} );
|
|
395
386
|
} );
|
|
@@ -621,6 +612,11 @@ export const deleteChecklist = async ( req, res ) => {
|
|
|
621
612
|
await processedchecklist.deleteMany( { date_string: { $ne: date }, date_iso: { $gt: date }, sourceCheckList_id: req.params.checklistId, checklistStatus: { $ne: 'submit' } } );
|
|
622
613
|
logger.info( { function: 'deleteChecklist', query: { date_string: { $ne: date }, date_iso: { $gt: date }, sourceCheckList_id: req.params.checklistId, checklistStatus: { $ne: 'submit' } } } );
|
|
623
614
|
checklistDetails.save().then( () => {
|
|
615
|
+
let actionType = 'Deleted';
|
|
616
|
+
let teamsMsg;
|
|
617
|
+
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
618
|
+
teamsMsg = 'ClientId: '+ checklistDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ req.params.checklistId + ', Checklist Name: '+ checklistDetails.checkListName + ', UpDatedBy: '+ req.user.email;
|
|
619
|
+
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
624
620
|
return res.sendSuccess( { message: 'Checklist Deleted Successfully' } );
|
|
625
621
|
} ).catch( ( e ) => {
|
|
626
622
|
return res.sendError( e, 500 );
|
|
@@ -694,6 +690,11 @@ export const duplicateChecklist = async ( req, res ) => {
|
|
|
694
690
|
sections.push( sectionDetails );
|
|
695
691
|
}
|
|
696
692
|
await questionService.insertMany( sections );
|
|
693
|
+
let actionType = 'Duplicated';
|
|
694
|
+
let teamsMsg;
|
|
695
|
+
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
696
|
+
teamsMsg = 'ClientId: '+ checkDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ data._id + ', Checklist Name: '+ checkDetails.checkListName + ', UpDatedBy: '+ req.user.email;
|
|
697
|
+
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
697
698
|
return res.sendSuccess( { message: 'CheckList Duplicated Successfully' } );
|
|
698
699
|
} else {
|
|
699
700
|
return res.sendSuccess( { message: 'duplicated Successfully' } );
|
|
@@ -792,13 +793,13 @@ export const update = async ( req, res ) => {
|
|
|
792
793
|
}
|
|
793
794
|
if ( answer.showLinked ) {
|
|
794
795
|
if ( nestedIndex != -1 ) {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
796
|
+
if ( !section.questions[qIdx].answers[nestedIndex].nestedQuestion.includes( answer.linkedQuestion ) ) {
|
|
797
|
+
section.questions[qIdx].answers[nestedIndex].nestedQuestion.push( answer.linkedQuestion );
|
|
798
|
+
}
|
|
798
799
|
} else {
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
800
|
+
if ( !section.questions[qIdx].answers[index].nestedQuestion.includes( answer.linkedQuestion ) ) {
|
|
801
|
+
section.questions[qIdx].answers[index].nestedQuestion.push( answer.linkedQuestion );
|
|
802
|
+
}
|
|
802
803
|
}
|
|
803
804
|
let nestedLinkedQuestion = section.questions.find( ( item ) => item.qno == answer.linkedQuestion );
|
|
804
805
|
if ( nestedLinkedQuestion ) {
|
|
@@ -816,21 +817,6 @@ export const update = async ( req, res ) => {
|
|
|
816
817
|
}
|
|
817
818
|
}
|
|
818
819
|
|
|
819
|
-
let checkNestedLevel = false;
|
|
820
|
-
section.questions.forEach( ( qns ) => {
|
|
821
|
-
qns.answers.forEach( ( answ ) => {
|
|
822
|
-
if ( answ.nestedQuestion.length > 20 ) {
|
|
823
|
-
checkNestedLevel = true;
|
|
824
|
-
}
|
|
825
|
-
} );
|
|
826
|
-
} );
|
|
827
|
-
|
|
828
|
-
console.log( checkNestedLevel, 'lebej' );
|
|
829
|
-
|
|
830
|
-
if ( checkNestedLevel ) {
|
|
831
|
-
return res.sendError( { message: 'Unable to create more than 20 linked questions' }, 400 );
|
|
832
|
-
}
|
|
833
|
-
|
|
834
820
|
let sectionList = {
|
|
835
821
|
section: section.name,
|
|
836
822
|
sectionOldName: section.oldName,
|
|
@@ -844,6 +830,11 @@ export const update = async ( req, res ) => {
|
|
|
844
830
|
await questionService.create( sectionList ).then( async ( data ) => {
|
|
845
831
|
sectionId.push( data._id );
|
|
846
832
|
if ( i == inputBody.sections.length - 1 ) {
|
|
833
|
+
let actionType = 'Checklist Updated';
|
|
834
|
+
let teamsMsg;
|
|
835
|
+
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
836
|
+
teamsMsg = 'ClientId: '+ req.body.clientId + ', Action: '+ actionType + ', ChecklistId: '+ checkListId + ', Checklist Name: '+ inputBody.checklistName + ', UpDatedBy: '+ req.user.email;
|
|
837
|
+
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
847
838
|
await questionService.deleteMany( { checkListId: checkListId, client_id: req.body.clientId, _id: { $nin: sectionId } } );
|
|
848
839
|
await assignedService.updateMany( { checkListId: checkListId }, { checkListName: inputBody.checklistName } );
|
|
849
840
|
return res.sendSuccess( { checklistId: checkListId, msg: 'CheckList Created Successfully' } );
|
|
@@ -889,11 +880,11 @@ export const uploadImage = async ( req, res ) => {
|
|
|
889
880
|
};
|
|
890
881
|
imgUrl = await fileUpload( params );
|
|
891
882
|
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
imgUrl =
|
|
883
|
+
let inputData = {
|
|
884
|
+
Bucket: bucket.sop,
|
|
885
|
+
file_path: imgUrl.Key,
|
|
886
|
+
};
|
|
887
|
+
imgUrl = await signedUrl( inputData );
|
|
897
888
|
if ( !imgUrl ) {
|
|
898
889
|
return res.sendError( { message: 'Something went Wrong' }, 500 );
|
|
899
890
|
}
|
|
@@ -1499,8 +1490,9 @@ export const updateConfigurev1 =async ( req, res ) => {
|
|
|
1499
1490
|
if ( inputBody.timeZone ) {
|
|
1500
1491
|
currentDate = dayjs().tz( inputBody.timeZone ).format();
|
|
1501
1492
|
} else {
|
|
1502
|
-
currentDate = dayjs().format();
|
|
1493
|
+
currentDate = dayjs().format( 'HH:mm:ss' );
|
|
1503
1494
|
}
|
|
1495
|
+
currentDate = dayjs.utc( currentDate, 'HH:mm:ss' ).format();
|
|
1504
1496
|
let updatedscheduleEndTimeISO = dayjs.utc( inputBody?.checkListDetails?.scheduleEndTime, 'hh:mm A' ).format( 'HH:mm:ss' );
|
|
1505
1497
|
let newUpdatedDate = dayjs.utc( updatedscheduleEndTimeISO, 'HH:mm:ss' ).format();
|
|
1506
1498
|
|
|
@@ -1643,6 +1635,12 @@ export const updateConfigurev1 =async ( req, res ) => {
|
|
|
1643
1635
|
futureDaysDataRemove( currentDate, req.params.checklistId, checklistDetails.checkListName, '333' );
|
|
1644
1636
|
}
|
|
1645
1637
|
}
|
|
1638
|
+
let actionType;
|
|
1639
|
+
let teamsMsg;
|
|
1640
|
+
actionType = inputBody.checkListDetails.publish ? 'configPublish' : 'configDraft';
|
|
1641
|
+
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
1642
|
+
teamsMsg = 'ClientId: '+ checklistDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ checklistDetails._id + ', Checklist Name: '+ checklistDetails.checkListName + ', UpDatedBy: '+ req.user.email;
|
|
1643
|
+
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
1646
1644
|
if ( response?.modifiedCount || response?.matchedCount || response?.upsertedCount ) {
|
|
1647
1645
|
return res.sendSuccess( { id, message: 'Configured Updated Successfully' } );
|
|
1648
1646
|
}
|
|
@@ -1799,6 +1797,12 @@ export const updatePublish = async ( req, res ) => {
|
|
|
1799
1797
|
createdByEmail: req.user.email,
|
|
1800
1798
|
};
|
|
1801
1799
|
await checklistLogs.create( logInsertData );
|
|
1800
|
+
let actionType;
|
|
1801
|
+
let teamsMsg;
|
|
1802
|
+
actionType = req.body.publish ? 'publish' : 'unpublish';
|
|
1803
|
+
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
1804
|
+
teamsMsg = 'ClientId: '+ getCheckDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ getCheckDetails._id + ', Checklist Name: '+ getCheckDetails.checkListName + ', UpDatedBy: '+ req.user.email;
|
|
1805
|
+
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
1802
1806
|
return res.sendSuccess( { checklistName: getCheckDetails.checkListName, message: 'Updated Successfully' } );
|
|
1803
1807
|
} catch ( e ) {
|
|
1804
1808
|
logger.error( 'updatePublish erroe =>', e );
|
|
@@ -2070,7 +2074,7 @@ export const validateUserv1 = async ( req, res ) => {
|
|
|
2070
2074
|
{
|
|
2071
2075
|
$project: {
|
|
2072
2076
|
newEmail: { $toLower: '$email' },
|
|
2073
|
-
isActive: 1,
|
|
2077
|
+
// isActive: 1,
|
|
2074
2078
|
clientId: 1,
|
|
2075
2079
|
email: 1,
|
|
2076
2080
|
},
|
|
@@ -2078,7 +2082,7 @@ export const validateUserv1 = async ( req, res ) => {
|
|
|
2078
2082
|
{
|
|
2079
2083
|
$match: {
|
|
2080
2084
|
newEmail: { $in: userEmailList },
|
|
2081
|
-
isActive: true,
|
|
2085
|
+
// isActive: true,
|
|
2082
2086
|
clientId: { $ne: req.body.clientId },
|
|
2083
2087
|
},
|
|
2084
2088
|
},
|
|
@@ -2120,7 +2124,7 @@ export const validateUserv1 = async ( req, res ) => {
|
|
|
2120
2124
|
let newStoreList = storeList.filter( ( ele ) => ele != null && !existsStore.includes( ele.toLowerCase() ) );
|
|
2121
2125
|
if ( req.body.coverage == 'store' ) {
|
|
2122
2126
|
assignDetails.forEach( ( item ) => {
|
|
2123
|
-
let getStoreDetails = storeDetails.find( ( store ) => store.storeName.toLowerCase() == item.storeName.toLowerCase() );
|
|
2127
|
+
let getStoreDetails = storeDetails.find( ( store ) => store.storeName.trim().toLowerCase() == item.storeName.trim().toLowerCase() );
|
|
2124
2128
|
if ( getStoreDetails ) {
|
|
2125
2129
|
let storeUserDetails = userDetails.find( ( ele ) => ele.newEmail.toLowerCase() == item.userEmail.toLowerCase() );
|
|
2126
2130
|
item._id = getStoreDetails._id;
|
|
@@ -2141,6 +2145,10 @@ export const validateUserv1 = async ( req, res ) => {
|
|
|
2141
2145
|
} );
|
|
2142
2146
|
}
|
|
2143
2147
|
|
|
2148
|
+
newStoreList = [ ...new Set( newStoreList.map( ( item ) => item ) ) ];
|
|
2149
|
+
newUserList = [ ...new Set( newUserList.map( ( item ) => item ) ) ];
|
|
2150
|
+
existEmail = [ ...new Set( existEmail.map( ( item ) => item ) ) ];
|
|
2151
|
+
inActiveStores = [ ...new Set( inActiveStores.map( ( item ) => item ) ) ];
|
|
2144
2152
|
if ( ( newUserList.length || newStoreList.length || existEmail.length || inActiveStores.length ) && !req.body?.addUser ) {
|
|
2145
2153
|
return res.sendError( { validate: false, user: newUserList, store: newStoreList, existEmail, inActiveStores, data: assignDetails }, 400 );
|
|
2146
2154
|
}
|
|
@@ -2586,6 +2594,7 @@ export async function insertSingleProcessData( checklistId, processId = 0, oldDa
|
|
|
2586
2594
|
insertdata.restrictAttendance = getCLconfig?.restrictAttendance;
|
|
2587
2595
|
insertdata.coverage = getCLconfig?.coverage;
|
|
2588
2596
|
insertdata.rawImageUpload = getCLconfig?.rawImageUpload || false;
|
|
2597
|
+
insertdata.rawVideoUpload = getCLconfig?.rawVideoUpload || false;
|
|
2589
2598
|
|
|
2590
2599
|
let collectSections = [];
|
|
2591
2600
|
let sectionQuery = [];
|
|
@@ -3175,6 +3184,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3175
3184
|
}
|
|
3176
3185
|
if ( getsubmitDetails ) {
|
|
3177
3186
|
getsubmitDetails = [ getsubmitDetails ];
|
|
3187
|
+
console.log( submittedDetails, getsubmitDetails );
|
|
3178
3188
|
}
|
|
3179
3189
|
function findDifferences( obj1, obj2 ) {
|
|
3180
3190
|
return Object.keys( obj1 ).reduce( ( diff, key ) => {
|
|
@@ -3210,7 +3220,6 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3210
3220
|
delete data.parentanswer;
|
|
3211
3221
|
delete data.remarks;
|
|
3212
3222
|
delete data.linkquestionenabled;
|
|
3213
|
-
delete data.uniqueNo;
|
|
3214
3223
|
if ( data.descriptivetype == null ) {
|
|
3215
3224
|
delete data.descriptivetype;
|
|
3216
3225
|
}
|
|
@@ -3222,101 +3231,29 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3222
3231
|
delete ans.index;
|
|
3223
3232
|
delete ans.validationAnswer;
|
|
3224
3233
|
delete ans.answeroptionNumber;
|
|
3225
|
-
ans.nestedQuestion = ans?.oldNestedQuestion ? ans.oldNestedQuestion : ans.nestedQuestion;
|
|
3226
|
-
ans.linkedQuestion = ans?.oldLinkedQuestion ? ans.oldLinkedQuestion : ans.linkedQuestion;
|
|
3227
|
-
delete ans.oldNestedQuestion;
|
|
3228
|
-
delete ans.oldLinkedQuestion;
|
|
3229
3234
|
} );
|
|
3230
3235
|
const compare = findDifferences( data, qns );
|
|
3231
3236
|
if ( compare?.answerType || compare?.answers || compare?.linkType ) {
|
|
3232
3237
|
logger.info( 'compare =>', compare );
|
|
3233
|
-
logger.info( 'compareSection =>', { section: section.sectionName } );
|
|
3234
|
-
logger.info( 'qno =>', { qno: data.qno } );
|
|
3235
3238
|
modifiedCount++;
|
|
3236
|
-
question.push(
|
|
3239
|
+
question.push( qns );
|
|
3237
3240
|
} else {
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
}
|
|
3241
|
-
// getsubmitDetails[0].questionAnswers[index].questions[findQuestion].qname = qns.qname;
|
|
3241
|
+
getsubmitDetails[0].questionAnswers[index].questions[findQuestion].qname = qns.qname;
|
|
3242
|
+
question.push( getsubmitDetails[0].questionAnswers[index].questions[findQuestion] );
|
|
3242
3243
|
}
|
|
3243
3244
|
} else {
|
|
3244
3245
|
modifiedCount++;
|
|
3245
|
-
question.push(
|
|
3246
|
+
question.push( qns );
|
|
3246
3247
|
}
|
|
3247
3248
|
} );
|
|
3248
|
-
|
|
3249
|
-
sectionList.push(
|
|
3249
|
+
getsubmitDetails[0].questionAnswers[index].questions = question;
|
|
3250
|
+
sectionList.push( getsubmitDetails[0].questionAnswers[index] );
|
|
3250
3251
|
} else {
|
|
3251
3252
|
modifiedCount++;
|
|
3252
|
-
sectionList.push(
|
|
3253
|
+
sectionList.push( section );
|
|
3253
3254
|
}
|
|
3254
3255
|
}
|
|
3255
|
-
|
|
3256
|
-
sectionList.forEach( ( sec ) => {
|
|
3257
|
-
if ( sec.type == 'add' ) {
|
|
3258
|
-
getsubmitDetails[0].questionAnswers.push( sec );
|
|
3259
|
-
} else {
|
|
3260
|
-
sec.question.forEach( ( qn ) => {
|
|
3261
|
-
let sectionDetails = getsubmitDetails[0].questionAnswers.findIndex( ( section ) => section.sectionName == sec?.oldName || section.sectionName == sec.sectionName );
|
|
3262
|
-
if ( qn.type == 'add' ) {
|
|
3263
|
-
getsubmitDetails[0].questionAnswers[sectionDetails].questions.push( qn.question );
|
|
3264
|
-
} else {
|
|
3265
|
-
let questions = getsubmitDetails[0].questionAnswers[sectionDetails].questions.reduce( ( acc, ele, idx ) => {
|
|
3266
|
-
if ( ele.qname.trim() == qn?.question?.oldQname?.trim() || ele.qname.trim() == qn.question.qname.trim() ) {
|
|
3267
|
-
acc.push( idx );
|
|
3268
|
-
}
|
|
3269
|
-
return acc;
|
|
3270
|
-
}, [] );
|
|
3271
|
-
if ( questions.length && [ 'qnEdit', 'nameChange' ].includes( qn.type ) ) {
|
|
3272
|
-
if ( qn.type == 'qnEdit' ) {
|
|
3273
|
-
let checkLinkType = getsubmitDetails[0].questionAnswers[sectionDetails].questions[questions[0]].linkType;
|
|
3274
|
-
if ( checkLinkType && !qn.question.linkType ) {
|
|
3275
|
-
questions.forEach( ( qnIdx, index ) => {
|
|
3276
|
-
if ( index != 0 ) {
|
|
3277
|
-
getsubmitDetails[0].questionAnswers[sectionDetails].questions.splice( qnIdx, 1 );
|
|
3278
|
-
}
|
|
3279
|
-
} );
|
|
3280
|
-
questions = [ questions[0] ];
|
|
3281
|
-
}
|
|
3282
|
-
}
|
|
3283
|
-
questions.forEach( ( qnIdx ) => {
|
|
3284
|
-
if ( qn.type == 'qnEdit' ) {
|
|
3285
|
-
getsubmitDetails[0].questionAnswers[sectionDetails].questions[qnIdx].answers.forEach( ( ele ) => {
|
|
3286
|
-
console.log( ele?.nestedQuestion );
|
|
3287
|
-
if ( ele?.nestedQuestion.length ) {
|
|
3288
|
-
ele?.nestedQuestion.forEach( ( nested ) => {
|
|
3289
|
-
let findIndex = getsubmitDetails[0].questionAnswers[sectionDetails].questions.findIndex( ( qn ) => qn.uniqueNo == nested );
|
|
3290
|
-
if ( findIndex != -1 ) {
|
|
3291
|
-
delete getsubmitDetails[0].questionAnswers[sectionDetails].questions[findIndex].userAnswer;
|
|
3292
|
-
let questionDetails = getsubmitDetails[0].questionAnswers[sectionDetails].questions[findIndex];
|
|
3293
|
-
let checkQuestionExists = getsubmitDetails[0].questionAnswers[sectionDetails].questions.filter( ( qnDetails ) => qnDetails.qname == questionDetails.qname );
|
|
3294
|
-
if ( checkQuestionExists.length > 1 ) {
|
|
3295
|
-
getsubmitDetails[0].questionAnswers[sectionDetails].questions.splice( findIndex, 1 );
|
|
3296
|
-
} else {
|
|
3297
|
-
delete getsubmitDetails[0].questionAnswers[sectionDetails].questions[findIndex].uniqueNo;
|
|
3298
|
-
getsubmitDetails[0].questionAnswers[sectionDetails].questions[findIndex].linkquestionenabled = false;
|
|
3299
|
-
getsubmitDetails[0].questionAnswers[sectionDetails].questions[findIndex].answers.forEach( ( ele ) => {
|
|
3300
|
-
if ( ele?.oldNestedQuestion?.length ) {
|
|
3301
|
-
ele.nestedQuestion = ele.oldNestedQuestion;
|
|
3302
|
-
ele.linkedQuestion = ele.oldLinkedQuestion;
|
|
3303
|
-
}
|
|
3304
|
-
} );
|
|
3305
|
-
}
|
|
3306
|
-
}
|
|
3307
|
-
} );
|
|
3308
|
-
}
|
|
3309
|
-
} );
|
|
3310
|
-
getsubmitDetails[0].questionAnswers[sectionDetails].questions[qnIdx] = qn.question;
|
|
3311
|
-
} else {
|
|
3312
|
-
getsubmitDetails[0].questionAnswers[sectionDetails].questions[qnIdx].qname = qn.question.qname;
|
|
3313
|
-
}
|
|
3314
|
-
} );
|
|
3315
|
-
}
|
|
3316
|
-
}
|
|
3317
|
-
} );
|
|
3318
|
-
}
|
|
3319
|
-
} );
|
|
3256
|
+
getsubmitDetails[0].questionAnswers = sectionList;
|
|
3320
3257
|
if ( modifiedCount ) {
|
|
3321
3258
|
getsubmitDetails[0].checklistStatus = 'inprogress';
|
|
3322
3259
|
getsubmitDetails[0].date_string = dayjs( currentdate ).format( 'YYYY-MM-DD' );
|
|
@@ -3370,6 +3307,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3370
3307
|
element4.restrictAttendance = getCLconfig?.restrictAttendance;
|
|
3371
3308
|
element4.coverage = getCLconfig?.coverage;
|
|
3372
3309
|
element4.rawImageUpload = getCLconfig?.rawImageUpload || false;
|
|
3310
|
+
element4.rawVideoUpload = getCLconfig?.rawVideoUpload || false;
|
|
3373
3311
|
assignUserList.push( { ...element4 } );
|
|
3374
3312
|
}
|
|
3375
3313
|
} ) );
|
|
@@ -3527,11 +3465,11 @@ async function updateOpenSearch( user, data ) {
|
|
|
3527
3465
|
export const aiChecklist = async ( req, res ) => {
|
|
3528
3466
|
try {
|
|
3529
3467
|
let storeDetails = await storeService.count( { clientId: req.query.clientId, status: 'active' } );
|
|
3530
|
-
let aiList = [ 'mobileusagedetection', 'storeopenandclose', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum' ];
|
|
3468
|
+
let aiList = [ 'mobileusagedetection', 'storeopenandclose', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection' ];
|
|
3531
3469
|
let checklistDetails = [];
|
|
3532
3470
|
let publishList = [];
|
|
3533
3471
|
let unpublishList = [];
|
|
3534
|
-
publishList = await checklistService.find( { client_id: req.query.clientId, checkListType: { $in: aiList } }, { publish: 1, checkListName: 1, checkListType: 1, client_id: 1, checkListDescription: 1 } );
|
|
3472
|
+
publishList = await checklistService.find( { client_id: req.query.clientId, checkListType: { $in: aiList } }, { publish: 1, checkListName: 1, checkListType: 1, client_id: 1, checkListDescription: 1, storeCount: 1 } );
|
|
3535
3473
|
if ( publishList.length ) {
|
|
3536
3474
|
let existList = publishList.map( ( item ) => item.checkListType );
|
|
3537
3475
|
aiList = aiList.filter( ( item ) => !existList.includes( item ) );
|
|
@@ -3540,7 +3478,9 @@ export const aiChecklist = async ( req, res ) => {
|
|
|
3540
3478
|
checklistDetails = [ ...publishList, ...unpublishList ];
|
|
3541
3479
|
|
|
3542
3480
|
checklistDetails.forEach( ( item ) => {
|
|
3543
|
-
item.
|
|
3481
|
+
if ( ![ 'mobileusagedetection', 'storeopenandclose', 'cleaning', 'scrum' ].includes( item.checkListType ) ) {
|
|
3482
|
+
item.storeCount = storeDetails;
|
|
3483
|
+
}
|
|
3544
3484
|
} );
|
|
3545
3485
|
|
|
3546
3486
|
return res.sendSuccess( checklistDetails );
|
|
@@ -3724,12 +3664,7 @@ export const selectAssign = async ( req, res ) => {
|
|
|
3724
3664
|
// //Select Store and cluster
|
|
3725
3665
|
if ( requestData.assignType == 'store' ) {
|
|
3726
3666
|
let storeQuery = [
|
|
3727
|
-
{
|
|
3728
|
-
$match: {
|
|
3729
|
-
...( req.user.userType==='client'&&req.user.role!='superadmin' ) ? { storeId: { $in: requestData?.assignedStores } } :{ clientId: requestData.clientId },
|
|
3730
|
-
status: 'active',
|
|
3731
|
-
},
|
|
3732
|
-
},
|
|
3667
|
+
{ $match: { clientId: requestData.clientId, status: 'active' } },
|
|
3733
3668
|
{
|
|
3734
3669
|
$project: {
|
|
3735
3670
|
storeName: 1,
|
|
@@ -3739,6 +3674,8 @@ export const selectAssign = async ( req, res ) => {
|
|
|
3739
3674
|
userEmail: { $arrayElemAt: [ '$spocDetails.email', 0 ] },
|
|
3740
3675
|
contact: { $arrayElemAt: [ '$spocDetails.contact', 0 ] },
|
|
3741
3676
|
city: '$storeProfile.city',
|
|
3677
|
+
openTime: '$storeProfile.open',
|
|
3678
|
+
closeTime: '$storeProfile.close',
|
|
3742
3679
|
},
|
|
3743
3680
|
},
|
|
3744
3681
|
|
|
@@ -3912,7 +3849,8 @@ export async function updateAssign( req, res ) {
|
|
|
3912
3849
|
},
|
|
3913
3850
|
];
|
|
3914
3851
|
let assignUserDetails = await userService.aggregate( query );
|
|
3915
|
-
|
|
3852
|
+
for ( let assign of req.body.assignedList ) {
|
|
3853
|
+
// await Promise.all( req.body.assignedList.map( async ( assign ) => {
|
|
3916
3854
|
let userDetails = assignUserDetails.find( ( ele ) => ele.email.toLowerCase() == assign.userEmail.toLowerCase() );
|
|
3917
3855
|
if ( !userDetails ) {
|
|
3918
3856
|
let userData = {
|
|
@@ -3926,6 +3864,7 @@ export async function updateAssign( req, res ) {
|
|
|
3926
3864
|
}
|
|
3927
3865
|
let data = {
|
|
3928
3866
|
...assign,
|
|
3867
|
+
userEmail: userDetails?.email,
|
|
3929
3868
|
store_id: assign?.storeId,
|
|
3930
3869
|
client_id: req.body.clientId,
|
|
3931
3870
|
checkListId: req.body.checkListId,
|
|
@@ -3936,7 +3875,8 @@ export async function updateAssign( req, res ) {
|
|
|
3936
3875
|
};
|
|
3937
3876
|
delete data._id;
|
|
3938
3877
|
assignedUserList.push( data );
|
|
3939
|
-
} ) );
|
|
3878
|
+
// } ) );
|
|
3879
|
+
}
|
|
3940
3880
|
let assignGroupDetails = [];
|
|
3941
3881
|
if ( req.body.coverage == 'store' ) {
|
|
3942
3882
|
assignGroupDetails = await clusterServices.findcluster( { _id: { $in: req.body.assignedGroup } } );
|
|
@@ -3964,3 +3904,202 @@ export async function updateAssign( req, res ) {
|
|
|
3964
3904
|
return res.sendError( e, 500 );
|
|
3965
3905
|
}
|
|
3966
3906
|
}
|
|
3907
|
+
|
|
3908
|
+
export async function updateAiConfigure( req, res ) {
|
|
3909
|
+
try {
|
|
3910
|
+
if ( !req.body.storeList.length && req.body.publish ) {
|
|
3911
|
+
return res.sendError( 'Please assign a store', 400 );
|
|
3912
|
+
}
|
|
3913
|
+
if ( !req.body.id && !req.body.type ) {
|
|
3914
|
+
return res.sendError( 'Type/Id is required', 400 );
|
|
3915
|
+
}
|
|
3916
|
+
if ( req.body.aiConfig?.assignConfig && req.body.aiConfig?.assignConfig == 'global' && !req.body?.aiConfig?.events?.length ) {
|
|
3917
|
+
return res.sendError( 'Event is required', 400 );
|
|
3918
|
+
}
|
|
3919
|
+
let query;
|
|
3920
|
+
query = req.body.type ? { checkListType: req.body.type, client_id: { $exists: false } } : { _id: req.body.id, client_id: req.body.clientId };
|
|
3921
|
+
let aiChecklistDetails = await checklistService.findOne( query );
|
|
3922
|
+
if ( !aiChecklistDetails ) {
|
|
3923
|
+
return res.sendError( 'No data found', 204 );
|
|
3924
|
+
}
|
|
3925
|
+
let details = {
|
|
3926
|
+
checkListName: aiChecklistDetails.checkListName,
|
|
3927
|
+
checkListDescription: aiChecklistDetails.checkListDescription,
|
|
3928
|
+
client_id: req.body.clientId,
|
|
3929
|
+
publish: req.body.publish,
|
|
3930
|
+
aiConfig: req.body.aiConfig,
|
|
3931
|
+
createdBy: req.user._id,
|
|
3932
|
+
createdByName: req.user.userName,
|
|
3933
|
+
questionCount: 0,
|
|
3934
|
+
storeCount: req.body.storeList.length,
|
|
3935
|
+
type: 'checklist',
|
|
3936
|
+
checkListType: aiChecklistDetails.checkListType,
|
|
3937
|
+
schedule: 'daily',
|
|
3938
|
+
...( req.body.publish ) ? { publishDate: new Date() } :{},
|
|
3939
|
+
approver: req.body?.approver || [],
|
|
3940
|
+
scheduleRepeatedDay: [ '01' ],
|
|
3941
|
+
scheduleStartTime: '06:00 AM',
|
|
3942
|
+
scheduleEndTime: '11:59 PM',
|
|
3943
|
+
enableNewDeployedStore: req.body.enableNewDeployedStore,
|
|
3944
|
+
checkListNumber: aiChecklistDetails?.checkListNumber || 1,
|
|
3945
|
+
};
|
|
3946
|
+
let aiResponse = await checklistService.updateOne( { checkListType: aiChecklistDetails.checkListType, client_id: req.body.clientId }, details );
|
|
3947
|
+
let checklistId = req.body?.id || aiResponse?.upsertedId;
|
|
3948
|
+
if ( req.body.storeList ) {
|
|
3949
|
+
let storeData = [];
|
|
3950
|
+
req.body.storeList.forEach( ( ele ) => {
|
|
3951
|
+
let eventTime = [];
|
|
3952
|
+
Object.keys( ele ).forEach( ( key ) => {
|
|
3953
|
+
let keyValue ={};
|
|
3954
|
+
if ( req.body.aiConfig?.assignConfig && req.body.aiConfig?.assignConfig == 'store' && key.includes( 'startTime' ) ) {
|
|
3955
|
+
let num = key.slice( -1 );
|
|
3956
|
+
if ( ele[key] && ele[`configTime${num}`] ) {
|
|
3957
|
+
keyValue['time'] = ele[key];
|
|
3958
|
+
keyValue['duration'] = ele[`configTime${num}`];
|
|
3959
|
+
eventTime.push( keyValue );
|
|
3960
|
+
}
|
|
3961
|
+
}
|
|
3962
|
+
} );
|
|
3963
|
+
if ( req.body.aiConfig?.assignConfig && req.body.aiConfig?.assignConfig == 'global' ) {
|
|
3964
|
+
req.body.aiConfig.events.forEach( ( event ) => {
|
|
3965
|
+
if ( event.time.split( ':' ).length <= 2 ) {
|
|
3966
|
+
event.time = event.time + ':00';
|
|
3967
|
+
}
|
|
3968
|
+
} );
|
|
3969
|
+
eventTime = req.body.aiConfig.events;
|
|
3970
|
+
}
|
|
3971
|
+
storeData.push( {
|
|
3972
|
+
storeName: ele.storeName,
|
|
3973
|
+
...( req.body.aiConfig?.assignConfig ) ? { events: eventTime } : { events: [] },
|
|
3974
|
+
checkListId: checklistId,
|
|
3975
|
+
client_id: req.body.clientId,
|
|
3976
|
+
checkListName: aiChecklistDetails.checkListName,
|
|
3977
|
+
store_id: ele.storeId,
|
|
3978
|
+
assignId: ele._id,
|
|
3979
|
+
} );
|
|
3980
|
+
} );
|
|
3981
|
+
await assignedService.deleteMany( { checkListId: checklistId } );
|
|
3982
|
+
await assignedService.insertMany( storeData );
|
|
3983
|
+
if ( req.body.publish ) {
|
|
3984
|
+
let processedData = {
|
|
3985
|
+
client_id: req.body.clientId,
|
|
3986
|
+
date_iso: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
|
|
3987
|
+
date_string: dayjs().format( 'YYYY-MM-DD' ),
|
|
3988
|
+
sourceCheckList_id: checklistId,
|
|
3989
|
+
checkListName: aiChecklistDetails.checkListName,
|
|
3990
|
+
checkListDescription: aiChecklistDetails.checkListDescription,
|
|
3991
|
+
scheduleStartTime: '06:00 AM',
|
|
3992
|
+
scheduleEndTime: '11:59 PM',
|
|
3993
|
+
scheduleStartTime_iso: dayjs.utc( '06:00 AM', 'hh:mm A' ).format(),
|
|
3994
|
+
scheduleEndTime_iso: dayjs.utc( '11:59 PM', 'hh:mm A' ).format(),
|
|
3995
|
+
allowedOverTime: false,
|
|
3996
|
+
allowedStoreLocation: false,
|
|
3997
|
+
createdBy: req.user._id,
|
|
3998
|
+
createdByName: req.user.userName,
|
|
3999
|
+
questionAnswers: [],
|
|
4000
|
+
isdeleted: false,
|
|
4001
|
+
questionCount: 0,
|
|
4002
|
+
storeCount: req.body.storeList.length,
|
|
4003
|
+
publishDate: details?.publishDate,
|
|
4004
|
+
locationCount: 1,
|
|
4005
|
+
checkListType: aiChecklistDetails.checkListType,
|
|
4006
|
+
scheduleRepeatedType: 'daily',
|
|
4007
|
+
aiStoreList: storeData.length? storeData.map( ( store ) => {
|
|
4008
|
+
return { storeName: store.storeName, events: store.events, storeId: store.store_id };
|
|
4009
|
+
} ) : [],
|
|
4010
|
+
aiConfig: req.body.aiConfig,
|
|
4011
|
+
approver: req.body?.approver || [],
|
|
4012
|
+
};
|
|
4013
|
+
let configResponse = await processedchecklistConfig.updateOne( { date_string: dayjs().format( 'YYYY-MM-DD' ), sourceCheckList_id: checklistId, checkListType: aiChecklistDetails.checkListType }, processedData );
|
|
4014
|
+
let data = {
|
|
4015
|
+
...( configResponse?.upsertedId ) ? { checkListId: configResponse?.upsertedId } : {},
|
|
4016
|
+
checkListName: aiChecklistDetails.checkListName,
|
|
4017
|
+
checkListDescription: aiChecklistDetails.checkListDescription,
|
|
4018
|
+
date_iso: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
|
|
4019
|
+
date_string: dayjs().format( 'YYYY-MM-DD' ),
|
|
4020
|
+
allowedOverTime: false,
|
|
4021
|
+
allowedStoreLocation: false,
|
|
4022
|
+
scheduleStartTime: '06:00 AM',
|
|
4023
|
+
scheduleStartTime_iso: dayjs.utc( '06:00 AM', 'hh:mm A' ).format(),
|
|
4024
|
+
scheduleEndTime: '11:59 PM',
|
|
4025
|
+
scheduleEndTime_iso: dayjs.utc( '11:59 PM', 'hh:mm A' ).format(),
|
|
4026
|
+
createdBy: req.user._id,
|
|
4027
|
+
createdByName: req.user.userName,
|
|
4028
|
+
sourceCheckList_id: checklistId,
|
|
4029
|
+
checkListType: aiChecklistDetails.checkListType,
|
|
4030
|
+
storeCount: storeData.length,
|
|
4031
|
+
questionCount: 0,
|
|
4032
|
+
publishDate: new Date(),
|
|
4033
|
+
locationCount: 0,
|
|
4034
|
+
scheduleRepeatedType: 'daily',
|
|
4035
|
+
client_id: req.body.clientId,
|
|
4036
|
+
aiStoreList: storeData?.length ? storeData.map( ( store ) => store.store_id ) : [],
|
|
4037
|
+
};
|
|
4038
|
+
await processedchecklist.updateOne( { date_string: dayjs().format( 'YYYY-MM-DD' ), sourceCheckList_id: checklistId, checkListType: aiChecklistDetails.checkListType }, data );
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
4041
|
+
return res.sendSuccess( 'Checklist updated successfully' );
|
|
4042
|
+
} catch ( e ) {
|
|
4043
|
+
logger.error( { functionName: 'updateAiConfigure', error: e } );
|
|
4044
|
+
return res.sendError( e, 500 );
|
|
4045
|
+
}
|
|
4046
|
+
}
|
|
4047
|
+
|
|
4048
|
+
|
|
4049
|
+
export async function getAiDetails( req, res ) {
|
|
4050
|
+
try {
|
|
4051
|
+
let storeList = [];
|
|
4052
|
+
if ( !req.query.id && !req.query.type ) {
|
|
4053
|
+
return res.sendError( 'Type/Id is required', 400 );
|
|
4054
|
+
}
|
|
4055
|
+
let query = req.query.type ? { checkListType: req.query.type, client_id: { $exists: false } } : { _id: req.query.id, client_id: req.query.clientId };
|
|
4056
|
+
let checklistDetails = await checklistService.findOne( query );
|
|
4057
|
+
if ( !checklistDetails ) {
|
|
4058
|
+
return res.sendError( 'No data found', 204 );
|
|
4059
|
+
}
|
|
4060
|
+
let clientDetails = await clientService.findOne( { clientId: req.query.clientId }, { 'planDetails.product': 1 } );
|
|
4061
|
+
if ( !clientDetails ) {
|
|
4062
|
+
return res.sendError( 'No data found', 204 );
|
|
4063
|
+
}
|
|
4064
|
+
if ( req.query?.id ) {
|
|
4065
|
+
storeList = await assignedService.find( { checkListId: req.query?.id } );
|
|
4066
|
+
let data = [];
|
|
4067
|
+
await Promise.all( ( storeList.map( async ( ele ) => {
|
|
4068
|
+
let element = {};
|
|
4069
|
+
element['storeName'] = ele.storeName,
|
|
4070
|
+
element['storeId'] = ele.store_id;
|
|
4071
|
+
element['_id'] = ele.assignId;
|
|
4072
|
+
let getStoreDetails = await storeService.findOne( { storeId: ele.store_id, status: 'active', clientId: req.query.clientId } );
|
|
4073
|
+
if ( getStoreDetails ) {
|
|
4074
|
+
element['openTime'] = getStoreDetails?.storeProfile?.open;
|
|
4075
|
+
element['closeTime'] = getStoreDetails?.storeProfile?.close;
|
|
4076
|
+
}
|
|
4077
|
+
if ( [ 'cleaning', 'scrum' ].includes( checklistDetails.checkListType ) && checklistDetails?.aiConfig?.assignConfig == 'store' ) {
|
|
4078
|
+
ele.events.forEach( ( event, index ) => {
|
|
4079
|
+
element[`startTime${index+1}`] = event.time;
|
|
4080
|
+
element[`configTime${index+1}`] = event.duration;
|
|
4081
|
+
} );
|
|
4082
|
+
}
|
|
4083
|
+
data.push( element );
|
|
4084
|
+
} ) ) );
|
|
4085
|
+
storeList = data;
|
|
4086
|
+
}
|
|
4087
|
+
|
|
4088
|
+
let response = {
|
|
4089
|
+
checkListName: checklistDetails?.checkListName,
|
|
4090
|
+
checkListDescription: checklistDetails?.checkListDescription,
|
|
4091
|
+
publish: checklistDetails?.publish,
|
|
4092
|
+
aiConfig: checklistDetails?.aiConfig,
|
|
4093
|
+
storeList: storeList,
|
|
4094
|
+
approver: checklistDetails?.approver,
|
|
4095
|
+
storeCount: checklistDetails?.storeCount,
|
|
4096
|
+
...( checklistDetails?.client_id ) ? { clientId: checklistDetails?.client_id } :{},
|
|
4097
|
+
enableNewDeployedStore: checklistDetails?.enableNewDeployedStore,
|
|
4098
|
+
product: clientDetails?.planDetails?.product.map( ( product ) => product.productName ),
|
|
4099
|
+
};
|
|
4100
|
+
return res.sendSuccess( response );
|
|
4101
|
+
} catch ( e ) {
|
|
4102
|
+
logger.error( { functionName: getAiDetails, error: e } );
|
|
4103
|
+
return res.sendError( e, 500 );
|
|
4104
|
+
}
|
|
4105
|
+
}
|