tango-app-api-payment-subscription 3.0.49-dev → 3.0.50-dev

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-payment-subscription",
3
- "version": "3.0.49-dev",
3
+ "version": "3.0.50-dev",
4
4
  "description": "paymentSubscription",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -462,6 +462,24 @@ export const updateSubscription = async ( req, res ) => {
462
462
  } else {
463
463
  clientProducts[existsIndex].status = 'live';
464
464
  clientProducts[existsIndex].subscribedDate = new Date();
465
+ let productObj = {
466
+ userName: req.user?.userName,
467
+ email: req.user?.email,
468
+ clientId: requestBody.clientId,
469
+ clientNotification: false,
470
+ adminNotification: true,
471
+ title: 'Subscription',
472
+ description: 'Your subscription is now active! Get ready to maximize your instore sales potential with the Tangoeye suite',
473
+ alertCta: [],
474
+ markasRead: false,
475
+ logType: 'subscription',
476
+ logSubType: 'subscription',
477
+ showPushNotification: true,
478
+ changes: [ `${convertTitleCase( item.name )} subscribed` ],
479
+ eventType: '',
480
+ date: new Date(),
481
+ };
482
+ insertOpenSearchData( appConfig.opensearch.activityLog, productObj );
465
483
  }
466
484
  subscriptionCount = subscriptionCount + 1;
467
485
  }
@@ -1022,9 +1040,9 @@ export const trialExtendRequestApproval = async ( req, res ) => {
1022
1040
  requestData.save();
1023
1041
  }
1024
1042
  let userDetails = await userService.findOne( { clientId: req.body.clientId, role: 'superadmin' } );
1043
+ let [ firstWord, secondWord ] = req.body.product.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
1044
+ firstWord = firstWord.charAt( 0 ).toUpperCase() + firstWord.slice( 1 );
1025
1045
  if ( userDetails ) {
1026
- let [ firstWord, secondWord ] = req.body.product.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
1027
- firstWord = firstWord.charAt( 0 ).toUpperCase() + firstWord.slice( 1 );
1028
1046
  let data = {
1029
1047
  userName: userDetails.userName,
1030
1048
  product: firstWord + ' ' + secondWord,
@@ -1060,7 +1078,7 @@ export const trialExtendRequestApproval = async ( req, res ) => {
1060
1078
  logType: 'subscription',
1061
1079
  showPushNotification: true,
1062
1080
  date: new Date(),
1063
- changes: [ `${data.product} trial Extended` ],
1081
+ changes: [ `${firstWord + ' ' + secondWord} trial Extended` ],
1064
1082
  eventType: '',
1065
1083
  };
1066
1084
  insertOpenSearchData( appConfig.opensearch.activityLog, notifyObj );
@@ -2393,7 +2411,7 @@ export const getRemindClients = async ( req, res ) => {
2393
2411
  description: 'Subscription - Your Free trial is about to expire in 3 days. Pleas make sure to subscribe to the products',
2394
2412
  logSubType: 'trialReminder',
2395
2413
  title: 'Subscription',
2396
- alertCta: [ { buttonName: 'Subscribe now', redirectionUrl: 'manage/settings/payment-subscription' }, { buttonName: 'Remind me later', redirectionUrl: 'cancel' } ],
2414
+ alertCta: [ { buttonName: 'Subscribe now', redirectionUrl: 'manage/settings/payment-subscription', product: data.product, clientId: client.clientId }, { buttonName: 'Remind me later', redirectionUrl: 'remind' } ],
2397
2415
  markasRead: false,
2398
2416
  logType: 'subscription',
2399
2417
  showPushNotification: true,
@@ -3077,6 +3095,13 @@ export const invoiceRevised = async ( req, res ) => {
3077
3095
  export const clientNotificationList = async ( req, res ) => {
3078
3096
  try {
3079
3097
  let from = ( req.query.offset - 1 ) * req.query.limit;
3098
+ let start = new Date();
3099
+ let userTimezoneOffset = start.getTimezoneOffset() * 60000;
3100
+ start = new Date( start.getTime() - userTimezoneOffset );
3101
+ start.setUTCHours( 0, 0, 0, 0 );
3102
+ let end = new Date();
3103
+ end = new Date( end.getTime() - userTimezoneOffset );
3104
+ end.setUTCHours( 23, 59, 59, 59 );
3080
3105
  let query;
3081
3106
  if ( req.user.role == 'superadmin' ) {
3082
3107
  query = {
@@ -3089,9 +3114,17 @@ export const clientNotificationList = async ( req, res ) => {
3089
3114
  // { match: { logType: 'notification' } },
3090
3115
  { match: { adminNotification: true } },
3091
3116
  { match: { markasRead: false } },
3117
+ { range: { date: { gte: start, lte: end } } },
3092
3118
  ],
3093
3119
  },
3094
3120
  },
3121
+ sort: [
3122
+ {
3123
+ date: {
3124
+ order: 'desc',
3125
+ },
3126
+ },
3127
+ ],
3095
3128
  _source: [ 'title', 'alertCta', 'clientId', 'markasRead', 'showPushNotification', 'date', 'description' ],
3096
3129
  };
3097
3130
  } else {
@@ -3103,9 +3136,17 @@ export const clientNotificationList = async ( req, res ) => {
3103
3136
  // { match: { type: 'notification' } },
3104
3137
  { match: { clientNotification: true } },
3105
3138
  { match: { markasRead: false } },
3139
+ { range: { date: { gte: start, lte: end } } },
3106
3140
  ],
3107
3141
  },
3108
3142
  },
3143
+ sort: [
3144
+ {
3145
+ date: {
3146
+ order: 'desc',
3147
+ },
3148
+ },
3149
+ ],
3109
3150
  _source: [ 'title', 'alertCta', 'clientId', 'markasRead', 'showPushNotification', 'date', 'description' ],
3110
3151
  };
3111
3152
  }
@@ -3166,6 +3207,24 @@ export const updatePushNotification = async ( req, res ) => {
3166
3207
  }
3167
3208
  };
