@frontegg/redux-store 5.29.0 → 5.30.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.
@@ -666,18 +666,6 @@ function* checkoutSagas() {
666
666
  yield effects.takeEvery(actions$3.errorCheckout, errorCheckout);
667
667
  }
668
668
  function* checkoutPlan({ payload: planId }) {
669
- const { subscription, summary } = yield effects.select((state) => state.subscriptions.billing.information);
670
- const isTrialing = (subscription === null || subscription === void 0 ? void 0 : subscription.trialEnd) || (subscription === null || subscription === void 0 ? void 0 : subscription.status) === exports.SubscriptionStatus.TRIALING;
671
- const hasPaymentMethod = !!(summary === null || summary === void 0 ? void 0 : summary.paymentMethodId);
672
- if (isTrialing && hasPaymentMethod) {
673
- yield effects.put(actions$3.setState({
674
- checkoutPlanId: null,
675
- loading: false,
676
- status: exports.CheckoutStatus.CONFIRM,
677
- }));
678
- yield effects.put(actions$3.checkoutEvent(exports.CheckoutEvent.CONFIRMED));
679
- return;
680
- }
681
669
  yield effects.put(actions$3.setState({
682
670
  checkoutPlanId: planId,
683
671
  loading: false,
@@ -693,18 +681,29 @@ function* resetCheckout() {
693
681
  }));
694
682
  }
695
683
  function* confirmPlan({ payload: paymentMethodId }) {
696
- const { subscription, status, planId } = yield effects.select(({ subscriptions: { billing: { information }, checkout, }, }) => ({
697
- subscription: information.subscription,
698
- status: checkout.status,
699
- planId: checkout.checkoutPlanId,
684
+ const { checkout: { status, checkoutPlanId, }, subscription, summary } = yield effects.select(({ subscriptions: { billing: { information: { summary, subscription } }, checkout, }, }) => ({
685
+ subscription,
686
+ summary,
687
+ checkout,
700
688
  }));
701
- if (!planId || !subscription) {
689
+ const isTrialing = (subscription === null || subscription === void 0 ? void 0 : subscription.trialEnd) || (subscription === null || subscription === void 0 ? void 0 : subscription.status) === exports.SubscriptionStatus.TRIALING;
690
+ const hasPaymentMethod = !!(summary === null || summary === void 0 ? void 0 : summary.paymentMethodId);
691
+ if (!checkoutPlanId || !subscription) {
702
692
  yield effects.put(actions$3.setState({
703
693
  loading: false,
704
694
  status: exports.CheckoutStatus.ERROR,
705
695
  }));
706
696
  return;
707
697
  }
698
+ if (isTrialing && hasPaymentMethod) {
699
+ yield effects.put(actions$3.setState({
700
+ checkoutPlanId: null,
701
+ loading: false,
702
+ status: exports.CheckoutStatus.CONFIRM,
703
+ }));
704
+ yield effects.put(actions$3.checkoutEvent(exports.CheckoutEvent.CONFIRMED));
705
+ return;
706
+ }
708
707
  if (status === exports.CheckoutStatus.CHECKOUT) {
709
708
  yield effects.put(actions$3.setState({
710
709
  loading: true,
@@ -713,7 +712,7 @@ function* confirmPlan({ payload: paymentMethodId }) {
713
712
  try {
714
713
  yield effects.call(restApi.api.subscriptions.updateManagedSubscription, subscription.id, {
715
714
  paymentMethodId,
716
- planId,
715
+ planId: checkoutPlanId,
717
716
  });
718
717
  yield effects.put(actions$3.setState({
719
718
  checkoutPlanId: null,
@@ -787,7 +786,7 @@ function* loadPlans() {
787
786
  id: item.id,
788
787
  name: item.name,
789
788
  description: item.description,
790
- price: +((((_a = item.price) === null || _a === void 0 ? void 0 : _a.amount) || 0) / 100).toFixed(2),
789
+ price: ((_a = item.price) === null || _a === void 0 ? void 0 : _a.amount) || 0,
791
790
  currency: ((_b = item.price) === null || _b === void 0 ? void 0 : _b.currency) || 'usd',
792
791
  recurringInterval: 'month',
793
792
  });
@@ -813,7 +812,7 @@ function* loadPlansMock() {
813
812
  loading: false,
814
813
  plans: planResponseMock.map((item) => {
815
814
  var _a, _b;
816
- 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' }));
815
+ return (Object.assign(Object.assign({}, item), { price: ((_a = item.price) === null || _a === void 0 ? void 0 : _a.amount) || 0, currency: ((_b = item.price) === null || _b === void 0 ? void 0 : _b.currency) || 'usd', recurringInterval: 'month' }));
817
816
  }),
818
817
  }));
819
818
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@frontegg/redux-store",
3
3
  "libName": "FronteggReduxStore",
4
- "version": "5.29.0",
4
+ "version": "5.30.0",
5
5
  "author": "Frontegg LTD",
6
6
  "main": "./node/index.js",
7
7
  "module": "./index.js",
@@ -663,18 +663,6 @@ function* checkoutSagas() {
663
663
  yield takeEvery(actions$3.errorCheckout, errorCheckout);
664
664
  }
665
665
  function* checkoutPlan({ payload: planId }) {
666
- const { subscription, summary } = yield select((state) => state.subscriptions.billing.information);
667
- const isTrialing = (subscription === null || subscription === void 0 ? void 0 : subscription.trialEnd) || (subscription === null || subscription === void 0 ? void 0 : subscription.status) === SubscriptionStatus.TRIALING;
668
- const hasPaymentMethod = !!(summary === null || summary === void 0 ? void 0 : summary.paymentMethodId);
669
- if (isTrialing && hasPaymentMethod) {
670
- yield put(actions$3.setState({
671
- checkoutPlanId: null,
672
- loading: false,
673
- status: CheckoutStatus.CONFIRM,
674
- }));
675
- yield put(actions$3.checkoutEvent(CheckoutEvent.CONFIRMED));
676
- return;
677
- }
678
666
  yield put(actions$3.setState({
679
667
  checkoutPlanId: planId,
680
668
  loading: false,
@@ -690,18 +678,29 @@ function* resetCheckout() {
690
678
  }));
691
679
  }
692
680
  function* confirmPlan({ payload: paymentMethodId }) {
693
- const { subscription, status, planId } = yield select(({ subscriptions: { billing: { information }, checkout, }, }) => ({
694
- subscription: information.subscription,
695
- status: checkout.status,
696
- planId: checkout.checkoutPlanId,
681
+ const { checkout: { status, checkoutPlanId, }, subscription, summary } = yield select(({ subscriptions: { billing: { information: { summary, subscription } }, checkout, }, }) => ({
682
+ subscription,
683
+ summary,
684
+ checkout,
697
685
  }));
698
- if (!planId || !subscription) {
686
+ const isTrialing = (subscription === null || subscription === void 0 ? void 0 : subscription.trialEnd) || (subscription === null || subscription === void 0 ? void 0 : subscription.status) === SubscriptionStatus.TRIALING;
687
+ const hasPaymentMethod = !!(summary === null || summary === void 0 ? void 0 : summary.paymentMethodId);
688
+ if (!checkoutPlanId || !subscription) {
699
689
  yield put(actions$3.setState({
700
690
  loading: false,
701
691
  status: CheckoutStatus.ERROR,
702
692
  }));
703
693
  return;
704
694
  }
695
+ if (isTrialing && hasPaymentMethod) {
696
+ yield put(actions$3.setState({
697
+ checkoutPlanId: null,
698
+ loading: false,
699
+ status: CheckoutStatus.CONFIRM,
700
+ }));
701
+ yield put(actions$3.checkoutEvent(CheckoutEvent.CONFIRMED));
702
+ return;
703
+ }
705
704
  if (status === CheckoutStatus.CHECKOUT) {
706
705
  yield put(actions$3.setState({
707
706
  loading: true,
@@ -710,7 +709,7 @@ function* confirmPlan({ payload: paymentMethodId }) {
710
709
  try {
711
710
  yield call(api.subscriptions.updateManagedSubscription, subscription.id, {
712
711
  paymentMethodId,
713
- planId,
712
+ planId: checkoutPlanId,
714
713
  });
715
714
  yield put(actions$3.setState({
716
715
  checkoutPlanId: null,
@@ -784,7 +783,7 @@ function* loadPlans() {
784
783
  id: item.id,
785
784
  name: item.name,
786
785
  description: item.description,
787
- price: +((((_a = item.price) === null || _a === void 0 ? void 0 : _a.amount) || 0) / 100).toFixed(2),
786
+ price: ((_a = item.price) === null || _a === void 0 ? void 0 : _a.amount) || 0,
788
787
  currency: ((_b = item.price) === null || _b === void 0 ? void 0 : _b.currency) || 'usd',
789
788
  recurringInterval: 'month',
790
789
  });
@@ -810,7 +809,7 @@ function* loadPlansMock() {
810
809
  loading: false,
811
810
  plans: planResponseMock.map((item) => {
812
811
  var _a, _b;
813
- 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' }));
812
+ return (Object.assign(Object.assign({}, item), { price: ((_a = item.price) === null || _a === void 0 ? void 0 : _a.amount) || 0, currency: ((_b = item.price) === null || _b === void 0 ? void 0 : _b.currency) || 'usd', recurringInterval: 'month' }));
814
813
  }),
815
814
  }));
816
815
  }