Skip to content

Commit

Permalink
feat: replace local history with one from platform (#499)
Browse files Browse the repository at this point in the history
  • Loading branch information
binodpant authored Mar 12, 2021
1 parent e8ceffa commit 1eedef3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 48 deletions.
85 changes: 41 additions & 44 deletions src/components/App/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Switch, Router } from 'react-router-dom';
import { Switch } from 'react-router-dom';
import { Helmet } from 'react-helmet';

import { AuthenticatedPageRoute, PageRoute, AppProvider } from '@edx/frontend-platform/react';
Expand All @@ -16,55 +16,52 @@ import SupportPage from '../SupportPage';
import { ToastsProvider, Toasts } from '../Toasts';

import store from '../../data/store';
import history from '../../data/history';

const AppWrapper = () => {
const apiClient = getAuthenticatedHttpClient();
return (
<AppProvider store={store}>
<Router history={history}>
<ToastsProvider>
<Helmet
titleTemplate="%s - edX Admin Portal"
defaultTitle="edX Admin Portal"
<ToastsProvider>
<Helmet
titleTemplate="%s - edX Admin Portal"
defaultTitle="edX Admin Portal"
/>
<Toasts />
<Header />
<Switch>
<PageRoute exact path="/public/support" component={SupportPage} />
<AuthenticatedPageRoute
path="/enterprises"
render={(routerProps) => <EnterpriseIndexPage {...routerProps} />}
authenticatedAPIClient={apiClient}
redirect={`${process.env.BASE_URL}/enterprises`}
/>
<Toasts />
<Header />
<Switch>
<PageRoute exact path="/public/support" component={SupportPage} />
<AuthenticatedPageRoute
path="/enterprises"
render={(routerProps) => <EnterpriseIndexPage {...routerProps} />}
authenticatedAPIClient={apiClient}
redirect={`${process.env.BASE_URL}/enterprises`}
/>
<PageRoute
exact
path="/:enterpriseSlug/admin/register"
component={AdminRegisterPage}
/>
<PageRoute
exact
path="/:enterpriseSlug/admin/register/activate"
component={UserActivationPage}
/>
<AuthenticatedPageRoute
path="/:enterpriseSlug"
component={EnterpriseApp}
authenticatedAPIClient={apiClient}
redirect={process.env.BASE_URL}
/>
<AuthenticatedPageRoute
path="/"
render={(routerProps) => <EnterpriseIndexPage {...routerProps} />}
authenticatedAPIClient={apiClient}
redirect={process.env.BASE_URL}
/>
<PageRoute component={NotFoundPage} />
</Switch>
<Footer />
</ToastsProvider>
</Router>
<PageRoute
exact
path="/:enterpriseSlug/admin/register"
component={AdminRegisterPage}
/>
<PageRoute
exact
path="/:enterpriseSlug/admin/register/activate"
component={UserActivationPage}
/>
<AuthenticatedPageRoute
path="/:enterpriseSlug"
component={EnterpriseApp}
authenticatedAPIClient={apiClient}
redirect={process.env.BASE_URL}
/>
<AuthenticatedPageRoute
path="/"
render={(routerProps) => <EnterpriseIndexPage {...routerProps} />}
authenticatedAPIClient={apiClient}
redirect={process.env.BASE_URL}
/>
<PageRoute component={NotFoundPage} />
</Switch>
<Footer />
</ToastsProvider>
</AppProvider>
);
};
Expand Down
3 changes: 0 additions & 3 deletions src/data/history.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import isEmail from 'validator/lib/isEmail';
import isEmpty from 'validator/lib/isEmpty';
import isNumeric from 'validator/lib/isNumeric';

import { history } from '@edx/frontend-platform/initialize';
import { EMAIL_TEMPLATE_FIELD_MAX_LIMIT, OFFER_ASSIGNMENT_EMAIL_SUBJECT_LIMIT } from './data/constants/emailTemplate';
import { EMAIL_ADDRESS_TEXT_FORM_DATA, EMAIL_ADDRESS_CSV_FORM_DATA } from './data/constants/addUsers';
import { ENTERPRISE_ADMIN_ROLE_NAME } from './data/constants';
import history from './data/history';

const formatTimestamp = ({ timestamp, format = 'MMMM D, YYYY' }) => {
if (timestamp) {
Expand Down

0 comments on commit 1eedef3

Please sign in to comment.