Skip to content

Commit

Permalink
feat: route time
Browse files Browse the repository at this point in the history
  • Loading branch information
muselesscreator committed Sep 20, 2023
1 parent a031c1d commit eedae24
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 47 deletions.
33 changes: 28 additions & 5 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,46 @@ import { Routes, Route } from 'react-router-dom';
import { ErrorPage } from '@edx/frontend-platform/react';
import { useIntl } from '@edx/frontend-platform/i18n';

import AppContainer from 'views/AppContainer';
import ModalContainer from 'views/ModalContainer';
import PeerAssessmentView from 'views/PeerAssessmentView';
import SelfAssessmentView from 'views/SelfAssessmentView';
import StudentTrainingView from 'views/StudentTrainingView';
import SubmissionView from 'views/SubmissionView';
import XBlockView from 'views/XBlockView';
import messages from './messages';
import routes from './routes';

const RouterRoot = () => {
const { formatMessage } = useIntl();
const appRoute = (route, Component) => (
<Route path={route} element={<AppContainer Component={Component} />} />
);
const modalRoute = (route, Component, title) => (
<Route path={route} element={<ModalContainer {...{ title, Component }} />} />
);

const embeddedRoutes = [
<Route path={routes.embedded.xblock} element={<XBlockView />} />,
modalRoute(routes.embedded.peerAssessment, PeerAssessmentView, 'ORA Peer Assessment'),
modalRoute(routes.embedded.selfAssessment, SelfAssessmentView, 'ORA Self Assessment'),
modalRoute(routes.embedded.studentTraining, StudentTrainingView, 'ORA Student Training'),
modalRoute(routes.embedded.submission, SubmissionView, 'ORA Submission'),
<Route path={routes.embedded.root} element={<ErrorPage message={formatMessage(messages.error404Message)} />} />,
];
const baseRoutes = [
appRoute(routes.xblock, PeerAssessmentView),
appRoute(routes.peerAssessment, PeerAssessmentView),
appRoute(routes.selfAssessment, SelfAssessmentView),
appRoute(routes.studentTraining, StudentTrainingView),
appRoute(routes.submission, SubmissionView),
<Route path={routes.root} element={<ErrorPage message={formatMessage(messages.error404Message)} />} />,
];

return (
<Routes>
<Route path={routes.peerAssessment} element={<PeerAssessmentView />} />
<Route path={routes.selfAssessment} element={<SelfAssessmentView />} />
<Route path={routes.studentTraining} element={<StudentTrainingView />} />
<Route path={routes.submission} element={<SubmissionView />} />
<Route path={routes.root} element={<ErrorPage message={formatMessage(messages.error404Message)} />} />
{embeddedRoutes}
{baseRoutes}
</Routes>
);
};
Expand Down
9 changes: 9 additions & 0 deletions src/routes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
export default {
embedded: {
xblock: '/embedded/xblock/:id',
peerAssessment: '/embedded/peer_assessment/:id',
selfAssessment: '/embedded/self_assessment/:id',
studentTraining: '/embedded/student_training/:id',
submission: '/embedded/submission/:id',
root: '/embedded/*',
},
xblock: '/xblock/:id',
peerAssessment: '/peer_assessment/:id',
selfAssessment: '/self_assessment/:id',
studentTraining: '/student_training/:id',
Expand Down
17 changes: 17 additions & 0 deletions src/views/AppContainer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';

/* The purpose of this component is to wrap views with a header/footer for situations
* where we need to run non-embedded
*/

const AppContainer = ({ Component }) => (
<div>
<Component />
</div>
);
AppContainer.propTypes = {
Component: PropTypes.elementType.isRequired,
};

export default AppContainer;
25 changes: 25 additions & 0 deletions src/views/ModalContainer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import PropTypes from 'prop-types';
import { FullscreenModal } from '@edx/paragon';

/* The purpose of this component is to wrap views with a header/footer for situations
* where we need to run non-embedded
*/

const ModalContainer = ({ Component, title }) => (
<FullscreenModal
isOpen
onClose={null}
hasCloseButton={false}
title={title}
modalBodyClassName="content-body"
>
<Component />
</FullscreenModal>
);
ModalContainer.propTypes = {
Component: PropTypes.elementType.isRequired,
title: PropTypes.string.isRequired,
};

export default ModalContainer;
16 changes: 3 additions & 13 deletions src/views/PeerAssessmentView/index.jsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
import React from 'react';

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

import { useIsORAConfigLoaded, usePageData } from 'data/services/lms/hooks/selectors';
import { useIsORAConfigLoaded } from 'data/services/lms/hooks/selectors';

import AssessmentContentLayout from './AssessmentContentLayout';
import AssessmentActions from './AssessmentActions';

export const PeerAssessmentView = () => {
const isORAConfigLoaded = useIsORAConfigLoaded();
const pageData = usePageData();
console.log({ pageData });
// const submissionData = useSubmissionData();
return (
<FullscreenModal
isOpen
onClose={() => ({})}
title="ORA Assessment"
modalBodyClassName="content-body"
>
<>
{isORAConfigLoaded && (<AssessmentContentLayout />)}
<AssessmentActions />
</FullscreenModal>
</>
);
};

Expand Down
14 changes: 2 additions & 12 deletions src/views/SelfAssessmentView/index.jsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
import React from 'react';

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

import { useIsORAConfigLoaded, usePageData } from 'data/services/lms/hooks/selectors';

Check failure on line 3 in src/views/SelfAssessmentView/index.jsx

View workflow job for this annotation

GitHub Actions / test

'usePageData' is defined but never used

import AssessmentContentLayout from './AssessmentContentLayout';
import AssessmentActions from './AssessmentActions';

export const SelfAssessmentView = () => {
const isORAConfigLoaded = useIsORAConfigLoaded();
const pageData = usePageData();
console.log({ pageData });
// const submissionData = useSubmissionData();
return (
<FullscreenModal
isOpen
onClose={() => ({})}
title="ORA Assessment"
modalBodyClassName="content-body"
>
<>
{isORAConfigLoaded && (<AssessmentContentLayout />)}
<AssessmentActions />
</FullscreenModal>
</>
);
};

Expand Down
12 changes: 2 additions & 10 deletions src/views/StudentTrainingView/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,11 @@ import AssessmentActions from './AssessmentActions';

export const StudentTrainingView = () => {
const isORAConfigLoaded = useIsORAConfigLoaded();
const pageData = usePageData();
console.log({ pageData });
// const submissionData = useSubmissionData();
return (
<FullscreenModal
isOpen
onClose={() => ({})}
title="ORA Assessment"
modalBodyClassName="content-body"
>
<>
{isORAConfigLoaded && (<AssessmentContentLayout />)}
<AssessmentActions />
</FullscreenModal>
</>
);
};

Expand Down
9 changes: 2 additions & 7 deletions src/views/SubmissionView/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,10 @@ export const SubmissionView = () => {
}

return (
<FullscreenModal
isOpen
onClose={() => ({})}
title="ORA Submission"
modalBodyClassName="content-body"
>
<>
<SubmissionContentLayout />
<SubmissionActions />
</FullscreenModal>
</>
);
};

Expand Down
9 changes: 9 additions & 0 deletions src/views/XBlockView/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

export const XBlockView = () => {

Check failure on line 3 in src/views/XBlockView/index.jsx

View workflow job for this annotation

GitHub Actions / test

Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`
return (
<div>XBlock View</div>
)

Check failure on line 6 in src/views/XBlockView/index.jsx

View workflow job for this annotation

GitHub Actions / test

Missing semicolon
};

export default XBlockView

Check failure on line 9 in src/views/XBlockView/index.jsx

View workflow job for this annotation

GitHub Actions / test

Missing semicolon

0 comments on commit eedae24

Please sign in to comment.