From 6fe4f62fddbca2aabd5d8f7f8fdf3dd8a34c7005 Mon Sep 17 00:00:00 2001 From: julianajlk Date: Tue, 30 Jul 2024 10:43:41 -0400 Subject: [PATCH] fix: Remove ManageSubscriptionsPage used from Program Details page --- src/index.jsx | 8 -- src/subscriptions/ManageSubscriptionsPage.jsx | 81 ------------------- .../ManageSubscriptionsPage.messages.js | 17 ---- .../ManageSubscriptionsPage.test.jsx | 64 --------------- src/subscriptions/index.js | 2 - 5 files changed, 172 deletions(-) delete mode 100644 src/subscriptions/ManageSubscriptionsPage.jsx delete mode 100644 src/subscriptions/ManageSubscriptionsPage.messages.js delete mode 100644 src/subscriptions/ManageSubscriptionsPage.test.jsx diff --git a/src/index.jsx b/src/index.jsx index ff282888..f825f7fd 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -9,7 +9,6 @@ import { APP_READY, initialize, subscribe, - getConfig, mergeConfig, } from '@edx/frontend-platform'; @@ -20,7 +19,6 @@ import messages from './i18n'; import configureStore from './store'; import { NotFoundPage } from './components'; import { OrdersAndSubscriptionsPage } from './orders-and-subscriptions'; -import { ManageSubscriptionsPage } from './subscriptions'; import './index.scss'; @@ -52,12 +50,6 @@ subscribe(APP_READY, () => {
- {getConfig().ENABLE_B2C_SUBSCRIPTIONS?.toLowerCase() === 'true' ? ( - } - /> - ) : null} } /> } /> } /> diff --git a/src/subscriptions/ManageSubscriptionsPage.jsx b/src/subscriptions/ManageSubscriptionsPage.jsx deleted file mode 100644 index 858684a7..00000000 --- a/src/subscriptions/ManageSubscriptionsPage.jsx +++ /dev/null @@ -1,81 +0,0 @@ -import React, { useEffect } from 'react'; -import { useDispatch, useSelector } from 'react-redux'; -import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n'; -import { Button } from '@edx/paragon'; - -import { PageLoading, SupportLink } from '../components'; - -import { fetchStripeCustomerPortalURL } from './actions'; -import { subscriptionsSelector } from './selectors'; -import messages from './ManageSubscriptionsPage.messages'; - -const ManageSubscriptionsPage = () => { - const { formatMessage } = useIntl(); - const dispatch = useDispatch(); - const { stripeCustomerPortalURL, stripeError } = useSelector( - subscriptionsSelector, - ); - - const buttonLabel = formatMessage( - messages['ecommerce.order.history.manage.subscriptions.button'], - ); - - useEffect(() => { - dispatch(fetchStripeCustomerPortalURL()); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - useEffect(() => { - if (stripeCustomerPortalURL) { - window.location.href = stripeCustomerPortalURL; - } - }, [stripeCustomerPortalURL]); - - const renderLoading = () => ( - - ); - - const renderError = () => ( -
-
- - {(text) =>

{text}

} -
- {buttonLabel}, - }} - > - {(text) =>

{text}

} -
- , - }} - /> - -
-
- ); - - return stripeError ? renderError() : renderLoading(); -}; - -export default ManageSubscriptionsPage; diff --git a/src/subscriptions/ManageSubscriptionsPage.messages.js b/src/subscriptions/ManageSubscriptionsPage.messages.js deleted file mode 100644 index d15e030b..00000000 --- a/src/subscriptions/ManageSubscriptionsPage.messages.js +++ /dev/null @@ -1,17 +0,0 @@ -import { defineMessages } from '@edx/frontend-platform/i18n'; - -const messages = defineMessages({ - 'ecommerce.order.history.manage.subscriptions.button': { - id: 'ecommerce.order.history.manage.subscriptions.button', - defaultMessage: 'Orders and subscriptions', - description: - 'Button label to navigate to the orders and subscriptions page.', - }, - 'ecommerce.order.history.manage.subscriptions.loading': { - id: 'ecommerce.order.history.manage.subscriptions.loading', - defaultMessage: 'Loading manage subscriptions...', - description: 'Message when loading the manage subscriptions page.', - }, -}); - -export default messages; diff --git a/src/subscriptions/ManageSubscriptionsPage.test.jsx b/src/subscriptions/ManageSubscriptionsPage.test.jsx deleted file mode 100644 index f00f7ec4..00000000 --- a/src/subscriptions/ManageSubscriptionsPage.test.jsx +++ /dev/null @@ -1,64 +0,0 @@ -/* eslint-disable global-require */ -import React from 'react'; -import { act, render, screen } from '../testing'; - -import ManageSubscriptionsPage from './ManageSubscriptionsPage'; - -const storeMocks = require('../store/__mocks__/mockEmptyStore'); - -const { getByText, getAllByText } = screen; - -describe('', () => { - describe('Renders correctly in various states', () => { - it('navigates when url is fetched correctly', () => { - const storeMocksWithURL = { - ...storeMocks, - subscriptions: { - ...storeMocks.subscriptions, - stripeCustomerPortalURL: 'http://edx.org', - }, - }; - - const mockHrefSetter = jest.fn(); - delete window.location; - window.location = { - ...window.location, - set href(url) { - mockHrefSetter(url); - }, - }; - - jest.useFakeTimers(); - - render(, storeMocksWithURL); - - act(() => { - jest.runAllTimers(); - }); - expect(mockHrefSetter).toHaveBeenCalledWith('http://edx.org'); - expect(getByText('Loading manage subscriptions...')).toBeInTheDocument(); - }); - - it('renders loading when url is being fetched', () => { - render(, storeMocks); - - expect(getByText('Loading manage subscriptions...')).toBeInTheDocument(); - }); - - it('renders error ui when fetching url fails', () => { - const storeMocksWithError = { - ...storeMocks, - subscriptions: { - ...storeMocks.subscriptions, - stripeError: true, - }, - }; - - render(, storeMocksWithError); - - expect(getByText('Something went wrong')).toBeInTheDocument(); - expect(getByText('contact support')).toBeInTheDocument(); - expect(getAllByText('Orders and subscriptions')).toHaveLength(2); - }); - }); -}); diff --git a/src/subscriptions/index.js b/src/subscriptions/index.js index d9aeb95a..b51acb36 100644 --- a/src/subscriptions/index.js +++ b/src/subscriptions/index.js @@ -1,5 +1,4 @@ import Subscriptions from './Subscriptions'; -import ManageSubscriptionsPage from './ManageSubscriptionsPage'; import { fetchSubscriptions } from './actions'; import reducer from './reducer'; import saga from './saga'; @@ -11,5 +10,4 @@ export { reducer, saga, storeName, - ManageSubscriptionsPage, };