@frontegg/redux-store 5.26.0 → 5.28.1
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
|
-
|
|
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.
|
|
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
|
|
397
|
+
defaultPlanId,
|
|
398
|
+
defaultPaymentId }, (subscriptionResponse
|
|
396
399
|
? {
|
|
397
400
|
subscription: {
|
|
398
401
|
id: subscriptionResponse.id,
|
|
@@ -439,7 +442,7 @@ function* cancelSubscription() {
|
|
|
439
442
|
if (isCancellable) {
|
|
440
443
|
try {
|
|
441
444
|
yield effects.put(actions$6.setCancellationLoading(true));
|
|
442
|
-
yield effects.call(restApi.api.subscriptions.
|
|
445
|
+
yield effects.call(restApi.api.subscriptions.cancelManagedSubscription, subscriptionId);
|
|
443
446
|
yield effects.put(actions$6.setBillingInformation({
|
|
444
447
|
subscription: Object.assign(Object.assign({}, overview.subscription), { cancellation: {
|
|
445
448
|
policy: exports.SubscriptionCancellationPolicy.AT_PERIOD_END,
|
|
@@ -466,7 +469,7 @@ function* renewSubscription() {
|
|
|
466
469
|
if (renewable) {
|
|
467
470
|
try {
|
|
468
471
|
yield effects.put(actions$6.setRenewalLoading(true));
|
|
469
|
-
yield effects.call(restApi.api.subscriptions.
|
|
472
|
+
yield effects.call(restApi.api.subscriptions.renewManagedSubscription, subscriptionId);
|
|
470
473
|
yield effects.put(actions$6.setBillingInformation({
|
|
471
474
|
subscription: Object.assign(Object.assign({}, overview.subscription), { cancellation: null }),
|
|
472
475
|
}));
|
|
@@ -692,9 +695,9 @@ function* confirmPlan({ payload: paymentMethodId }) {
|
|
|
692
695
|
error: null,
|
|
693
696
|
}));
|
|
694
697
|
try {
|
|
695
|
-
yield effects.call(restApi.api.subscriptions.
|
|
698
|
+
yield effects.call(restApi.api.subscriptions.updateManagedSubscription, subscription.id, {
|
|
696
699
|
paymentMethodId,
|
|
697
|
-
planId
|
|
700
|
+
planId
|
|
698
701
|
});
|
|
699
702
|
yield effects.put(actions$3.setState({
|
|
700
703
|
checkoutPlanId: null,
|
|
@@ -893,7 +896,7 @@ function* loadManagedSubscriptions() {
|
|
|
893
896
|
yield effects.put(actions$1.setState({
|
|
894
897
|
fetching: false,
|
|
895
898
|
loading: false,
|
|
896
|
-
managedSubscriptions,
|
|
899
|
+
managedSubscription: managedSubscriptions === null || managedSubscriptions === void 0 ? void 0 : managedSubscriptions[0],
|
|
897
900
|
}));
|
|
898
901
|
}
|
|
899
902
|
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.
|
|
4
|
+
"version": "5.28.1",
|
|
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.
|
|
10
|
+
"@frontegg/rest-api": "2.10.61",
|
|
11
11
|
"@reduxjs/toolkit": "^1.5.0",
|
|
12
12
|
"redux-saga": "^1.1.0",
|
|
13
13
|
"tslib": "^2.3.1",
|
|
@@ -3,7 +3,7 @@ export interface ManagedSubscriptionsState {
|
|
|
3
3
|
loading: boolean;
|
|
4
4
|
error: string | null;
|
|
5
5
|
fetching: boolean;
|
|
6
|
-
|
|
6
|
+
managedSubscription: ISubscriptionResponse | null;
|
|
7
7
|
}
|
|
8
8
|
export interface ManagedSubscriptionsActions {
|
|
9
9
|
loadManagedSubscriptions: () => void;
|
package/subscriptions/index.js
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
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
|
|
394
|
+
defaultPlanId,
|
|
395
|
+
defaultPaymentId }, (subscriptionResponse
|
|
393
396
|
? {
|
|
394
397
|
subscription: {
|
|
395
398
|
id: subscriptionResponse.id,
|
|
@@ -436,7 +439,7 @@ function* cancelSubscription() {
|
|
|
436
439
|
if (isCancellable) {
|
|
437
440
|
try {
|
|
438
441
|
yield put(actions$6.setCancellationLoading(true));
|
|
439
|
-
yield call(api.subscriptions.
|
|
442
|
+
yield call(api.subscriptions.cancelManagedSubscription, subscriptionId);
|
|
440
443
|
yield put(actions$6.setBillingInformation({
|
|
441
444
|
subscription: Object.assign(Object.assign({}, overview.subscription), { cancellation: {
|
|
442
445
|
policy: SubscriptionCancellationPolicy.AT_PERIOD_END,
|
|
@@ -463,7 +466,7 @@ function* renewSubscription() {
|
|
|
463
466
|
if (renewable) {
|
|
464
467
|
try {
|
|
465
468
|
yield put(actions$6.setRenewalLoading(true));
|
|
466
|
-
yield call(api.subscriptions.
|
|
469
|
+
yield call(api.subscriptions.renewManagedSubscription, subscriptionId);
|
|
467
470
|
yield put(actions$6.setBillingInformation({
|
|
468
471
|
subscription: Object.assign(Object.assign({}, overview.subscription), { cancellation: null }),
|
|
469
472
|
}));
|
|
@@ -689,9 +692,9 @@ function* confirmPlan({ payload: paymentMethodId }) {
|
|
|
689
692
|
error: null,
|
|
690
693
|
}));
|
|
691
694
|
try {
|
|
692
|
-
yield call(api.subscriptions.
|
|
695
|
+
yield call(api.subscriptions.updateManagedSubscription, subscription.id, {
|
|
693
696
|
paymentMethodId,
|
|
694
|
-
planId
|
|
697
|
+
planId
|
|
695
698
|
});
|
|
696
699
|
yield put(actions$3.setState({
|
|
697
700
|
checkoutPlanId: null,
|
|
@@ -890,7 +893,7 @@ function* loadManagedSubscriptions() {
|
|
|
890
893
|
yield put(actions$1.setState({
|
|
891
894
|
fetching: false,
|
|
892
895
|
loading: false,
|
|
893
|
-
managedSubscriptions,
|
|
896
|
+
managedSubscription: managedSubscriptions === null || managedSubscriptions === void 0 ? void 0 : managedSubscriptions[0],
|
|
894
897
|
}));
|
|
895
898
|
}
|
|
896
899
|
catch (e) {
|