tango-app-api-trax 3.6.0-sec-6 → 3.6.0-sec-8
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
|
@@ -2462,3 +2462,43 @@ export async function storecheckExists( data ) {
|
|
|
2462
2462
|
logger.error( { error: error, function: 'internalAISendPushNotification' } );
|
|
2463
2463
|
}
|
|
2464
2464
|
}
|
|
2465
|
+
|
|
2466
|
+
export async function insertAINotification( req, res ) {
|
|
2467
|
+
try {
|
|
2468
|
+
let requestData = req.body;
|
|
2469
|
+
let insertData= [];
|
|
2470
|
+
let findAllUser = await userService.find( { clientId: requestData.clientId, isActive: true } );
|
|
2471
|
+
for ( let user of findAllUser ) {
|
|
2472
|
+
let data= {};
|
|
2473
|
+
data.userId = user._id;
|
|
2474
|
+
data.storeId = requestData.storeId;
|
|
2475
|
+
data.storeName = requestData.storeName;
|
|
2476
|
+
data.captureTime = requestData.captureTime;
|
|
2477
|
+
data.clientId = requestData.clientId;
|
|
2478
|
+
data.sourceCheckList_id = requestData.sourceCheckList_id;
|
|
2479
|
+
data.checkListName = requestData.checkListName;
|
|
2480
|
+
data.notificationType = requestData.notificationType;
|
|
2481
|
+
let payload = {
|
|
2482
|
+
userType: user.userType,
|
|
2483
|
+
role: user.role,
|
|
2484
|
+
assignedStores: user.assignedStores,
|
|
2485
|
+
clientId: user.clientId,
|
|
2486
|
+
email: user.email,
|
|
2487
|
+
};
|
|
2488
|
+
let result = await storecheckExists( payload );
|
|
2489
|
+
if ( result ) {
|
|
2490
|
+
insertData.push( data );
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
// console.log( 'insertData =>', insertData );
|
|
2494
|
+
let create = await notificationModel.insertManynotificationModel( insertData );
|
|
2495
|
+
// console.log( 'create =>', create );
|
|
2496
|
+
if ( create ) {
|
|
2497
|
+
return res.sendSuccess( 'updated successfully' );
|
|
2498
|
+
}
|
|
2499
|
+
} catch ( e ) {
|
|
2500
|
+
logger.error( { error: e, function: 'insertAINotification' } );
|
|
2501
|
+
if ( e.name === 'ValidationError' ) res.sendBadRequest( e );
|
|
2502
|
+
else res.sendError( e, 500 );
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
@@ -151,8 +151,8 @@ export async function startChecklist( req, res ) {
|
|
|
151
151
|
|
|
152
152
|
let updateData = {};
|
|
153
153
|
let currentDateTime;
|
|
154
|
-
if ( getBeforeChecklist[0]
|
|
155
|
-
let storeTimeZone = await storeService.findOne( {
|
|
154
|
+
if ( getBeforeChecklist[0]?.store_id && getBeforeChecklist[0]?.store_id != '' ) {
|
|
155
|
+
let storeTimeZone = await storeService.findOne( { storeId: getBeforeChecklist[0].store_id, clientId: getBeforeChecklist[0].client_id }, { 'storeProfile.timeZone': 1 } );
|
|
156
156
|
if ( storeTimeZone?.storeProfile?.timeZone ) {
|
|
157
157
|
currentDateTime = dayjs().tz( storeTimeZone?.storeProfile?.timeZone );
|
|
158
158
|
} else {
|
|
@@ -1803,8 +1803,8 @@ export async function submitChecklist( req, res ) {
|
|
|
1803
1803
|
|
|
1804
1804
|
let currentDateTime;
|
|
1805
1805
|
let storeTimeZone;
|
|
1806
|
-
if ( getchecklist[0]
|
|
1807
|
-
storeTimeZone = await storeService.findOne( {
|
|
1806
|
+
if ( getchecklist[0]?.store_id && getchecklist[0]?.store_id !='' ) {
|
|
1807
|
+
storeTimeZone = await storeService.findOne( { storeId: getchecklist[0].store_id, clientId: getchecklist[0].client_id }, { 'storeProfile.timeZone': 1 } );
|
|
1808
1808
|
if ( storeTimeZone?.storeProfile?.timeZone ) {
|
|
1809
1809
|
currentDateTime = dayjs().tz( storeTimeZone?.storeProfile?.timeZone );
|
|
1810
1810
|
} else {
|
|
@@ -24,6 +24,7 @@ internalTraxRouter
|
|
|
24
24
|
.post( '/sendPushNotification', isAllowedInternalAPIHandler, internalController.internalSendPushNotification )
|
|
25
25
|
.post( '/sendAiPushNotification', isAllowedInternalAPIHandler, internalController.internalAISendPushNotification )
|
|
26
26
|
.post( '/getLiveChecklistClients', isAllowedInternalAPIHandler, internalController.getLiveChecklistClients )
|
|
27
|
-
.post( '/notificationCreate', isAllowedInternalAPIHandler, internalController.notificationCreate )
|
|
27
|
+
.post( '/notificationCreate', isAllowedInternalAPIHandler, internalController.notificationCreate )
|
|
28
|
+
.post( '/insertAINotification', isAllowedInternalAPIHandler, internalController.insertAINotification );
|
|
28
29
|
|
|
29
30
|
|