Skip to content

Commit

Permalink
feat: add unauthorized page
Browse files Browse the repository at this point in the history
  • Loading branch information
AuraAlba committed Aug 29, 2024
1 parent 7e45aef commit 0c81204
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 23 deletions.
14 changes: 14 additions & 0 deletions src/features/Main/UnauthorizedPage/__test__/index.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import { render } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import UnauthorizedPage from 'features/Main/UnauthorizedPage';

import { unauthorizedText } from 'features/constants';

describe('Unauthorized Component', () => {
test('should render message', async () => {
const { container } = render(<UnauthorizedPage />);

expect(container).toHaveTextContent(unauthorizedText);
});
});
16 changes: 16 additions & 0 deletions src/features/Main/UnauthorizedPage/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';

import { Container } from '@edx/paragon';

import { unauthorizedText } from 'features/constants';

const UnauthorizedPage = () => (
<Container className="px-0 container-pages">
<Container size="md" className="p-4 my-4 page-content-container text-center font-weight-bold">
<p>{unauthorizedText}</p>
</Container>

</Container>
);

export default UnauthorizedPage;
52 changes: 29 additions & 23 deletions src/features/Main/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import InstructorsDetailPage from 'features/Instructors/InstructorsDetailPage';
import ActiveTabUpdater from 'features/Main//ActiveTabUpdater';
import ManageInstructors from 'features/Instructors/ManageInstructors';
import InstitutionSelector from 'features/Main/InstitutionSelector';
import UnauthorizedPage from 'features/Main/UnauthorizedPage';

import { fetchInstitutionData } from 'features/Main/data/thunks';
import { updateSelectedInstitution } from 'features/Main/data/slice';
Expand Down Expand Up @@ -81,29 +82,34 @@ const Main = () => {
<Header />
<div className="pageWrapper">
<main className="d-flex">
<Sidebar />
<Container className="px-0 container-pages">
<Container size="xl" className="px-4">
{institutions.length > 1 && (<InstitutionSelector />)}
</Container>
<Switch>
<Route exact path="/">
<Redirect to={addQueryParam('/dashboard')} />
</Route>
{routes.map(({ path, exact, component: Component }) => (
<Route
key={path}
path={path}
exact={exact}
render={() => (
<ActiveTabUpdater path={path}>
<Component />
</ActiveTabUpdater>
)}
/>
))}
</Switch>
</Container>
{institutions.length < 1 && <UnauthorizedPage />}
{institutions.length > 0 && (
<>
<Sidebar />
<Container className="px-0 container-pages">
<Container size="xl" className="px-4">
{institutions.length > 1 && (<InstitutionSelector />)}
</Container>
<Switch>
<Route exact path="/">
<Redirect to={addQueryParam('/dashboard')} />
</Route>
{routes.map(({ path, exact, component: Component }) => (
<Route
key={path}
path={path}
exact={exact}
render={() => (
<ActiveTabUpdater path={path}>
<Component />
</ActiveTabUpdater>
)}
/>
))}
</Switch>
</Container>
</>
)}
</main>
<Footer />
</div>
Expand Down
6 changes: 6 additions & 0 deletions src/features/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,9 @@ export const INSTITUTION_QUERY_ID = 'institutionId';
* @constant {string}
*/
export const cookieText = 'This website uses cookies to ensure you get the best experience on our website. If you continue browsing this site, we understand that you accept the use of cookies.';

/**
* Text for unauthorized user.
* @constant {string}
*/
export const unauthorizedText = 'You do not have access to CertPREP Manager. If you believe you should have access then please contact your sales rep.';

0 comments on commit 0c81204

Please sign in to comment.