@frontegg/redux-store 5.9.1 → 5.13.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.
@@ -15,7 +15,7 @@ function createModuleCaseReducers() {
15
15
  },
16
16
  setError: {
17
17
  prepare: (payload) => ({ payload }),
18
- reducer: (state, action) => (Object.assign(Object.assign({}, state), { error: action.payload, loading: false })),
18
+ reducer: (state, action) => (Object.assign(Object.assign({}, state), { error: action.payload, loading: false, fetching: false })),
19
19
  },
20
20
  setState: {
21
21
  prepare: (payload) => ({ payload }),
@@ -39,25 +39,24 @@ function createKeyCaseErrorReducer(key) {
39
39
  const plansInitialState = {
40
40
  loading: false,
41
41
  error: null,
42
+ fetching: true,
42
43
  plans: [],
43
44
  };
44
45
  const { actions: sliceActions$1, reducer: reducer$7, name: name$6 } = toolkit.createSlice({
45
46
  name: `${constants.subscriptionsStoreName}/plans`,
46
47
  initialState: plansInitialState,
47
- reducers: Object.assign(Object.assign({}, createModuleCaseReducers()), { setPlans: {
48
- prepare: (payload) => ({ payload }),
49
- reducer: (state, action) => (Object.assign(Object.assign({}, state), { plans: action.payload })),
50
- } }),
48
+ reducers: Object.assign({}, createModuleCaseReducers()),
51
49
  });
52
50
  const actions$7 = Object.assign({ loadPlans: toolkit.createAction(`${name$6}/loadPlans`) }, sliceActions$1);
53
51
 
54
52
  const configInitialState = {
55
53
  loading: false,
56
54
  error: null,
55
+ fetching: true,
57
56
  config: null,
58
57
  };
59
58
  const reducers$5 = Object.assign({}, createModuleCaseReducers());
60
- const { actions: configActions, reducer: reducer$6, name: name$5 } = toolkit.createSlice({
59
+ const { actions: configActions, reducer: reducer$6, name: name$5, } = toolkit.createSlice({
61
60
  name: `${constants.subscriptionsStoreName}/config`,
62
61
  initialState: configInitialState,
63
62
  reducers: reducers$5,
@@ -67,6 +66,7 @@ const actions$6 = Object.assign({ loadPaymentConfiguration: toolkit.createAction
67
66
  const initialBillingInformationState = {
68
67
  loading: false,
69
68
  error: null,
69
+ fetching: true,
70
70
  externallyManaged: false,
71
71
  defaultPlanId: null,
72
72
  cancellation: {
@@ -92,12 +92,13 @@ const actions$5 = Object.assign({ loadBillingInformation: toolkit.createAction(`
92
92
  const initialPaymentMethodState = {
93
93
  loading: false,
94
94
  error: null,
95
+ fetching: true,
95
96
  };
96
97
  const reducers$3 = Object.assign(Object.assign({}, createModuleCaseReducers()), { setState: {
97
98
  prepare: (payload) => ({ payload }),
98
99
  reducer: (state, action) => (Object.assign(Object.assign({}, state), action.payload)),
99
100
  } });
100
- const { reducer: reducer$4, actions: paymentActions, name: name$3 } = toolkit.createSlice({
101
+ const { reducer: reducer$4, actions: paymentActions, name: name$3, } = toolkit.createSlice({
101
102
  name: `${constants.subscriptionsStoreName}/billing/payment`,
102
103
  initialState: initialPaymentMethodState,
103
104
  reducers: reducers$3,
@@ -107,16 +108,14 @@ const actions$4 = Object.assign({ loadPaymentMethod: toolkit.createAction(`${nam
107
108
  const initialInvoicesState = {
108
109
  loading: false,
109
110
  error: null,
111
+ fetching: true,
110
112
  invoices: [],
111
113
  invoiceDownload: {
112
114
  loading: false,
113
115
  error: null
114
116
  }
115
117
  };
116
- const reducers$2 = Object.assign(Object.assign({}, createModuleCaseReducers()), { setInvoices: {
117
- prepare: (payload) => ({ payload }),
118
- reducer: (state, action) => (Object.assign(Object.assign({}, state), { invoices: action.payload })),
119
- }, setInvoiceDownloadState: {
118
+ const reducers$2 = Object.assign(Object.assign({}, createModuleCaseReducers()), { setInvoiceDownloadState: {
120
119
  prepare: (payload) => ({ payload }),
121
120
  reducer: (state, action) => (Object.assign(Object.assign({}, state), { invoiceDownload: Object.assign(Object.assign({}, state.invoiceDownload), action.payload) })),
122
121
  } });
@@ -375,7 +374,7 @@ function* loadSummaries(tenantId) {
375
374
  const { currentPlanId, subscriptionId, externallyManaged, defaultPlanId } = yield effects.call(restApi.api.subscriptions.getSubscriptionSummaries, tenantId);
376
375
  const subscriptionResponse = yield effects.call(restApi.api.subscriptions.getSubscription, subscriptionId);
377
376
  const planResponse = yield effects.call(restApi.api.subscriptions.getSubscriptionPlan, currentPlanId);
378
- yield effects.put(actions$5.setBillingInformation(Object.assign(Object.assign({ loading: false, externallyManaged,
377
+ yield effects.put(actions$5.setBillingInformation(Object.assign(Object.assign({ loading: false, fetching: false, externallyManaged,
379
378
  defaultPlanId }, (subscriptionResponse
380
379
  ? {
381
380
  subscription: {
@@ -479,6 +478,7 @@ function* loadSummariesMock() {
479
478
  yield effects.delay(500);
480
479
  yield effects.put(actions$5.setBillingInformation({
481
480
  loading: false,
481
+ fetching: false,
482
482
  externallyManaged: false,
483
483
  subscription: Object.assign(Object.assign({}, subscriptionResponseMock), { startDate: new Date(subscriptionResponseMock.startDate), currentPeriodStart: new Date(subscriptionResponseMock.currentPeriodStart), currentPeriodEnd: new Date(subscriptionResponseMock.currentPeriodEnd), status: toSubscriptionStatus(subscriptionResponseMock.status), cancellation: subscriptionResponseMock.cancellation && toSubscriptionCancellation(subscriptionResponseMock.cancellation), items: subscriptionResponseMock.items }),
484
484
  plan: Object.assign(Object.assign({}, planResponseMock[0]), { price: toPrice((_a = planResponseMock[0].price) === null || _a === void 0 ? void 0 : _a.amount), currency: (_b = planResponseMock[0].price) === null || _b === void 0 ? void 0 : _b.currency, recurringInterval: 'month' }),
@@ -501,15 +501,11 @@ function* loadPaymentMethod() {
501
501
  try {
502
502
  const paymentMethods = yield effects.call(restApi.api.subscriptions.getPaymentMethods);
503
503
  const paymentMethod = paymentMethods[0];
504
- if (paymentMethod) {
505
- yield effects.put(actions$4.setState({
506
- paymentMethod,
507
- loading: false,
508
- }));
509
- }
510
- else {
511
- yield effects.put(actions$4.setLoading(false));
512
- }
504
+ yield effects.put(actions$4.setState({
505
+ paymentMethod,
506
+ loading: false,
507
+ fetching: false,
508
+ }));
513
509
  }
514
510
  catch (e) {
515
511
  yield effects.put(actions$4.setError(e.message));
@@ -553,6 +549,7 @@ function* loadPaymentMethodMock() {
553
549
  yield effects.put(actions$4.setState({
554
550
  paymentMethod,
555
551
  loading: false,
552
+ fetching: false,
556
553
  }));
557
554
  }
558
555
  function* subscriptionsPaymentMethodSagasMock() {
@@ -567,20 +564,22 @@ function* subscriptionInvoicesSagas() {
567
564
  function* loadInvoices() {
568
565
  yield effects.put(actions$3.setLoading(true));
569
566
  try {
570
- const invoices = yield effects.call(restApi.api.subscriptions.getSubscriptionInvoices);
567
+ const responseInvoices = yield effects.call(restApi.api.subscriptions.getSubscriptionInvoices);
568
+ const invoices = responseInvoices.map((invoice) => ({
569
+ id: invoice.id,
570
+ externalId: invoice.externalId,
571
+ subscriptionId: invoice.subscriptionId,
572
+ paymentDate: new Date(Date.parse(invoice.paymentDate)),
573
+ totalAmount: +((invoice.totalAmount || 0) / 100).toFixed(2),
574
+ currency: invoice.currency || 'usd',
575
+ paid: invoice.paid || false,
576
+ receiptNumber: invoice.receiptNumber,
577
+ }));
571
578
  yield effects.put(actions$3.setState({
572
- invoices: invoices.map((invoice) => ({
573
- id: invoice.id,
574
- externalId: invoice.externalId,
575
- subscriptionId: invoice.subscriptionId,
576
- paymentDate: new Date(Date.parse(invoice.paymentDate)),
577
- totalAmount: +((invoice.totalAmount || 0) / 100).toFixed(2),
578
- currency: invoice.currency || 'usd',
579
- paid: invoice.paid || false,
580
- receiptNumber: invoice.receiptNumber,
581
- })),
579
+ loading: false,
580
+ fetching: false,
581
+ invoices,
582
582
  }));
583
- yield effects.put(actions$3.setLoading(false));
584
583
  }
585
584
  catch (e) {
586
585
  yield effects.put(actions$3.setError(e.message));
@@ -608,7 +607,11 @@ function* loadInvoicesMock() {
608
607
  yield effects.put(actions$3.setLoading(true));
609
608
  yield effects.delay(500);
610
609
  const selectPlanTitle = 'Premium';
611
- yield effects.put(actions$3.setInvoices(invoicesMock.map((invoice) => (Object.assign(Object.assign({}, invoice), { selectedPlan: selectPlanTitle, paymentDate: new Date(Date.parse(invoice.paymentDate)), totalAmount: +((invoice.totalAmount || 0) / 100).toFixed(2) })))));
610
+ yield effects.put(actions$3.setState({
611
+ loading: false,
612
+ fetching: false,
613
+ invoices: invoicesMock.map((invoice) => (Object.assign(Object.assign({}, invoice), { selectedPlan: selectPlanTitle, paymentDate: new Date(Date.parse(invoice.paymentDate)), totalAmount: +((invoice.totalAmount || 0) / 100).toFixed(2) }))),
614
+ }));
612
615
  yield effects.put(actions$3.setLoading(false));
613
616
  }
614
617
  function* subscriptionInvoicesSagasMock() {
@@ -750,7 +753,7 @@ function* loadPlans() {
750
753
  yield effects.put(actions$7.setLoading(true));
751
754
  try {
752
755
  const products = yield effects.call(restApi.api.subscriptions.getSubscriptionPlans);
753
- yield effects.put(actions$7.setPlans(products.map((item) => {
756
+ const plans = products.map((item) => {
754
757
  var _a, _b;
755
758
  return ({
756
759
  id: item.id,
@@ -760,8 +763,12 @@ function* loadPlans() {
760
763
  currency: ((_b = item.price) === null || _b === void 0 ? void 0 : _b.currency) || 'usd',
761
764
  recurringInterval: 'month',
762
765
  });
763
- })));
764
- yield effects.put(actions$7.setLoading(false));
766
+ });
767
+ yield effects.put(actions$7.setState({
768
+ fetching: false,
769
+ loading: false,
770
+ plans,
771
+ }));
765
772
  }
766
773
  catch (e) {
767
774
  yield effects.put(actions$7.setError(e.message));
@@ -773,11 +780,14 @@ function* loadPlans() {
773
780
  function* loadPlansMock() {
774
781
  yield effects.put(actions$7.setLoading(true));
775
782
  yield effects.delay(500);
776
- yield effects.put(actions$7.setPlans(planResponseMock.map((item) => {
777
- var _a, _b;
778
- return (Object.assign(Object.assign({}, item), { price: +((((_a = item.price) === null || _a === void 0 ? void 0 : _a.amount) || 0) / 100).toFixed(2), currency: ((_b = item.price) === null || _b === void 0 ? void 0 : _b.currency) || 'usd', recurringInterval: 'month' }));
779
- })));
780
- yield effects.put(actions$7.setLoading(false));
783
+ yield effects.put(actions$7.setState({
784
+ fetching: false,
785
+ loading: false,
786
+ plans: planResponseMock.map((item) => {
787
+ var _a, _b;
788
+ return (Object.assign(Object.assign({}, item), { price: +((((_a = item.price) === null || _a === void 0 ? void 0 : _a.amount) || 0) / 100).toFixed(2), currency: ((_b = item.price) === null || _b === void 0 ? void 0 : _b.currency) || 'usd', recurringInterval: 'month' }));
789
+ }),
790
+ }));
781
791
  }
782
792
  function* plansSagasMock() {
783
793
  yield effects.takeEvery(actions$7.loadPlans, loadPlansMock);
@@ -814,6 +824,7 @@ function* loadStripePaymentConfiguration() {
814
824
  const response = yield effects.call(restApi.api.subscriptions.getStripePaymentProviderConfiguration);
815
825
  yield effects.put(actions$6.setState({
816
826
  loading: false,
827
+ fetching: false,
817
828
  config: {
818
829
  paymentProvider: exports.PaymentProvider.STRIPE,
819
830
  apiKey: response.publishableKey
@@ -832,6 +843,7 @@ function* loadPaymentConfigurationMock() {
832
843
  yield effects.delay(500);
833
844
  yield effects.put(actions$6.setState({
834
845
  loading: false,
846
+ fetching: false,
835
847
  config: {
836
848
  paymentProvider: exports.PaymentProvider.STRIPE,
837
849
  apiKey: ''
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@frontegg/redux-store",
3
3
  "libName": "FronteggReduxStore",
4
- "version": "5.9.1",
4
+ "version": "5.13.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.49",
10
+ "@frontegg/rest-api": "2.10.50",
11
11
  "@reduxjs/toolkit": "^1.5.0",
12
12
  "redux-saga": "^1.1.0",
13
13
  "tslib": "^2.3.1",
@@ -2,6 +2,7 @@ import { Plan, Subscription } from '../../general.interfaces';
2
2
  export interface BillingInformationState {
3
3
  loading: boolean;
4
4
  error: string | null;
5
+ fetching: boolean;
5
6
  externallyManaged: boolean;
6
7
  defaultPlanId: string | null;
7
8
  subscription?: Subscription;
@@ -1,9 +1,7 @@
1
1
  import { DownloadInvoiceActionPayload, InvoicesState } from './interfaces';
2
- import { Invoice } from '../../general.interfaces';
3
2
  export declare const initialInvoicesState: InvoicesState;
4
3
  declare const reducer: import("redux").Reducer<InvoicesState, import("redux").AnyAction>;
5
4
  declare const actions: {
6
- setInvoices: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Invoice[]], Invoice[], string, never, never>;
7
5
  setInvoiceDownloadState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[{
8
6
  loading: boolean;
9
7
  error: string | null;
@@ -2,6 +2,7 @@ import { Invoice } from '../../general.interfaces';
2
2
  export interface InvoicesState {
3
3
  loading: boolean;
4
4
  error: string | null;
5
+ fetching: boolean;
5
6
  invoices: Invoice[];
6
7
  invoiceDownload: {
7
8
  loading: boolean;
@@ -14,6 +14,7 @@ export declare type PaymentMethod = {
14
14
  export interface PaymentMethodState {
15
15
  loading: boolean;
16
16
  error: string | null;
17
+ fetching: boolean;
17
18
  paymentMethod?: PaymentMethod;
18
19
  }
19
20
  export interface PaymentMethodActions {
@@ -3,7 +3,6 @@ import { BillingState } from './interfaces';
3
3
  export declare const billingInitialState: BillingState;
4
4
  export declare const billingActions: {
5
5
  invoices: {
6
- setInvoices: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("..").Invoice[]], import("..").Invoice[], string, never, never>;
7
6
  setInvoiceDownloadState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[{
8
7
  loading: boolean;
9
8
  error: string | null;
@@ -7,6 +7,7 @@ declare type PaymentProviderCustomConfig = StripePaymentProviderConfig;
7
7
  export declare type PaymentProviderConfigState = {
8
8
  loading: boolean;
9
9
  error: string | null;
10
+ fetching: boolean;
10
11
  config: PaymentProviderCustomConfig | null;
11
12
  };
12
13
  export interface PaymentProviderConfigActions {
@@ -1,9 +1,7 @@
1
1
  import { PlansState } from './interfaces';
2
- import { Plan } from '../general.interfaces';
3
2
  export declare const plansInitialState: PlansState;
4
3
  declare const reducer: import("redux").Reducer<PlansState, import("redux").AnyAction>;
5
4
  declare const actions: {
6
- setPlans: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Plan[]], Plan[], string, never, never>;
7
5
  setLoading: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[boolean], boolean, string, never, never>;
8
6
  setError: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[string | null], string | null, string, never, never>;
9
7
  setState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<PlansState>], Partial<PlansState>, string, never, never>;
@@ -2,6 +2,7 @@ import { Plan } from '../general.interfaces';
2
2
  export interface PlansState {
3
3
  loading: boolean;
4
4
  error: string | null;
5
+ fetching: boolean;
5
6
  plans: Plan[];
6
7
  }
7
8
  export interface PlansActions {
@@ -22,7 +22,6 @@ declare const _default: {
22
22
  };
23
23
  billing: {
24
24
  invoices: {
25
- setInvoices: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("./general.interfaces").Invoice[]], import("./general.interfaces").Invoice[], string, never, never>;
26
25
  setInvoiceDownloadState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[{
27
26
  loading: boolean;
28
27
  error: string | null;
@@ -65,7 +64,6 @@ declare const _default: {
65
64
  };
66
65
  };
67
66
  plans: {
68
- setPlans: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("./general.interfaces").Plan[]], import("./general.interfaces").Plan[], string, never, never>;
69
67
  setLoading: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[boolean], boolean, string, never, never>;
70
68
  setError: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[string | null], string | null, string, never, never>;
71
69
  setState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<import("./interfaces").PlansState>], Partial<import("./interfaces").PlansState>, string, never, never>;
@@ -12,7 +12,7 @@ function createModuleCaseReducers() {
12
12
  },
13
13
  setError: {
14
14
  prepare: (payload) => ({ payload }),
15
- reducer: (state, action) => (Object.assign(Object.assign({}, state), { error: action.payload, loading: false })),
15
+ reducer: (state, action) => (Object.assign(Object.assign({}, state), { error: action.payload, loading: false, fetching: false })),
16
16
  },
17
17
  setState: {
18
18
  prepare: (payload) => ({ payload }),
@@ -36,25 +36,24 @@ function createKeyCaseErrorReducer(key) {
36
36
  const plansInitialState = {
37
37
  loading: false,
38
38
  error: null,
39
+ fetching: true,
39
40
  plans: [],
40
41
  };
41
42
  const { actions: sliceActions$1, reducer: reducer$7, name: name$6 } = createSlice({
42
43
  name: `${subscriptionsStoreName}/plans`,
43
44
  initialState: plansInitialState,
44
- reducers: Object.assign(Object.assign({}, createModuleCaseReducers()), { setPlans: {
45
- prepare: (payload) => ({ payload }),
46
- reducer: (state, action) => (Object.assign(Object.assign({}, state), { plans: action.payload })),
47
- } }),
45
+ reducers: Object.assign({}, createModuleCaseReducers()),
48
46
  });
49
47
  const actions$7 = Object.assign({ loadPlans: createAction(`${name$6}/loadPlans`) }, sliceActions$1);
50
48
 
51
49
  const configInitialState = {
52
50
  loading: false,
53
51
  error: null,
52
+ fetching: true,
54
53
  config: null,
55
54
  };
56
55
  const reducers$5 = Object.assign({}, createModuleCaseReducers());
57
- const { actions: configActions, reducer: reducer$6, name: name$5 } = createSlice({
56
+ const { actions: configActions, reducer: reducer$6, name: name$5, } = createSlice({
58
57
  name: `${subscriptionsStoreName}/config`,
59
58
  initialState: configInitialState,
60
59
  reducers: reducers$5,
@@ -64,6 +63,7 @@ const actions$6 = Object.assign({ loadPaymentConfiguration: createAction(`${name
64
63
  const initialBillingInformationState = {
65
64
  loading: false,
66
65
  error: null,
66
+ fetching: true,
67
67
  externallyManaged: false,
68
68
  defaultPlanId: null,
69
69
  cancellation: {
@@ -89,12 +89,13 @@ const actions$5 = Object.assign({ loadBillingInformation: createAction(`${name$4
89
89
  const initialPaymentMethodState = {
90
90
  loading: false,
91
91
  error: null,
92
+ fetching: true,
92
93
  };
93
94
  const reducers$3 = Object.assign(Object.assign({}, createModuleCaseReducers()), { setState: {
94
95
  prepare: (payload) => ({ payload }),
95
96
  reducer: (state, action) => (Object.assign(Object.assign({}, state), action.payload)),
96
97
  } });
97
- const { reducer: reducer$4, actions: paymentActions, name: name$3 } = createSlice({
98
+ const { reducer: reducer$4, actions: paymentActions, name: name$3, } = createSlice({
98
99
  name: `${subscriptionsStoreName}/billing/payment`,
99
100
  initialState: initialPaymentMethodState,
100
101
  reducers: reducers$3,
@@ -104,16 +105,14 @@ const actions$4 = Object.assign({ loadPaymentMethod: createAction(`${name$3}/loa
104
105
  const initialInvoicesState = {
105
106
  loading: false,
106
107
  error: null,
108
+ fetching: true,
107
109
  invoices: [],
108
110
  invoiceDownload: {
109
111
  loading: false,
110
112
  error: null
111
113
  }
112
114
  };
113
- const reducers$2 = Object.assign(Object.assign({}, createModuleCaseReducers()), { setInvoices: {
114
- prepare: (payload) => ({ payload }),
115
- reducer: (state, action) => (Object.assign(Object.assign({}, state), { invoices: action.payload })),
116
- }, setInvoiceDownloadState: {
115
+ const reducers$2 = Object.assign(Object.assign({}, createModuleCaseReducers()), { setInvoiceDownloadState: {
117
116
  prepare: (payload) => ({ payload }),
118
117
  reducer: (state, action) => (Object.assign(Object.assign({}, state), { invoiceDownload: Object.assign(Object.assign({}, state.invoiceDownload), action.payload) })),
119
118
  } });
@@ -372,7 +371,7 @@ function* loadSummaries(tenantId) {
372
371
  const { currentPlanId, subscriptionId, externallyManaged, defaultPlanId } = yield call(api.subscriptions.getSubscriptionSummaries, tenantId);
373
372
  const subscriptionResponse = yield call(api.subscriptions.getSubscription, subscriptionId);
374
373
  const planResponse = yield call(api.subscriptions.getSubscriptionPlan, currentPlanId);
375
- yield put(actions$5.setBillingInformation(Object.assign(Object.assign({ loading: false, externallyManaged,
374
+ yield put(actions$5.setBillingInformation(Object.assign(Object.assign({ loading: false, fetching: false, externallyManaged,
376
375
  defaultPlanId }, (subscriptionResponse
377
376
  ? {
378
377
  subscription: {
@@ -476,6 +475,7 @@ function* loadSummariesMock() {
476
475
  yield delay(500);
477
476
  yield put(actions$5.setBillingInformation({
478
477
  loading: false,
478
+ fetching: false,
479
479
  externallyManaged: false,
480
480
  subscription: Object.assign(Object.assign({}, subscriptionResponseMock), { startDate: new Date(subscriptionResponseMock.startDate), currentPeriodStart: new Date(subscriptionResponseMock.currentPeriodStart), currentPeriodEnd: new Date(subscriptionResponseMock.currentPeriodEnd), status: toSubscriptionStatus(subscriptionResponseMock.status), cancellation: subscriptionResponseMock.cancellation && toSubscriptionCancellation(subscriptionResponseMock.cancellation), items: subscriptionResponseMock.items }),
481
481
  plan: Object.assign(Object.assign({}, planResponseMock[0]), { price: toPrice((_a = planResponseMock[0].price) === null || _a === void 0 ? void 0 : _a.amount), currency: (_b = planResponseMock[0].price) === null || _b === void 0 ? void 0 : _b.currency, recurringInterval: 'month' }),
@@ -498,15 +498,11 @@ function* loadPaymentMethod() {
498
498
  try {
499
499
  const paymentMethods = yield call(api.subscriptions.getPaymentMethods);
500
500
  const paymentMethod = paymentMethods[0];
501
- if (paymentMethod) {
502
- yield put(actions$4.setState({
503
- paymentMethod,
504
- loading: false,
505
- }));
506
- }
507
- else {
508
- yield put(actions$4.setLoading(false));
509
- }
501
+ yield put(actions$4.setState({
502
+ paymentMethod,
503
+ loading: false,
504
+ fetching: false,
505
+ }));
510
506
  }
511
507
  catch (e) {
512
508
  yield put(actions$4.setError(e.message));
@@ -550,6 +546,7 @@ function* loadPaymentMethodMock() {
550
546
  yield put(actions$4.setState({
551
547
  paymentMethod,
552
548
  loading: false,
549
+ fetching: false,
553
550
  }));
554
551
  }
555
552
  function* subscriptionsPaymentMethodSagasMock() {
@@ -564,20 +561,22 @@ function* subscriptionInvoicesSagas() {
564
561
  function* loadInvoices() {
565
562
  yield put(actions$3.setLoading(true));
566
563
  try {
567
- const invoices = yield call(api.subscriptions.getSubscriptionInvoices);
564
+ const responseInvoices = yield call(api.subscriptions.getSubscriptionInvoices);
565
+ const invoices = responseInvoices.map((invoice) => ({
566
+ id: invoice.id,
567
+ externalId: invoice.externalId,
568
+ subscriptionId: invoice.subscriptionId,
569
+ paymentDate: new Date(Date.parse(invoice.paymentDate)),
570
+ totalAmount: +((invoice.totalAmount || 0) / 100).toFixed(2),
571
+ currency: invoice.currency || 'usd',
572
+ paid: invoice.paid || false,
573
+ receiptNumber: invoice.receiptNumber,
574
+ }));
568
575
  yield put(actions$3.setState({
569
- invoices: invoices.map((invoice) => ({
570
- id: invoice.id,
571
- externalId: invoice.externalId,
572
- subscriptionId: invoice.subscriptionId,
573
- paymentDate: new Date(Date.parse(invoice.paymentDate)),
574
- totalAmount: +((invoice.totalAmount || 0) / 100).toFixed(2),
575
- currency: invoice.currency || 'usd',
576
- paid: invoice.paid || false,
577
- receiptNumber: invoice.receiptNumber,
578
- })),
576
+ loading: false,
577
+ fetching: false,
578
+ invoices,
579
579
  }));
580
- yield put(actions$3.setLoading(false));
581
580
  }
582
581
  catch (e) {
583
582
  yield put(actions$3.setError(e.message));
@@ -605,7 +604,11 @@ function* loadInvoicesMock() {
605
604
  yield put(actions$3.setLoading(true));
606
605
  yield delay(500);
607
606
  const selectPlanTitle = 'Premium';
608
- yield put(actions$3.setInvoices(invoicesMock.map((invoice) => (Object.assign(Object.assign({}, invoice), { selectedPlan: selectPlanTitle, paymentDate: new Date(Date.parse(invoice.paymentDate)), totalAmount: +((invoice.totalAmount || 0) / 100).toFixed(2) })))));
607
+ yield put(actions$3.setState({
608
+ loading: false,
609
+ fetching: false,
610
+ invoices: invoicesMock.map((invoice) => (Object.assign(Object.assign({}, invoice), { selectedPlan: selectPlanTitle, paymentDate: new Date(Date.parse(invoice.paymentDate)), totalAmount: +((invoice.totalAmount || 0) / 100).toFixed(2) }))),
611
+ }));
609
612
  yield put(actions$3.setLoading(false));
610
613
  }
611
614
  function* subscriptionInvoicesSagasMock() {
@@ -747,7 +750,7 @@ function* loadPlans() {
747
750
  yield put(actions$7.setLoading(true));
748
751
  try {
749
752
  const products = yield call(api.subscriptions.getSubscriptionPlans);
750
- yield put(actions$7.setPlans(products.map((item) => {
753
+ const plans = products.map((item) => {
751
754
  var _a, _b;
752
755
  return ({
753
756
  id: item.id,
@@ -757,8 +760,12 @@ function* loadPlans() {
757
760
  currency: ((_b = item.price) === null || _b === void 0 ? void 0 : _b.currency) || 'usd',
758
761
  recurringInterval: 'month',
759
762
  });
760
- })));
761
- yield put(actions$7.setLoading(false));
763
+ });
764
+ yield put(actions$7.setState({
765
+ fetching: false,
766
+ loading: false,
767
+ plans,
768
+ }));
762
769
  }
763
770
  catch (e) {
764
771
  yield put(actions$7.setError(e.message));
@@ -770,11 +777,14 @@ function* loadPlans() {
770
777
  function* loadPlansMock() {
771
778
  yield put(actions$7.setLoading(true));
772
779
  yield delay(500);
773
- yield put(actions$7.setPlans(planResponseMock.map((item) => {
774
- var _a, _b;
775
- return (Object.assign(Object.assign({}, item), { price: +((((_a = item.price) === null || _a === void 0 ? void 0 : _a.amount) || 0) / 100).toFixed(2), currency: ((_b = item.price) === null || _b === void 0 ? void 0 : _b.currency) || 'usd', recurringInterval: 'month' }));
776
- })));
777
- yield put(actions$7.setLoading(false));
780
+ yield put(actions$7.setState({
781
+ fetching: false,
782
+ loading: false,
783
+ plans: planResponseMock.map((item) => {
784
+ var _a, _b;
785
+ return (Object.assign(Object.assign({}, item), { price: +((((_a = item.price) === null || _a === void 0 ? void 0 : _a.amount) || 0) / 100).toFixed(2), currency: ((_b = item.price) === null || _b === void 0 ? void 0 : _b.currency) || 'usd', recurringInterval: 'month' }));
786
+ }),
787
+ }));
778
788
  }
779
789
  function* plansSagasMock() {
780
790
  yield takeEvery(actions$7.loadPlans, loadPlansMock);
@@ -811,6 +821,7 @@ function* loadStripePaymentConfiguration() {
811
821
  const response = yield call(api.subscriptions.getStripePaymentProviderConfiguration);
812
822
  yield put(actions$6.setState({
813
823
  loading: false,
824
+ fetching: false,
814
825
  config: {
815
826
  paymentProvider: PaymentProvider.STRIPE,
816
827
  apiKey: response.publishableKey
@@ -829,6 +840,7 @@ function* loadPaymentConfigurationMock() {
829
840
  yield delay(500);
830
841
  yield put(actions$6.setState({
831
842
  loading: false,
843
+ fetching: false,
832
844
  config: {
833
845
  paymentProvider: PaymentProvider.STRIPE,
834
846
  apiKey: ''
@@ -10,7 +10,6 @@ declare const actions: {
10
10
  };
11
11
  billing: {
12
12
  invoices: {
13
- setInvoices: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("./general.interfaces").Invoice[]], import("./general.interfaces").Invoice[], string, never, never>;
14
13
  setInvoiceDownloadState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[{
15
14
  loading: boolean;
16
15
  error: string | null;
@@ -53,7 +52,6 @@ declare const actions: {
53
52
  };
54
53
  };
55
54
  plans: {
56
- setPlans: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("./general.interfaces").Plan[]], import("./general.interfaces").Plan[], string, never, never>;
57
55
  setLoading: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[boolean], boolean, string, never, never>;
58
56
  setError: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[string | null], string | null, string, never, never>;
59
57
  setState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<import("./interfaces").PlansState>], Partial<import("./interfaces").PlansState>, string, never, never>;
@@ -1,6 +1,7 @@
1
1
  import { AnyAction, PayloadAction } from '@reduxjs/toolkit';
2
2
  export interface ModuleCaseState {
3
3
  loading: boolean;
4
+ fetching: boolean;
4
5
  error: string | null;
5
6
  }
6
7
  export declare type ModuleCaseActions = {
@@ -24,6 +25,7 @@ export declare function createModuleCaseReducers<State>(): {
24
25
  reducer: (state: State, action: PayloadAction<string | null>) => State & {
25
26
  error: string | null;
26
27
  loading: boolean;
28
+ fetching: boolean;
27
29
  };
28
30
  };
29
31
  setState: {