tango-app-api-trax 3.3.1-beta-7 → 3.3.1-beta-9
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-trax",
|
|
3
|
-
"version": "3.3.1-beta-
|
|
3
|
+
"version": "3.3.1-beta-9",
|
|
4
4
|
"description": "Trax",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"mongodb": "^6.8.0",
|
|
27
27
|
"nodemon": "^3.1.4",
|
|
28
28
|
"path": "^0.12.7",
|
|
29
|
-
"tango-api-schema": "^2.2.
|
|
29
|
+
"tango-api-schema": "^2.2.41",
|
|
30
30
|
"tango-app-api-middleware": "^3.1.50",
|
|
31
31
|
"url": "^0.11.4",
|
|
32
32
|
"winston": "^3.13.1",
|
|
@@ -354,14 +354,14 @@ export async function redoChecklist( req, res ) {
|
|
|
354
354
|
return res.sendError( 'section is not found', 400 );
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
-
let findQuestion = question[sectionIndex].questions.findIndex( ( ele ) => ele.qno == req.body.payload.qno );
|
|
357
|
+
let findQuestion = question[sectionIndex].questions.findIndex( ( ele ) => ele?.parentQuestion ? ele.qno == req.body.payload.qno && ele.parentQuestion == req.body.payload.parentQuestion : ele.qno == req.body.payload.qno );
|
|
358
358
|
|
|
359
359
|
let data = { ...question[sectionIndex].questions[findQuestion], redo: true, redoComment: req.body.payload?.checklistDescription || '' };
|
|
360
360
|
// if ( checklistDetails.client_id == '458' ) {
|
|
361
361
|
data.answers.forEach( ( item ) => {
|
|
362
362
|
if ( item.showLinked ) {
|
|
363
363
|
item.nestedQuestion.forEach( ( ele ) => {
|
|
364
|
-
let eleIndex = question[sectionIndex].questions.findIndex( ( qn ) => qn.qno == parseInt( ele ) );
|
|
364
|
+
let eleIndex = question[sectionIndex].questions.findIndex( ( qn ) => qn?.parentQuestion ? qn.qno == parseInt( ele ) && qn?.parentQuestion == req.body.payload?.parentQuestion : qn.qno == parseInt( ele ) );
|
|
365
365
|
let element = { ...question[sectionIndex].questions[eleIndex], redo: true, redoComment: '', linkquestionenabled: false };
|
|
366
366
|
question[sectionIndex].questions[eleIndex] = element;
|
|
367
367
|
question[sectionIndex].questions[eleIndex].userAnswer = [];
|
|
@@ -149,7 +149,7 @@ export async function startChecklist( req, res ) {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
let updateData = {};
|
|
152
|
-
let storeTimeZone = await storeService.findOne( { storeName: getBeforeChecklist[0].storeName }, { 'storeProfile.timeZone': 1 } );
|
|
152
|
+
let storeTimeZone = await storeService.findOne( { storeName: { $regex: getBeforeChecklist[0].storeName, $options: 'i' }, clientId: getBeforeChecklist[0].client_id }, { 'storeProfile.timeZone': 1 } );
|
|
153
153
|
let currentDateTime;
|
|
154
154
|
if ( storeTimeZone?.storeProfile?.timeZone ) {
|
|
155
155
|
currentDateTime = dayjs().tz( storeTimeZone?.storeProfile?.timeZone );
|
|
@@ -244,6 +244,7 @@ export async function startChecklist( req, res ) {
|
|
|
244
244
|
questions = [];
|
|
245
245
|
for ( let question of section.questions ) {
|
|
246
246
|
if ( !question.linkType ) {
|
|
247
|
+
question.parentQuestion = question.qno;
|
|
247
248
|
questions.push( question );
|
|
248
249
|
let linkedAnswer = new Set( question.answers.filter( ( ele ) => ele.showLinked ).flatMap( ( ele ) => ele.nestedQuestion ) );
|
|
249
250
|
let linkedQuestion = section.questions.filter( ( qn ) => linkedAnswer.has( qn.qno ) );
|
|
@@ -984,7 +985,6 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
984
985
|
if ( requestData?.editSubmit && requestData?.editSubmit == 'true' ) {
|
|
985
986
|
let sampleData = reqAnswers[0];
|
|
986
987
|
CLQAnswers.forEach( ( section ) => {
|
|
987
|
-
console.log( section, 'section' );
|
|
988
988
|
let requestSection = reqAnswers.filter( ( reqSection ) => reqSection.sectionName == section?.sectionOldName || reqSection.sectionName == section?.sectionName );
|
|
989
989
|
if ( requestSection.length ) {
|
|
990
990
|
requestSection.forEach( ( item ) => item.section_id = section.section_id );
|
|
@@ -995,6 +995,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
995
995
|
data.answerType = question.answerType;
|
|
996
996
|
data.qno = question.qno;
|
|
997
997
|
data.qname = question.qname;
|
|
998
|
+
data.oldQname = question?.oldQname || question.qname;
|
|
998
999
|
data.answer = 'null';
|
|
999
1000
|
data.remarks = '';
|
|
1000
1001
|
data.validationAnswer = '';
|
|
@@ -1016,6 +1017,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1016
1017
|
data.answerType = ele.answerType;
|
|
1017
1018
|
data.qno = ele.qno;
|
|
1018
1019
|
data.qname = ele.qname;
|
|
1020
|
+
data.oldQname = ele?.oldQname || ele.qname;
|
|
1019
1021
|
data.answer = 'null';
|
|
1020
1022
|
data.remarks = '';
|
|
1021
1023
|
data.validationAnswer = '';
|
|
@@ -1049,7 +1051,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1049
1051
|
let requestSection = reqAnswers.filter( ( item ) => item.section_id == section.id );
|
|
1050
1052
|
for ( let i = 0; i < requestSection.length; i++ ) {
|
|
1051
1053
|
for ( let j = 0; j < qaAnswers.length; j++ ) {
|
|
1052
|
-
if ( requestSection[i].qname == qaAnswers[j].oldQname || requestSection[i].qname == qaAnswers[j].qname ) {
|
|
1054
|
+
if ( ( requestSection[i].qname == qaAnswers[j].oldQname || requestSection[i].qname == qaAnswers[j].qname ) && ( !qaAnswers[j]?.parentQuestion || ( qaAnswers[j]?.parentQuestion && requestSection[i]?.parentQuestion == qaAnswers[j]?.parentQuestion ) ) ) {
|
|
1053
1055
|
if ( qaAnswers[j].answerType == 'yes/no' ) {
|
|
1054
1056
|
let qaans = qaAnswers[j].answers;
|
|
1055
1057
|
let yn = [];
|
|
@@ -1089,13 +1091,14 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1089
1091
|
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
|
|
1090
1092
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1091
1093
|
structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1094
|
+
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1092
1095
|
if ( qaAnswers[j]?.taskId ) {
|
|
1093
1096
|
structure.taskId = qaAnswers[j]?.taskId;
|
|
1094
1097
|
structure.task = true;
|
|
1095
1098
|
}
|
|
1096
1099
|
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1097
1100
|
structure.redo = false;
|
|
1098
|
-
} else if ( requestData.submittype === 'draft' ) {
|
|
1101
|
+
} else if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'draft' ) {
|
|
1099
1102
|
structure.redo = qaAnswers[j]?.redo;
|
|
1100
1103
|
}
|
|
1101
1104
|
if ( qaAnswers[j]?.redoComment ) {
|
|
@@ -1141,13 +1144,14 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1141
1144
|
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
|
|
1142
1145
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1143
1146
|
structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1147
|
+
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1144
1148
|
if ( qaAnswers[j]?.taskId ) {
|
|
1145
1149
|
structure.taskId = qaAnswers[j]?.taskId;
|
|
1146
1150
|
structure.task = true;
|
|
1147
1151
|
}
|
|
1148
1152
|
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1149
1153
|
structure.redo = false;
|
|
1150
|
-
} else if ( requestData.submittype === 'draft' ) {
|
|
1154
|
+
} else if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'draft' ) {
|
|
1151
1155
|
structure.redo = qaAnswers[j]?.redo;
|
|
1152
1156
|
}
|
|
1153
1157
|
if ( qaAnswers[j]?.redoComment ) {
|
|
@@ -1197,13 +1201,14 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1197
1201
|
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
|
|
1198
1202
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1199
1203
|
structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1204
|
+
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1200
1205
|
if ( qaAnswers[j]?.taskId ) {
|
|
1201
1206
|
structure.taskId = qaAnswers[j]?.taskId;
|
|
1202
1207
|
structure.task = true;
|
|
1203
1208
|
}
|
|
1204
1209
|
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1205
1210
|
structure.redo = false;
|
|
1206
|
-
} else if ( requestData.submittype === 'draft' ) {
|
|
1211
|
+
} else if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'draft' ) {
|
|
1207
1212
|
structure.redo = qaAnswers[j]?.redo;
|
|
1208
1213
|
}
|
|
1209
1214
|
if ( qaAnswers[j]?.redoComment ) {
|
|
@@ -1258,13 +1263,14 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1258
1263
|
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
|
|
1259
1264
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1260
1265
|
structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1266
|
+
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1261
1267
|
if ( qaAnswers[j]?.taskId ) {
|
|
1262
1268
|
structure.taskId = qaAnswers[j]?.taskId;
|
|
1263
1269
|
structure.task = true;
|
|
1264
1270
|
}
|
|
1265
1271
|
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1266
1272
|
structure.redo = false;
|
|
1267
|
-
} else if ( requestData.submittype === 'draft' ) {
|
|
1273
|
+
} else if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'draft' ) {
|
|
1268
1274
|
structure.redo = qaAnswers[j]?.redo;
|
|
1269
1275
|
}
|
|
1270
1276
|
if ( qaAnswers[j]?.redoComment ) {
|
|
@@ -1317,13 +1323,14 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1317
1323
|
structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
|
|
1318
1324
|
structure.descriptivetype = qaAnswers[j].descriptivetype;
|
|
1319
1325
|
structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
|
|
1326
|
+
structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
|
|
1320
1327
|
if ( qaAnswers[j]?.taskId ) {
|
|
1321
1328
|
structure.taskId = qaAnswers[j]?.taskId;
|
|
1322
1329
|
structure.task = true;
|
|
1323
1330
|
}
|
|
1324
1331
|
if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1325
1332
|
structure.redo = false;
|
|
1326
|
-
} else if ( requestData.submittype === 'draft' ) {
|
|
1333
|
+
} else if ( typeof qaAnswers[j]?.redo === 'boolean' && requestData.submittype === 'draft' ) {
|
|
1327
1334
|
structure.redo = qaAnswers[j]?.redo;
|
|
1328
1335
|
}
|
|
1329
1336
|
if ( qaAnswers[j]?.redoComment ) {
|
|
@@ -1719,12 +1726,12 @@ export async function submitChecklist( req, res ) {
|
|
|
1719
1726
|
updateQuery._id = new ObjectId( requestData.processedcheckListId );
|
|
1720
1727
|
updateQuery.userId = req.user._id;
|
|
1721
1728
|
updateQuery.date_string = requestData.date;
|
|
1722
|
-
let storeTimeZone = await storeService.findOne( { storeName: getchecklist[0].storeName }, { 'storeProfile.timeZone': 1 } );
|
|
1729
|
+
let storeTimeZone = await storeService.findOne( { storeName: { $regex: getchecklist[0].storeName, $options: 'i' }, clientId: getchecklist[0].client_id }, { 'storeProfile.timeZone': 1 } );
|
|
1723
1730
|
let currentDateTime;
|
|
1724
1731
|
if ( storeTimeZone?.storeProfile?.timeZone ) {
|
|
1725
1732
|
currentDateTime = dayjs().tz( storeTimeZone?.storeProfile?.timeZone );
|
|
1726
1733
|
} else {
|
|
1727
|
-
currentDateTime = dayjs();
|
|
1734
|
+
currentDateTime = requestData?.currentTime ? dayjs( requestData.currentTime, 'HH:mm:ss' ) : dayjs();
|
|
1728
1735
|
}
|
|
1729
1736
|
let updateData = {};
|
|
1730
1737
|
let flagCount = QuestionFlag( req, res );
|
|
@@ -2599,6 +2606,7 @@ export async function questionList( req, res ) {
|
|
|
2599
2606
|
questions = [];
|
|
2600
2607
|
for ( let question of section.questions ) {
|
|
2601
2608
|
if ( !question.linkType ) {
|
|
2609
|
+
question.parentQuestion = question.qno;
|
|
2602
2610
|
questions.push( question );
|
|
2603
2611
|
let linkedAnswer = new Set( question.answers.filter( ( ele ) => ele.showLinked ).flatMap( ( ele ) => ele.nestedQuestion ) );
|
|
2604
2612
|
let linkedQuestion = section.questions.filter( ( qn ) => qn?.parentQuestion ? qn?.parentQuestion == question.qno && linkedAnswer.has( qn.qno ) : linkedAnswer.has( qn.qno ) );
|
|
@@ -564,7 +564,10 @@ export const flagCardsV1 = async ( req, res ) => {
|
|
|
564
564
|
{
|
|
565
565
|
$match: {
|
|
566
566
|
client_id: clientId,
|
|
567
|
-
|
|
567
|
+
$or: [
|
|
568
|
+
{ store_id: { $in: storeId } },
|
|
569
|
+
{ aiStoreList: { $in: storeId } },
|
|
570
|
+
],
|
|
568
571
|
date_iso: { $gte: adjustedFromDate, $lte: adjustedToDate },
|
|
569
572
|
},
|
|
570
573
|
},
|
|
@@ -634,7 +637,7 @@ export const flagCardsV1 = async ( req, res ) => {
|
|
|
634
637
|
flagCards.detectionFlag.count += resultData[item];
|
|
635
638
|
}
|
|
636
639
|
} );
|
|
637
|
-
flagCards.totalFlag
|
|
640
|
+
flagCards.totalFlag += flagCards.detectionFlag.count;
|
|
638
641
|
}
|
|
639
642
|
|
|
640
643
|
return res.sendSuccess( { flagCards } );
|
|
@@ -697,7 +700,12 @@ export const flagComparisonCardsV1 = async ( req, res ) => {
|
|
|
697
700
|
}
|
|
698
701
|
|
|
699
702
|
const createFindQuery = ( fromDate, toDate ) => [
|
|
700
|
-
{ $match: { client_id: requestData.clientId,
|
|
703
|
+
{ $match: { client_id: requestData.clientId,
|
|
704
|
+
$or: [
|
|
705
|
+
{ store_id: { $in: requestData.storeId } },
|
|
706
|
+
{ aiStoreList: { $in: requestData.storeId } },
|
|
707
|
+
],
|
|
708
|
+
date_iso: { $gte: fromDate, $lte: toDate } } },
|
|
701
709
|
{
|
|
702
710
|
$project: {
|
|
703
711
|
timeFlag: 1,
|
|
@@ -874,6 +874,11 @@ export const assignedUserDetails = async ( req, res ) => {
|
|
|
874
874
|
query.push( { $match: { storeName: { $regex: req.query.search.trim(), $options: 'i' } } } );
|
|
875
875
|
}
|
|
876
876
|
}
|
|
877
|
+
if ( req.query.sortColumn && req.query.sortBy ) {
|
|
878
|
+
query.push( { $sort: { [req.query.sortColumn]: parseInt( req.query.sortBy ) } } );
|
|
879
|
+
} else {
|
|
880
|
+
query.push( { $sort: { _id: -1 } } );
|
|
881
|
+
}
|
|
877
882
|
|
|
878
883
|
query.push( {
|
|
879
884
|
$facet: {
|
|
@@ -893,19 +898,28 @@ export const assignedUserDetails = async ( req, res ) => {
|
|
|
893
898
|
}
|
|
894
899
|
|
|
895
900
|
let userDetails = [];
|
|
901
|
+
let storeList = [];
|
|
902
|
+
let userList = [];
|
|
896
903
|
checklistDetails[0].data.forEach( ( item ) => {
|
|
904
|
+
if ( item?.store_id ) {
|
|
905
|
+
storeList.push( item.assignId );
|
|
906
|
+
} else {
|
|
907
|
+
userList.push( item.assignId );
|
|
908
|
+
}
|
|
897
909
|
userDetails.push( {
|
|
898
910
|
id: item._id,
|
|
899
911
|
userName: item.userName,
|
|
900
912
|
userEmail: item.userEmail,
|
|
901
|
-
store_id: item
|
|
902
|
-
storeName: item
|
|
913
|
+
store_id: item?.store_id,
|
|
914
|
+
storeName: item?.storeName,
|
|
903
915
|
userPhone: item.userPhone,
|
|
904
916
|
city: item.city,
|
|
905
917
|
checkFlag: item.checkFlag,
|
|
918
|
+
clusterName: item?.clusterName,
|
|
919
|
+
teamName: item?.teamName,
|
|
906
920
|
} );
|
|
907
921
|
} );
|
|
908
|
-
return res.sendSuccess( { users: userDetails, count: checklistDetails[0].count[0].total } );
|
|
922
|
+
return res.sendSuccess( { users: userDetails, count: checklistDetails[0].count[0].total, storeList, userList } );
|
|
909
923
|
} catch ( e ) {
|
|
910
924
|
logger.error( 'assignedUserDetails =>', e );
|
|
911
925
|
return res.sendError( e, 500 );
|
|
@@ -2711,3 +2725,192 @@ export const checklistV2 = async ( req, res ) => {
|
|
|
2711
2725
|
return res.sendError( e, 500 );
|
|
2712
2726
|
}
|
|
2713
2727
|
};
|
|
2728
|
+
|
|
2729
|
+
export async function checklistAssign( req, res ) {
|
|
2730
|
+
try {
|
|
2731
|
+
if ( !req.body.checklistId ) {
|
|
2732
|
+
return res.sendError( 'Checklist id is required', 400 );
|
|
2733
|
+
}
|
|
2734
|
+
if ( !req.body.coverage ) {
|
|
2735
|
+
return res.sendError( 'Coverage is required', 400 );
|
|
2736
|
+
}
|
|
2737
|
+
if ( !req.body.id ) {
|
|
2738
|
+
return res.sendError( 'Store/user id is required', 400 );
|
|
2739
|
+
}
|
|
2740
|
+
|
|
2741
|
+
let checklistDetails = await checklistService.findOne( { _id: req.body.checklistId } );
|
|
2742
|
+
if ( !checklistDetails ) {
|
|
2743
|
+
return res.sendError( 'No data found', 204 );
|
|
2744
|
+
}
|
|
2745
|
+
checklistDetails.coverage = req.body.coverage;
|
|
2746
|
+
checklistDetails.save();
|
|
2747
|
+
let idList;
|
|
2748
|
+
if ( req.body.coverage == 'store' ) {
|
|
2749
|
+
let clusterDetails = await clusterServices.findOneCluster( { _id: req.body.id }, { stores: 1, clusterName: 1 } );
|
|
2750
|
+
if ( clusterDetails ) {
|
|
2751
|
+
idList = clusterDetails.stores.map( ( item ) => item.store );
|
|
2752
|
+
} else {
|
|
2753
|
+
idList = [ new ObjectId( req.body.id ) ];
|
|
2754
|
+
}
|
|
2755
|
+
let getStoreDetails = await storeService.find( { _id: { $in: idList } } );
|
|
2756
|
+
if ( !getStoreDetails.length ) {
|
|
2757
|
+
return res.sendError( 'No data found', 204 );
|
|
2758
|
+
}
|
|
2759
|
+
let assignList = await Promise.all( getStoreDetails.map( async ( store ) => {
|
|
2760
|
+
let userDetails = await userService.findOne( { userEmail: store?.spocDetails?.email, clientId: store.clientId } );
|
|
2761
|
+
if ( !userDetails ) {
|
|
2762
|
+
let data = {
|
|
2763
|
+
clientId: store.clientId,
|
|
2764
|
+
userName: store.spocDetails?.[0]?.name,
|
|
2765
|
+
mobileNumber: store.spocDetails?.[0]?.phone || '',
|
|
2766
|
+
email: store.spocDetails[0].email,
|
|
2767
|
+
password: '5dqFKAJj29PsV6P+kL+3Dw==',
|
|
2768
|
+
role: 'user',
|
|
2769
|
+
userType: 'client',
|
|
2770
|
+
rolespermission: [
|
|
2771
|
+
{
|
|
2772
|
+
featureName: 'Global',
|
|
2773
|
+
modules: [
|
|
2774
|
+
{
|
|
2775
|
+
name: 'Store',
|
|
2776
|
+
isAdd: false,
|
|
2777
|
+
isEdit: false,
|
|
2778
|
+
|
|
2779
|
+
},
|
|
2780
|
+
{
|
|
2781
|
+
name: 'User',
|
|
2782
|
+
isAdd: false,
|
|
2783
|
+
isEdit: false,
|
|
2784
|
+
|
|
2785
|
+
},
|
|
2786
|
+
{
|
|
2787
|
+
name: 'Camera',
|
|
2788
|
+
isAdd: false,
|
|
2789
|
+
isEdit: false,
|
|
2790
|
+
|
|
2791
|
+
},
|
|
2792
|
+
{
|
|
2793
|
+
name: 'Configuration',
|
|
2794
|
+
isAdd: false,
|
|
2795
|
+
isEdit: false,
|
|
2796
|
+
|
|
2797
|
+
},
|
|
2798
|
+
{
|
|
2799
|
+
name: 'Subscription',
|
|
2800
|
+
isAdd: false,
|
|
2801
|
+
isEdit: false,
|
|
2802
|
+
|
|
2803
|
+
},
|
|
2804
|
+
{
|
|
2805
|
+
name: 'Billing',
|
|
2806
|
+
isAdd: false,
|
|
2807
|
+
isEdit: false,
|
|
2808
|
+
|
|
2809
|
+
},
|
|
2810
|
+
],
|
|
2811
|
+
},
|
|
2812
|
+
{
|
|
2813
|
+
featurName: 'TangoEye',
|
|
2814
|
+
modules: [
|
|
2815
|
+
{
|
|
2816
|
+
name: 'ZoneTag',
|
|
2817
|
+
isAdd: false,
|
|
2818
|
+
isEdit: false,
|
|
2819
|
+
|
|
2820
|
+
},
|
|
2821
|
+
],
|
|
2822
|
+
},
|
|
2823
|
+
{
|
|
2824
|
+
featurName: 'TangoTrax',
|
|
2825
|
+
modules: [
|
|
2826
|
+
{
|
|
2827
|
+
name: 'checklist',
|
|
2828
|
+
isAdd: false,
|
|
2829
|
+
isEdit: false,
|
|
2830
|
+
|
|
2831
|
+
},
|
|
2832
|
+
{
|
|
2833
|
+
name: 'Task',
|
|
2834
|
+
isAdd: false,
|
|
2835
|
+
isEdit: false,
|
|
2836
|
+
|
|
2837
|
+
},
|
|
2838
|
+
],
|
|
2839
|
+
},
|
|
2840
|
+
],
|
|
2841
|
+
};
|
|
2842
|
+
userDetails = await userService.create( data );
|
|
2843
|
+
}
|
|
2844
|
+
let data = {
|
|
2845
|
+
store_id: store.storeId,
|
|
2846
|
+
storeName: store.storeName,
|
|
2847
|
+
userId: userDetails._id,
|
|
2848
|
+
userName: userDetails.userName,
|
|
2849
|
+
userEmail: userDetails.email,
|
|
2850
|
+
userPhone: userDetails?.mobileNumber,
|
|
2851
|
+
city: store?.storeProfile?.city,
|
|
2852
|
+
country: store?.storeprofile?.country,
|
|
2853
|
+
checkFlag: true,
|
|
2854
|
+
checkListId: req.body.checklistId,
|
|
2855
|
+
checkListName: checklistDetails.checkListName,
|
|
2856
|
+
client_id: store.clientId,
|
|
2857
|
+
clusterName: clusterDetails?.clusterName,
|
|
2858
|
+
assignId: req.body.id,
|
|
2859
|
+
};
|
|
2860
|
+
return data;
|
|
2861
|
+
} ) );
|
|
2862
|
+
await assignedService.insertMany( assignList );
|
|
2863
|
+
} else {
|
|
2864
|
+
let teamDetails = await teamsServices.findOneTeams( { _id: req.body.id }, { users: 1, teamName: 1 } );
|
|
2865
|
+
if ( teamDetails ) {
|
|
2866
|
+
idList = teamDetails.users.map( ( item ) => item.userId );
|
|
2867
|
+
} else {
|
|
2868
|
+
idList = [ new ObjectId( req.body.id ) ];
|
|
2869
|
+
}
|
|
2870
|
+
let userDetails = await userService.find( { _id: { $in: idList } } );
|
|
2871
|
+
if ( !userDetails.length ) {
|
|
2872
|
+
return res.sendError( 'No data found', 204 );
|
|
2873
|
+
}
|
|
2874
|
+
let assignList = [];
|
|
2875
|
+
userDetails.forEach( ( user ) => {
|
|
2876
|
+
assignList.push( {
|
|
2877
|
+
userId: user._id,
|
|
2878
|
+
userName: user.userName,
|
|
2879
|
+
userEmail: user.email,
|
|
2880
|
+
userPhone: user?.mobileNumber,
|
|
2881
|
+
checkFlag: true,
|
|
2882
|
+
checkListId: req.body.checklistId,
|
|
2883
|
+
checkListName: checklistDetails.checkListName,
|
|
2884
|
+
client_id: user.clientId,
|
|
2885
|
+
teamName: teamDetails?.teamName,
|
|
2886
|
+
assignId: req.body.id,
|
|
2887
|
+
} );
|
|
2888
|
+
} );
|
|
2889
|
+
await assignedService.insertMany( assignList );
|
|
2890
|
+
}
|
|
2891
|
+
return res.sendSuccess( 'Details updated successfully' );
|
|
2892
|
+
} catch ( e ) {
|
|
2893
|
+
logger.error( { functionName: 'checklistAssign', error: e } );
|
|
2894
|
+
return res.sendError( e, 500 );
|
|
2895
|
+
}
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
export async function removeAssign( req, res ) {
|
|
2899
|
+
try {
|
|
2900
|
+
if ( !req.body.id ) {
|
|
2901
|
+
return res.sendError( 'Id is required', 400 );
|
|
2902
|
+
}
|
|
2903
|
+
if ( !req.body.checkListId ) {
|
|
2904
|
+
return res.sendError( 'Checklist id is required', 400 );
|
|
2905
|
+
}
|
|
2906
|
+
let checklistDetails = await checklistService.findOne( { _id: req.body.checkListId } );
|
|
2907
|
+
if ( !checklistDetails ) {
|
|
2908
|
+
return res.sendError( 'No data found', 204 );
|
|
2909
|
+
}
|
|
2910
|
+
await assignedService.deleteMany( { assignId: req.body.id } );
|
|
2911
|
+
return res.sendSuccess( 'Details removed successfully' );
|
|
2912
|
+
} catch ( e ) {
|
|
2913
|
+
logger.error( { functionName: 'removeAssign', error: e } );
|
|
2914
|
+
return res.sendError( e, 500 );
|
|
2915
|
+
}
|
|
2916
|
+
}
|
|
@@ -23,6 +23,8 @@ traxRouter
|
|
|
23
23
|
.get( '/aichecklist', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ ] } ] } ), validate( aichecklistValidation ), traxController.aiChecklist )
|
|
24
24
|
.get( '/predefinedChecklist', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ ] } ] } ), validate( aichecklistValidation ), traxController.preDefinedChecklist )
|
|
25
25
|
.post( '/selectAssign', validate( selectAssign ), traxController.selectAssign )
|
|
26
|
-
.get( '/checklistV2', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ ] } ] } ), validate( checklistPageSchema ), traxController.checklistV2 )
|
|
26
|
+
.get( '/checklistV2', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ ] } ] } ), validate( checklistPageSchema ), traxController.checklistV2 )
|
|
27
|
+
.post( '/assign', isAllowedSessionHandler, traxController.checklistAssign )
|
|
28
|
+
.post( '/remove', isAllowedSessionHandler, traxController.removeAssign );
|
|
27
29
|
|
|
28
30
|
// isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ ] } ] } ),
|