Skip to content

Commit 77a0a5d

Browse files
feat: route time
1 parent f587907 commit 77a0a5d

File tree

9 files changed

+103
-58
lines changed

9 files changed

+103
-58
lines changed

src/App.jsx

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,41 @@ import { Spinner } from '@edx/paragon';
55

66
import { useIsORAConfigLoaded, useIsPageDataLoaded } from 'data/services/lms/hooks/selectors';
77

8+
import AppContainer from 'views/AppContainer';
9+
import ModalContainer from 'views/ModalContainer';
810
import PeerAssessmentView from 'views/PeerAssessmentView';
911
import SelfAssessmentView from 'views/SelfAssessmentView';
1012
import StudentTrainingView from 'views/StudentTrainingView';
1113
import SubmissionView from 'views/SubmissionView';
14+
import XBlockView from 'views/XBlockView';
1215
import messages from './messages';
1316
import routes from './routes';
1417

1518
const RouterRoot = () => {
1619
const { formatMessage } = useIntl();
20+
const appRoute = (route, Component) => (
21+
<Route path={route} element={<AppContainer Component={Component} />} />
22+
);
23+
const modalRoute = (route, Component, title) => (
24+
<Route path={route} element={<ModalContainer {...{ title, Component }} />} />
25+
);
26+
27+
const embeddedRoutes = [
28+
<Route path={routes.embedded.xblock} element={<XBlockView />} />,
29+
modalRoute(routes.embedded.peerAssessment, PeerAssessmentView, 'ORA Peer Assessment'),
30+
modalRoute(routes.embedded.selfAssessment, SelfAssessmentView, 'ORA Self Assessment'),
31+
modalRoute(routes.embedded.studentTraining, StudentTrainingView, 'ORA Student Training'),
32+
modalRoute(routes.embedded.submission, SubmissionView, 'ORA Submission'),
33+
<Route path={routes.embedded.root} element={<ErrorPage message={formatMessage(messages.error404Message)} />} />,
34+
];
35+
const baseRoutes = [
36+
appRoute(routes.xblock, PeerAssessmentView),
37+
appRoute(routes.peerAssessment, PeerAssessmentView),
38+
appRoute(routes.selfAssessment, SelfAssessmentView),
39+
appRoute(routes.studentTraining, StudentTrainingView),
40+
appRoute(routes.submission, SubmissionView),
41+
<Route path={routes.root} element={<ErrorPage message={formatMessage(messages.error404Message)} />} />,
42+
];
1743

1844
const isConfigLoaded = useIsORAConfigLoaded();
1945
const isPageLoaded = useIsPageDataLoaded();
@@ -33,11 +59,8 @@ const RouterRoot = () => {
3359

3460
return (
3561
<Routes>
36-
<Route path={routes.peerAssessment} element={<PeerAssessmentView />} />
37-
<Route path={routes.selfAssessment} element={<SelfAssessmentView />} />
38-
<Route path={routes.studentTraining} element={<StudentTrainingView />} />
39-
<Route path={routes.submission} element={<SubmissionView />} />
40-
<Route path={routes.root} element={<ErrorPage message={formatMessage(messages.error404Message)} />} />
62+
{embeddedRoutes}
63+
{baseRoutes}
4164
</Routes>
4265
);
4366
};

src/routes.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
export default {
2+
embedded: {
3+
xblock: '/embedded/xblock/:id',
4+
peerAssessment: '/embedded/peer_assessment/:id',
5+
selfAssessment: '/embedded/self_assessment/:id',
6+
studentTraining: '/embedded/student_training/:id',
7+
submission: '/embedded/submission/:id',
8+
root: '/embedded/*',
9+
},
10+
xblock: '/xblock/:id',
211
peerAssessment: '/peer_assessment/:id',
312
selfAssessment: '/self_assessment/:id',
413
studentTraining: '/student_training/:id',

src/views/AppContainer.jsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
4+
/* The purpose of this component is to wrap views with a header/footer for situations
5+
* where we need to run non-embedded
6+
*/
7+
8+
const AppContainer = ({ Component }) => (
9+
<div>
10+
<Component />
11+
</div>
12+
);
13+
AppContainer.propTypes = {
14+
Component: PropTypes.elementType.isRequired,
15+
};
16+
17+
export default AppContainer;

src/views/ModalContainer.jsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import { FullscreenModal } from '@edx/paragon';
4+
5+
/* The purpose of this component is to wrap views with a header/footer for situations
6+
* where we need to run non-embedded
7+
*/
8+
9+
const ModalContainer = ({ Component, title }) => (
10+
<FullscreenModal
11+
isOpen
12+
onClose={null}
13+
hasCloseButton={false}
14+
title={title}
15+
modalBodyClassName="content-body"
16+
>
17+
<Component />
18+
</FullscreenModal>
19+
);
20+
ModalContainer.propTypes = {
21+
Component: PropTypes.elementType.isRequired,
22+
title: PropTypes.string.isRequired,
23+
};
24+
25+
export default ModalContainer;

src/views/PeerAssessmentView/index.jsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
11
import React from 'react';
22

3-
import { FullscreenModal } from '@edx/paragon';
4-
5-
import { useIsORAConfigLoaded, usePageData } from 'data/services/lms/hooks/selectors';
3+
import { useIsORAConfigLoaded } from 'data/services/lms/hooks/selectors';
64

75
import AssessmentContentLayout from './AssessmentContentLayout';
86
import AssessmentActions from './AssessmentActions';
97

108
export const PeerAssessmentView = () => {
119
const isORAConfigLoaded = useIsORAConfigLoaded();
12-
const pageData = usePageData();
13-
console.log({ pageData });
14-
// const submissionData = useSubmissionData();
1510
return (
16-
<FullscreenModal
17-
isOpen
18-
onClose={() => ({})}
19-
title="ORA Assessment"
20-
modalBodyClassName="content-body"
21-
>
11+
<>
2212
{isORAConfigLoaded && (<AssessmentContentLayout />)}
2313
<AssessmentActions />
24-
</FullscreenModal>
14+
</>
2515
);
2616
};
2717

src/views/SelfAssessmentView/index.jsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
11
import React from 'react';
22

3-
import { FullscreenModal } from '@edx/paragon';
4-
53
import { useIsORAConfigLoaded, usePageData } from 'data/services/lms/hooks/selectors';
64

75
import AssessmentContentLayout from './AssessmentContentLayout';
86
import AssessmentActions from './AssessmentActions';
97

108
export const SelfAssessmentView = () => {
119
const isORAConfigLoaded = useIsORAConfigLoaded();
12-
const pageData = usePageData();
13-
console.log({ pageData });
14-
// const submissionData = useSubmissionData();
1510
return (
16-
<FullscreenModal
17-
isOpen
18-
onClose={() => ({})}
19-
title="ORA Assessment"
20-
modalBodyClassName="content-body"
21-
>
11+
<>
2212
{isORAConfigLoaded && (<AssessmentContentLayout />)}
2313
<AssessmentActions />
24-
</FullscreenModal>
14+
</>
2515
);
2616
};
2717

src/views/StudentTrainingView/index.jsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,11 @@ import AssessmentActions from './AssessmentActions';
99

1010
export const StudentTrainingView = () => {
1111
const isORAConfigLoaded = useIsORAConfigLoaded();
12-
const pageData = usePageData();
13-
console.log({ pageData });
14-
// const submissionData = useSubmissionData();
1512
return (
16-
<FullscreenModal
17-
isOpen
18-
onClose={() => ({})}
19-
title="ORA Assessment"
20-
modalBodyClassName="content-body"
21-
>
13+
<>
2214
{isORAConfigLoaded && (<AssessmentContentLayout />)}
2315
<AssessmentActions />
24-
</FullscreenModal>
16+
</>
2517
);
2618
};
2719

src/views/SubmissionView/index.jsx

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import React from 'react';
22

3-
import { FullscreenModal } from '@edx/paragon';
4-
53
import SubmissionContentLayout from './SubmissionContentLayout';
64
import SubmissionActions from './SubmissionActions';
75
import useSubmissionViewHooks from './hooks';
@@ -18,30 +16,22 @@ export const SubmissionView = () => {
1816
saveResponseStatus,
1917
draftSaved,
2018
} = useSubmissionViewHooks();
21-
2219
return (
23-
<FullscreenModal
24-
isOpen
25-
onClose={() => ({})}
26-
title="ORA Submission"
27-
modalBodyClassName="content-body"
28-
footerNode={(
29-
<SubmissionActions
30-
submitResponseHandler={submitResponseHandler}
31-
submitResponseStatus={submitResponseStatus}
32-
saveResponseHandler={saveResponseHandler}
33-
saveResponseStatus={saveResponseStatus}
34-
/>
35-
)}
36-
>
20+
<>
3721
<SubmissionContentLayout
3822
submission={submission}
3923
oraConfigData={oraConfigData}
4024
onTextResponseChange={onTextResponseChange}
4125
onFileUploaded={onFileUploaded}
4226
draftSaved={draftSaved}
4327
/>
44-
</FullscreenModal>
28+
<SubmissionActions
29+
submitResponseHandler={submitResponseHandler}
30+
submitResponseStatus={submitResponseStatus}
31+
saveResponseHandler={saveResponseHandler}
32+
saveResponseStatus={saveResponseStatus}
33+
/>
34+
</>
4535
);
4636
};
4737

src/views/XBlockView/index.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
3+
export const XBlockView = () => {
4+
return (
5+
<div>XBlock View</div>
6+
)
7+
};
8+
9+
export default XBlockView

0 commit comments

Comments
 (0)