3168
3209
 
3210
+ export const updateRemind = async ( req, res ) => {
3211
+ try {
3212
+ let openSearchDetails = await getOpenSearchById( appConfig.opensearch.activityLog, req.params.notificationId );
3213
+ if ( openSearchDetails && openSearchDetails.statusCode == 200 && openSearchDetails?.body?._source ) {
3214
+ let date = new Date( new Date( openSearchDetails.body._source.date ).getTime() + 24 * 60 * 60 * 1000 );
3215
+ openSearchDetails.body._source.date = date;
3216
+ openSearchDetails.body._source.markasRead = false;
3217
+ insertOpenSearchData( appConfig.opensearch.activityLog, openSearchDetails.body._source );
3218
+ return res.sendSuccess( 'Notification Updated Successfully' );
3219
+ } else {
3220
+ return res.sendError( 'no data found', 204 );
3221
+ }
3222
+ } catch ( e ) {
3223
+ logger.error( { error: e, function: 'updatePushNotification' } );
3224
+ return res.sendError( e, 500 );
3225
+ }
3226
+ };
3227
+
3169
3228
 
3170
3229
  function convertTitleCase( data ) {
3171
3230
  let [ firstWord, secondWord ] = data.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
@@ -3173,3 +3232,5 @@ function convertTitleCase( data ) {
3173
3232
  data = firstWord + ' ' + secondWord;
3174
3233
  return data;
3175
3234
  }
3235
+
3236
+
@@ -163,4 +163,5 @@ paymentSubscriptionRouter.get( '/invoiceRevised/:invoiceId', validate( validatio
163
163
  paymentSubscriptionRouter.get( '/notificationList', isAllowedSessionHandler, validate( validationDtos.notificationParams ), paymentController.clientNotificationList );
164
164
  paymentSubscriptionRouter.put( '/notification/update/:notificationId', isAllowedSessionHandler, validate( validationDtos.validateId ), paymentController.updateNotification );
165
165
  paymentSubscriptionRouter.put( '/pushNotification/update/:notificationId', isAllowedSessionHandler, validate( validationDtos.validateId ), paymentController.updatePushNotification );
166
+ paymentSubscriptionRouter.post( '/updateRemind/:notificationId', isAllowedSessionHandler, validate( validationDtos.validateId ), paymentController.updateRemind );
166
167