Skip to content

Commit b031dd5

Browse files
committed
refactor: Updates in Certificates
1 parent 39e0c38 commit b031dd5

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/CourseAuthoringRoutes.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ const CourseAuthoringRoutes = () => {
140140
/>
141141
<Route
142142
path="certificates"
143-
element={getConfig().ENABLE_CERTIFICATE_PAGE === 'true' ? <PageWrap><Certificates courseId={courseId} /></PageWrap> : null}
143+
element={getConfig().ENABLE_CERTIFICATE_PAGE === 'true' ? <PageWrap><Certificates /></PageWrap> : null}
144144
/>
145145
<Route
146146
path="textbooks"

src/certificates/Certificates.test.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ import { fetchCertificates } from './data/thunks';
99
import { certificatesDataMock } from './__mocks__';
1010
import Certificates from './Certificates';
1111
import messages from './messages';
12+
import { CourseAuthoringProvider } from '@src/CourseAuthoringContext';
1213

1314
let axiosMock;
1415
let store;
1516
const courseId = 'course-123';
1617

17-
const renderComponent = (props) => render(<Certificates courseId={courseId} {...props} />);
18+
const renderComponent = (props) => render(
19+
<CourseAuthoringProvider courseId={courseId}>
20+
<Certificates {...props} />
21+
</CourseAuthoringProvider>
22+
);
1823

1924
describe('Certificates', () => {
2025
beforeEach(async () => {
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Helmet } from 'react-helmet';
2-
import PropTypes from 'prop-types';
32

3+
import { useCourseAuthoringContext } from '@src/CourseAuthoringContext';
44
import Placeholder from '../editors/Placeholder';
55
import { RequestStatus } from '../data/constants';
66
import Loading from '../generic/Loading';
@@ -21,7 +21,8 @@ const MODE_COMPONENTS = {
2121
[MODE_STATES.editAll]: CertificateEditForm,
2222
};
2323

24-
const Certificates = ({ courseId }) => {
24+
const Certificates = () => {
25+
const { courseId } = useCourseAuthoringContext();
2526
const {
2627
certificates, componentMode, isLoading, loadingStatus, pageHeadTitle, hasCertificateModes,
2728
} = useCertificates({ courseId });
@@ -50,8 +51,4 @@ const Certificates = ({ courseId }) => {
5051
);
5152
};
5253

53-
Certificates.propTypes = {
54-
courseId: PropTypes.string.isRequired,
55-
};
56-
5754
export default Certificates;

0 commit comments

Comments
 (0)