Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit df6b6df

Browse files
committed
feat: add manage subscriptions url
1 parent 6de342e commit df6b6df

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

src/index.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
APP_READY,
1010
initialize,
1111
subscribe,
12+
getConfig,
1213
mergeConfig,
1314
} from '@edx/frontend-platform';
1415

@@ -19,6 +20,7 @@ import messages from './i18n';
1920
import configureStore from './store';
2021
import NotFoundPage from './components/NotFoundPage';
2122
import { OrdersAndSubscriptionsPage } from './orders-and-subscriptions';
23+
import { ManageSubscriptionsPage } from './subscriptions';
2224

2325
import './index.scss';
2426

@@ -39,6 +41,12 @@ subscribe(APP_READY, () => {
3941
<Header />
4042
<main>
4143
<Switch>
44+
{getConfig().ENABLE_B2C_SUBSCRIPTIONS === 'true' ? (
45+
<Route
46+
path="/manage-subscriptions"
47+
component={ManageSubscriptionsPage}
48+
/>
49+
) : null}
4250
<Route path="/orders" component={OrdersAndSubscriptionsPage} />
4351
<Route path="/notfound" component={NotFoundPage} />
4452
<Route path="*" component={NotFoundPage} />
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React, { useEffect } from 'react';
2+
import { useDispatch, useSelector } from 'react-redux';
3+
4+
import NotFoundPage from '../components/NotFoundPage';
5+
import { PageLoading } from '../common';
6+
import { fetchStripeCustomerPortalURL } from './actions';
7+
import { subscriptionsSelector } from './selectors';
8+
9+
const ManageSubscriptionsPage = () => {
10+
const dispatch = useDispatch();
11+
const { stripeCustomerPortalURL, stripeError, stripeLoading } = useSelector(
12+
subscriptionsSelector,
13+
);
14+
15+
useEffect(() => {
16+
dispatch(fetchStripeCustomerPortalURL());
17+
}, []);
18+
19+
useEffect(() => {
20+
if (stripeCustomerPortalURL) {
21+
window.location.href = stripeCustomerPortalURL;
22+
}
23+
}, [stripeCustomerPortalURL]);
24+
25+
return stripeError ? <NotFoundPage /> : <PageLoading />;
26+
};
27+
28+
export default ManageSubscriptionsPage;

src/subscriptions/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Subscriptions from './Subscriptions';
2+
import ManageSubscriptionsPage from './ManageSubscriptionsPage';
23
import { fetchSubscriptions } from './actions';
34
import reducer from './reducer';
45
import saga from './saga';
@@ -10,4 +11,5 @@ export {
1011
reducer,
1112
saga,
1213
storeName,
14+
ManageSubscriptionsPage,
1315
};

0 commit comments

Comments
 (0)