@zeniai/client-epic-state 5.0.88-betaAS1 → 5.0.88

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.
@@ -90,10 +90,13 @@ const tenant = (0, toolkit_1.createSlice)({
90
90
  (newTenant != null && action.payload.tenantUpdated)) {
91
91
  // Note: If tenant data already exists, save it if the new data is the latest one.
92
92
  // we dont want to overwrite the user related data since that has not come in the output
93
- draft.tenantsById[tenantPayload.tenant_id] = {
94
- ...newTenant,
95
- rewardsLastViewedTime: tenantInStore?.rewardsLastViewedTime,
96
- };
93
+ draft.tenantsById[tenantPayload.tenant_id] =
94
+ applyTreasuryPromoUserFieldsFromPayload(tenantInStore, {
95
+ ...newTenant,
96
+ rewardsLastViewedTime: tenantInStore?.rewardsLastViewedTime,
97
+ }, action.payload.userTenantPayload ?? {
98
+ rewards_feature_last_viewed_time: null,
99
+ });
97
100
  }
98
101
  });
99
102
  },
@@ -120,6 +123,9 @@ const tenant = (0, toolkit_1.createSlice)({
120
123
  draft.fetchState = 'Completed';
121
124
  draft.error = undefined;
122
125
  const [tenantsbyId, tenantIds, firstUser] = mapTenantsPayloadToState(tenants, user);
126
+ tenantIds.forEach((tenantId) => {
127
+ tenantsbyId[tenantId] = applyTreasuryPromoUserFieldsFromPayload(draft.tenantsById[tenantId], tenantsbyId[tenantId], user);
128
+ });
123
129
  draft.tenantsById = tenantsbyId;
124
130
  draft.tenantIds = tenantIds;
125
131
  draft.loggedInUser = (0, assignWith_1.default)(draft.loggedInUser ?? {}, firstUser, (objValue, srcValue) => srcValue ?? objValue);
@@ -823,6 +829,27 @@ const tenant = (0, toolkit_1.createSlice)({
823
829
  });
824
830
  _a = tenant.actions, exports.updateTenants = _a.updateTenants, exports.fetchAllTenants = _a.fetchAllTenants, exports.updateTenantsSuccess = _a.updateTenantsSuccess, exports.updateTenantsFailure = _a.updateTenantsFailure, exports.fetchActiveTenant = _a.fetchActiveTenant, exports.updateTenantSuccess = _a.updateTenantSuccess, exports.updateTenantFailure = _a.updateTenantFailure, exports.updateCurrentTenant = _a.updateCurrentTenant, exports.fetchExcludedResources = _a.fetchExcludedResources, exports.updateExcludedResourcesSuccess = _a.updateExcludedResourcesSuccess, exports.updateExcludedResourcesFailure = _a.updateExcludedResourcesFailure, exports.doSignIn = _a.doSignIn, exports.doMagicLinkSignIn = _a.doMagicLinkSignIn, exports.magicLinkSignInSuccess = _a.magicLinkSignInSuccess, exports.magicLinkSignInFailure = _a.magicLinkSignInFailure, exports.sendEmailMagicLinkToUser = _a.sendEmailMagicLinkToUser, exports.sendEmailMagicLinkToUserSuccess = _a.sendEmailMagicLinkToUserSuccess, exports.sendEmailMagicLinkToUserFailure = _a.sendEmailMagicLinkToUserFailure, exports.updateSignInState = _a.updateSignInState, exports.doSignOut = _a.doSignOut, exports.signOutSuccess = _a.signOutSuccess, exports.sendSessionHeartbeat = _a.sendSessionHeartbeat, exports.sessionHeartbeatSuccess = _a.sessionHeartbeatSuccess, exports.sessionHeartbeatFailure = _a.sessionHeartbeatFailure, exports.updateLoggedInUser = _a.updateLoggedInUser, exports.fetchExternalConnections = _a.fetchExternalConnections, exports.saveExternalConnection = _a.saveExternalConnection, exports.saveExternalConnectionSuccess = _a.saveExternalConnectionSuccess, exports.saveExternalConnectionFailure = _a.saveExternalConnectionFailure, exports.fetchExternalConnectionsFailure = _a.fetchExternalConnectionsFailure, exports.fetchExternalConnectionsSuccess = _a.fetchExternalConnectionsSuccess, exports.saveAPIKeyConnection = _a.saveAPIKeyConnection, exports.saveAPIKeyConnectionSuccess = _a.saveAPIKeyConnectionSuccess, exports.saveAPIKeyConnectionFailure = _a.saveAPIKeyConnectionFailure, exports.saveOAuthConnection = _a.saveOAuthConnection, exports.saveOAuthConnectionSuccess = _a.saveOAuthConnectionSuccess, exports.saveOAuthConnectionFailure = _a.saveOAuthConnectionFailure, exports.saveConnectorCredentials = _a.saveConnectorCredentials, exports.saveConnectorCredentialsSuccess = _a.saveConnectorCredentialsSuccess, exports.saveConnectorCredentialsFailure = _a.saveConnectorCredentialsFailure, exports.deleteConnection = _a.deleteConnection, exports.deleteConnectionSuccess = _a.deleteConnectionSuccess, exports.deleteConnectionFailure = _a.deleteConnectionFailure, exports.clearAll = _a.clearAll, exports.fetchSubscriptionSummaryForTenant = _a.fetchSubscriptionSummaryForTenant, exports.updateSubscriptionSummaryForTenantSuccess = _a.updateSubscriptionSummaryForTenantSuccess, exports.updateSubscriptionSummaryForTenantFailure = _a.updateSubscriptionSummaryForTenantFailure, exports.updateOnboardingTenants = _a.updateOnboardingTenants, exports.removeOnboardingTenant = _a.removeOnboardingTenant, exports.updateTenantReimbursementInfo = _a.updateTenantReimbursementInfo, exports.updateReferViewedForLoggedInUser = _a.updateReferViewedForLoggedInUser, exports.resetSignInState = _a.resetSignInState, exports.trigger2FA = _a.trigger2FA, exports.updateTenantAccountingClassesEnabled = _a.updateTenantAccountingClassesEnabled, exports.updateTenantCapitalizationOnboardingDismissed = _a.updateTenantCapitalizationOnboardingDismissed, exports.updateTenantCapitalizationThreshold = _a.updateTenantCapitalizationThreshold, exports.updateTenantMasterTOSInfo = _a.updateTenantMasterTOSInfo, exports.verifyDeviceWithTwoFA = _a.verifyDeviceWithTwoFA, exports.verifyDeviceWithTwoFASuccess = _a.verifyDeviceWithTwoFASuccess, exports.verifyDeviceWithTwoFAFailure = _a.verifyDeviceWithTwoFAFailure, exports.updateTreasuryVideoViewedForLoggedInUser = _a.updateTreasuryVideoViewedForLoggedInUser, exports.updateTreasuryPromoRemindMeLaterClickedForLoggedInUser = _a.updateTreasuryPromoRemindMeLaterClickedForLoggedInUser, exports.updateTreasuryPromoIntroClosedByOutsideClickForLoggedInUser = _a.updateTreasuryPromoIntroClosedByOutsideClickForLoggedInUser, exports.resendVerifyDeviceOTP = _a.resendVerifyDeviceOTP, exports.resendVerifyDeviceOTPSuccess = _a.resendVerifyDeviceOTPSuccess, exports.resendVerifyDeviceOTPFailure = _a.resendVerifyDeviceOTPFailure;
825
831
  exports.default = tenant.reducer;
832
+ /**
833
+ * Applies treasury promo user fields from the tenants API user block when present.
834
+ * When a field is omitted from the payload, keeps the existing tenant value so a
835
+ * later fetch-all-tenants call does not reset values already loaded by fetch-active-tenant.
836
+ */
837
+ function applyTreasuryPromoUserFieldsFromPayload(existingTenant, mappedTenant, userTenantPayload) {
838
+ if (existingTenant == null) {
839
+ return mappedTenant;
840
+ }
841
+ return {
842
+ ...mappedTenant,
843
+ isTreasuryPromoVideoPlayed: userTenantPayload.is_treasury_promo_video_played ??
844
+ existingTenant.isTreasuryPromoVideoPlayed,
845
+ isTreasuryPromoVideoRemindMeLaterClicked: userTenantPayload.is_treasury_promo_video_remind_me_later_clicked ??
846
+ existingTenant.isTreasuryPromoVideoRemindMeLaterClicked,
847
+ loginCounterForTreasuryPromoVideo: userTenantPayload.login_counter_for_treasury_promo_video ??
848
+ existingTenant.loginCounterForTreasuryPromoVideo,
849
+ isTreasuryPromoIntroClosedByOutsideClick: userTenantPayload.is_treasury_promo_intro_closed_by_outside_click ??
850
+ existingTenant.isTreasuryPromoIntroClosedByOutsideClick,
851
+ };
852
+ }
826
853
  /**
827
854
  * Converts tenants payload to Tenant and User State
828
855
  * @param payload tenants payload as received from backend API response
@@ -78,10 +78,13 @@ const tenant = createSlice({
78
78
  (newTenant != null && action.payload.tenantUpdated)) {
79
79
  // Note: If tenant data already exists, save it if the new data is the latest one.
80
80
  // we dont want to overwrite the user related data since that has not come in the output
81
- draft.tenantsById[tenantPayload.tenant_id] = {
82
- ...newTenant,
83
- rewardsLastViewedTime: tenantInStore?.rewardsLastViewedTime,
84
- };
81
+ draft.tenantsById[tenantPayload.tenant_id] =
82
+ applyTreasuryPromoUserFieldsFromPayload(tenantInStore, {
83
+ ...newTenant,
84
+ rewardsLastViewedTime: tenantInStore?.rewardsLastViewedTime,
85
+ }, action.payload.userTenantPayload ?? {
86
+ rewards_feature_last_viewed_time: null,
87
+ });
85
88
  }
86
89
  });
87
90
  },
@@ -108,6 +111,9 @@ const tenant = createSlice({
108
111
  draft.fetchState = 'Completed';
109
112
  draft.error = undefined;
110
113
  const [tenantsbyId, tenantIds, firstUser] = mapTenantsPayloadToState(tenants, user);
114
+ tenantIds.forEach((tenantId) => {
115
+ tenantsbyId[tenantId] = applyTreasuryPromoUserFieldsFromPayload(draft.tenantsById[tenantId], tenantsbyId[tenantId], user);
116
+ });
111
117
  draft.tenantsById = tenantsbyId;
112
118
  draft.tenantIds = tenantIds;
113
119
  draft.loggedInUser = assignWith(draft.loggedInUser ?? {}, firstUser, (objValue, srcValue) => srcValue ?? objValue);
@@ -811,6 +817,27 @@ const tenant = createSlice({
811
817
  });
812
818
  export const { updateTenants, fetchAllTenants, updateTenantsSuccess, updateTenantsFailure, fetchActiveTenant, updateTenantSuccess, updateTenantFailure, updateCurrentTenant, fetchExcludedResources, updateExcludedResourcesSuccess, updateExcludedResourcesFailure, doSignIn, doMagicLinkSignIn, magicLinkSignInSuccess, magicLinkSignInFailure, sendEmailMagicLinkToUser, sendEmailMagicLinkToUserSuccess, sendEmailMagicLinkToUserFailure, updateSignInState, doSignOut, signOutSuccess, sendSessionHeartbeat, sessionHeartbeatSuccess, sessionHeartbeatFailure, updateLoggedInUser, fetchExternalConnections, saveExternalConnection, saveExternalConnectionSuccess, saveExternalConnectionFailure, fetchExternalConnectionsFailure, fetchExternalConnectionsSuccess, saveAPIKeyConnection, saveAPIKeyConnectionSuccess, saveAPIKeyConnectionFailure, saveOAuthConnection, saveOAuthConnectionSuccess, saveOAuthConnectionFailure, saveConnectorCredentials, saveConnectorCredentialsSuccess, saveConnectorCredentialsFailure, deleteConnection, deleteConnectionSuccess, deleteConnectionFailure, clearAll, fetchSubscriptionSummaryForTenant, updateSubscriptionSummaryForTenantSuccess, updateSubscriptionSummaryForTenantFailure, updateOnboardingTenants, removeOnboardingTenant, updateTenantReimbursementInfo, updateReferViewedForLoggedInUser, resetSignInState, trigger2FA, updateTenantAccountingClassesEnabled, updateTenantCapitalizationOnboardingDismissed, updateTenantCapitalizationThreshold, updateTenantMasterTOSInfo, verifyDeviceWithTwoFA, verifyDeviceWithTwoFASuccess, verifyDeviceWithTwoFAFailure, updateTreasuryVideoViewedForLoggedInUser, updateTreasuryPromoRemindMeLaterClickedForLoggedInUser, updateTreasuryPromoIntroClosedByOutsideClickForLoggedInUser, resendVerifyDeviceOTP, resendVerifyDeviceOTPSuccess, resendVerifyDeviceOTPFailure, } = tenant.actions;
813
819
  export default tenant.reducer;
820
+ /**
821
+ * Applies treasury promo user fields from the tenants API user block when present.
822
+ * When a field is omitted from the payload, keeps the existing tenant value so a
823
+ * later fetch-all-tenants call does not reset values already loaded by fetch-active-tenant.
824
+ */
825
+ function applyTreasuryPromoUserFieldsFromPayload(existingTenant, mappedTenant, userTenantPayload) {
826
+ if (existingTenant == null) {
827
+ return mappedTenant;
828
+ }
829
+ return {
830
+ ...mappedTenant,
831
+ isTreasuryPromoVideoPlayed: userTenantPayload.is_treasury_promo_video_played ??
832
+ existingTenant.isTreasuryPromoVideoPlayed,
833
+ isTreasuryPromoVideoRemindMeLaterClicked: userTenantPayload.is_treasury_promo_video_remind_me_later_clicked ??
834
+ existingTenant.isTreasuryPromoVideoRemindMeLaterClicked,
835
+ loginCounterForTreasuryPromoVideo: userTenantPayload.login_counter_for_treasury_promo_video ??
836
+ existingTenant.loginCounterForTreasuryPromoVideo,
837
+ isTreasuryPromoIntroClosedByOutsideClick: userTenantPayload.is_treasury_promo_intro_closed_by_outside_click ??
838
+ existingTenant.isTreasuryPromoIntroClosedByOutsideClick,
839
+ };
840
+ }
814
841
  /**
815
842
  * Converts tenants payload to Tenant and User State
816
843
  * @param payload tenants payload as received from backend API response
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.88-betaAS1",
3
+ "version": "5.0.88",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",