@frontegg/redux-store 5.26.0 → 5.27.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.
@@ -69,6 +69,7 @@ const initialBillingInformationState = {
69
69
  fetching: true,
70
70
  externallyManaged: false,
71
71
  defaultPlanId: null,
72
+ defaultPaymentId: null,
72
73
  cancellation: {
73
74
  loading: false,
74
75
  error: null,
@@ -199,7 +200,7 @@ const managedSubscriptionsInitialState = {
199
200
  loading: false,
200
201
  error: null,
201
202
  fetching: true,
202
- managedSubscriptions: [],
203
+ managedSubscription: null,
203
204
  };
204
205
  const reducers = Object.assign({}, createModuleCaseReducers());
205
206
  const { reducer: reducer$1, actions: sliceActions, name } = toolkit.createSlice({
@@ -281,6 +282,7 @@ const subscriptionResponseMock = {
281
282
  externalId: 'sub_1JbhYVEwsu4qiqnnfMhYAdY6',
282
283
  startDate: '2021-09-20T08:08:51.000Z',
283
284
  status: restApi.ISubscriptionStatus.ACTIVE,
285
+ externallyManaged: false,
284
286
  cancellation: null,
285
287
  currentPeriodStart: '2021-09-20T08:08:51.000Z',
286
288
  currentPeriodEnd: '2021-10-20T08:08:51.000Z',
@@ -359,8 +361,8 @@ const paymentMethodsMock = [
359
361
  billingDetails: {
360
362
  name: 'Dummy',
361
363
  email: 'dummy@email.com',
362
- }
363
- }
364
+ },
365
+ },
364
366
  ];
365
367
 
366
368
  function* subscriptionBillingInformationSagas() {
@@ -388,11 +390,12 @@ function* loadSummaries(tenantId) {
388
390
  var _a, _b;
389
391
  yield effects.put(actions$6.setLoading(true));
390
392
  try {
391
- const { currentPlanId, subscriptionId, externallyManaged, defaultPlanId } = yield effects.call(restApi.api.subscriptions.getSubscriptionSummaries, tenantId);
392
- const subscriptionResponse = yield effects.call(restApi.api.subscriptions.getSubscription, subscriptionId);
393
+ const { currentPlanId, subscriptionId, externallyManaged, defaultPlanId, paymentMethodId: defaultPaymentId, } = yield effects.call(restApi.api.subscriptions.getSubscriptionSummaries, tenantId);
394
+ const subscriptionResponse = yield effects.call(restApi.api.subscriptions.getManagedSubscription, subscriptionId);
393
395
  const planResponse = yield effects.call(restApi.api.subscriptions.getSubscriptionPlan, currentPlanId);
394
396
  yield effects.put(actions$6.setBillingInformation(Object.assign(Object.assign({ loading: false, fetching: false, externallyManaged,
395
- defaultPlanId }, (subscriptionResponse
397
+ defaultPlanId,
398
+ defaultPaymentId }, (subscriptionResponse
396
399
  ? {
397
400
  subscription: {
398
401
  id: subscriptionResponse.id,
@@ -692,9 +695,10 @@ function* confirmPlan({ payload: paymentMethodId }) {
692
695
  error: null,
693
696
  }));
694
697
  try {
695
- yield effects.call(restApi.api.subscriptions.updateSubscription, subscription.id, {
698
+ yield effects.call(restApi.api.subscriptions.updateManagedSubscription, subscription.id, {
696
699
  paymentMethodId,
697
700
  planId,
701
+ items: []
698
702
  });
699
703
  yield effects.put(actions$3.setState({
700
704
  checkoutPlanId: null,
@@ -893,7 +897,7 @@ function* loadManagedSubscriptions() {
893
897
  yield effects.put(actions$1.setState({
894
898
  fetching: false,
895
899
  loading: false,
896
- managedSubscriptions,
900
+ managedSubscription: managedSubscriptions === null || managedSubscriptions === void 0 ? void 0 : managedSubscriptions[0],
897
901
  }));
898
902
  }
899
903
  catch (e) {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@frontegg/redux-store",
3
3
  "libName": "FronteggReduxStore",
4
- "version": "5.26.0",
4
+ "version": "5.27.0",
5
5
  "author": "Frontegg LTD",
6
6
  "main": "./node/index.js",
7
7
  "module": "./index.js",
8
8
  "types": "./index.d.ts",
9
9
  "dependencies": {
10
- "@frontegg/rest-api": "2.10.58",
10
+ "@frontegg/rest-api": "2.10.60",
11
11
  "@reduxjs/toolkit": "^1.5.0",
12
12
  "redux-saga": "^1.1.0",
13
13
  "tslib": "^2.3.1",
@@ -5,6 +5,7 @@ export interface BillingInformationState {
5
5
  fetching: boolean;
6
6
  externallyManaged: boolean;
7
7
  defaultPlanId: string | null;
8
+ defaultPaymentId: string | null;
8
9
  subscription?: Subscription;
9
10
  plan?: Plan;
10
11
  cancellation: {
@@ -3,7 +3,7 @@ export interface ManagedSubscriptionsState {
3
3
  loading: boolean;
4
4
  error: string | null;
5
5
  fetching: boolean;
6
- managedSubscriptions: ISubscriptionResponse[];
6
+ managedSubscription: ISubscriptionResponse | null;
7
7
  }
8
8
  export interface ManagedSubscriptionsActions {
9
9
  loadManagedSubscriptions: () => void;
@@ -66,6 +66,7 @@ const initialBillingInformationState = {
66
66
  fetching: true,
67
67
  externallyManaged: false,
68
68
  defaultPlanId: null,
69
+ defaultPaymentId: null,
69
70
  cancellation: {
70
71
  loading: false,
71
72
  error: null,
@@ -196,7 +197,7 @@ const managedSubscriptionsInitialState = {
196
197
  loading: false,
197
198
  error: null,
198
199
  fetching: true,
199
- managedSubscriptions: [],
200
+ managedSubscription: null,
200
201
  };
201
202
  const reducers = Object.assign({}, createModuleCaseReducers());
202
203
  const { reducer: reducer$1, actions: sliceActions, name } = createSlice({
@@ -278,6 +279,7 @@ const subscriptionResponseMock = {
278
279
  externalId: 'sub_1JbhYVEwsu4qiqnnfMhYAdY6',
279
280
  startDate: '2021-09-20T08:08:51.000Z',
280
281
  status: ISubscriptionStatus.ACTIVE,
282
+ externallyManaged: false,
281
283
  cancellation: null,
282
284
  currentPeriodStart: '2021-09-20T08:08:51.000Z',
283
285
  currentPeriodEnd: '2021-10-20T08:08:51.000Z',
@@ -356,8 +358,8 @@ const paymentMethodsMock = [
356
358
  billingDetails: {
357
359
  name: 'Dummy',
358
360
  email: 'dummy@email.com',
359
- }
360
- }
361
+ },
362
+ },
361
363
  ];
362
364
 
363
365
  function* subscriptionBillingInformationSagas() {
@@ -385,11 +387,12 @@ function* loadSummaries(tenantId) {
385
387
  var _a, _b;
386
388
  yield put(actions$6.setLoading(true));
387
389
  try {
388
- const { currentPlanId, subscriptionId, externallyManaged, defaultPlanId } = yield call(api.subscriptions.getSubscriptionSummaries, tenantId);
389
- const subscriptionResponse = yield call(api.subscriptions.getSubscription, subscriptionId);
390
+ const { currentPlanId, subscriptionId, externallyManaged, defaultPlanId, paymentMethodId: defaultPaymentId, } = yield call(api.subscriptions.getSubscriptionSummaries, tenantId);
391
+ const subscriptionResponse = yield call(api.subscriptions.getManagedSubscription, subscriptionId);
390
392
  const planResponse = yield call(api.subscriptions.getSubscriptionPlan, currentPlanId);
391
393
  yield put(actions$6.setBillingInformation(Object.assign(Object.assign({ loading: false, fetching: false, externallyManaged,
392
- defaultPlanId }, (subscriptionResponse
394
+ defaultPlanId,
395
+ defaultPaymentId }, (subscriptionResponse
393
396
  ? {
394
397
  subscription: {
395
398
  id: subscriptionResponse.id,
@@ -689,9 +692,10 @@ function* confirmPlan({ payload: paymentMethodId }) {
689
692
  error: null,
690
693
  }));
691
694
  try {
692
- yield call(api.subscriptions.updateSubscription, subscription.id, {
695
+ yield call(api.subscriptions.updateManagedSubscription, subscription.id, {
693
696
  paymentMethodId,
694
697
  planId,
698
+ items: []
695
699
  });
696
700
  yield put(actions$3.setState({
697
701
  checkoutPlanId: null,
@@ -890,7 +894,7 @@ function* loadManagedSubscriptions() {
890
894
  yield put(actions$1.setState({
891
895
  fetching: false,
892
896
  loading: false,
893
- managedSubscriptions,
897
+ managedSubscription: managedSubscriptions === null || managedSubscriptions === void 0 ? void 0 : managedSubscriptions[0],
894
898
  }));
895
899
  }
896
900
  catch (e) {