This repository was archived by the owner on Nov 4, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 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';
1920import configureStore from './store' ;
2021import NotFoundPage from './components/NotFoundPage' ;
2122import { OrdersAndSubscriptionsPage } from './orders-and-subscriptions' ;
23+ import { ManageSubscriptionsPage } from './subscriptions' ;
2224
2325import './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 } />
Original file line number Diff line number Diff line change 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 ;
Original file line number Diff line number Diff line change 11import Subscriptions from './Subscriptions' ;
2+ import ManageSubscriptionsPage from './ManageSubscriptionsPage' ;
23import { fetchSubscriptions } from './actions' ;
34import reducer from './reducer' ;
45import saga from './saga' ;
@@ -10,4 +11,5 @@ export {
1011 reducer ,
1112 saga ,
1213 storeName ,
14+ ManageSubscriptionsPage ,
1315} ;
You can’t perform that action at this time.
0 commit comments