Skip to content

Commit 5d5f391

Browse files
refactor: Replace of injectIntl with useIntl
1 parent 77935e4 commit 5d5f391

File tree

7 files changed

+28
-46
lines changed

7 files changed

+28
-46
lines changed

src/components/Certificate/Certificate.jsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
import React from 'react';
21
import PropTypes from 'prop-types';
32

4-
import {
5-
FormattedDate,
6-
injectIntl,
7-
intlShape,
8-
} from '@edx/frontend-platform/i18n';
3+
import { FormattedDate, useIntl } from '@edx/frontend-platform/i18n';
94
import { Hyperlink, DropdownButton, Dropdown } from '@openedx/paragon';
105
import messages from './messages';
116

127
function Certificate({
13-
intl,
148
type,
159
credential_title: certificateTitle,
1610
credential_org: certificateOrg,
@@ -19,6 +13,7 @@ function Certificate({
1913
handleCreate,
2014
storages = [],
2115
}) {
16+
const intl = useIntl();
2217
const showSingleAction = storages.length === 1;
2318

2419
const renderCreationButtons = () => (
@@ -75,7 +70,6 @@ function Certificate({
7570
}
7671

7772
Certificate.propTypes = {
78-
intl: intlShape.isRequired,
7973
type: PropTypes.oneOf(['program', 'course']),
8074
credential_title: PropTypes.string.isRequired,
8175
credential_org: PropTypes.string.isRequired,
@@ -90,4 +84,4 @@ Certificate.propTypes = {
9084
).isRequired,
9185
};
9286

93-
export default injectIntl(Certificate);
87+
export default Certificate;

src/components/CertificateModal/CertificateModal.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import React from 'react';
21
import PropTypes from 'prop-types';
3-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
2+
import { useIntl } from '@edx/frontend-platform/i18n';
43
import { BrowserView, MobileView, isBrowser } from 'react-device-detect';
54
import {
65
ActionRow, Button, Row, StandardModal,
@@ -12,7 +11,7 @@ import appStoreImg from '../../assets/images/appStore.png';
1211
import googlePlayImg from '../../assets/images/googleplay.png';
1312

1413
function CertificateModal({
15-
intl, isOpen, close, data,
14+
isOpen, close, data,
1615
}) {
1716
const {
1817
deeplink,
@@ -22,6 +21,8 @@ function CertificateModal({
2221
error,
2322
} = data;
2423

24+
const intl = useIntl();
25+
2526
if (error) {
2627
return (
2728
<StandardModal title="Failure" isOpen={isOpen} onClose={close} size="lg">
@@ -172,10 +173,9 @@ function CertificateModal({
172173
}
173174

174175
CertificateModal.propTypes = {
175-
intl: intlShape.isRequired,
176176
isOpen: PropTypes.bool.isRequired,
177177
close: PropTypes.func.isRequired,
178178
data: PropTypes.shape.isRequired,
179179
};
180180

181-
export default injectIntl(CertificateModal);
181+
export default CertificateModal;

src/components/CertificatesList/CertificatesList.jsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import React, { useEffect, useState } from 'react';
1+
import { useEffect, useState } from 'react';
22

33
import { ChevronLeft, Info } from '@openedx/paragon/icons';
44
import {
55
Alert, Hyperlink, Row, useToggle,
66
} from '@openedx/paragon';
7-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
7+
import { useIntl } from '@edx/frontend-platform/i18n';
88
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
99
import { getConfig } from '@edx/frontend-platform/config';
1010
import { logError } from '@edx/frontend-platform/logging';
@@ -19,7 +19,8 @@ import messages from './messages';
1919
import CertificateModal from '../CertificateModal';
2020
import Certificate from '../Certificate';
2121

22-
function CertificatesList({ intl }) {
22+
function CertificatesList() {
23+
const intl = useIntl();
2324
const [certificatesAreLoaded, setCertificatesAreLoaded] = useState(false);
2425
const [dataLoadingIssue, setDataLoadingIssue] = useState('');
2526
const [certificates, setCertificates] = useState({
@@ -206,8 +207,4 @@ function CertificatesList({ intl }) {
206207
);
207208
}
208209

209-
CertificatesList.propTypes = {
210-
intl: intlShape.isRequired,
211-
};
212-
213-
export default injectIntl(CertificatesList);
210+
export default CertificatesList;

src/components/Head/Head.jsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import React from 'react';
21
import { Helmet } from 'react-helmet-async';
3-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
2+
import { useIntl } from '@edx/frontend-platform/i18n';
43
import { getConfig } from '@edx/frontend-platform';
54

65
import messages from './messages';
76

8-
function Head({ intl }) {
7+
function Head() {
8+
const intl = useIntl();
9+
910
return (
1011
<Helmet>
1112
<title>
@@ -16,8 +17,4 @@ function Head({ intl }) {
1617
);
1718
}
1819

19-
Head.propTypes = {
20-
intl: intlShape.isRequired,
21-
};
22-
23-
export default injectIntl(Head);
20+
export default Head;

src/components/NavigationBar/NavigationBar.jsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import React from 'react';
21
import { useNavigate, useLocation } from 'react-router-dom';
32

4-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
3+
import { useIntl } from '@edx/frontend-platform/i18n';
54
import { Tabs, Tab } from '@openedx/paragon';
65
import { getConfig } from '@edx/frontend-platform';
76
import { ROUTES } from '../../constants';
87

98
import messages from './messages';
109

11-
function NavigationBar({ intl }) {
10+
function NavigationBar() {
11+
const intl = useIntl();
1212
const NavigationTabs = [
1313
{
1414
id: 'learnerRecords',
@@ -43,8 +43,4 @@ function NavigationBar({ intl }) {
4343
) : null;
4444
}
4545

46-
NavigationBar.propTypes = {
47-
intl: intlShape.isRequired,
48-
};
49-
50-
export default injectIntl(NavigationBar);
46+
export default NavigationBar;

src/components/ProgramRecord/ProgramRecordHeader.jsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import React from 'react';
21
import PropTypes from 'prop-types';
32
import { Badge } from '@openedx/paragon';
43

5-
import { injectIntl, intlShape, FormattedMessage } from '@edx/frontend-platform/i18n';
4+
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
65
import messages from './messages';
76

87
function ProgramRecordHeader({
9-
learner, program, platform, intl,
8+
learner, program, platform,
109
}) {
10+
const intl = useIntl();
1111
return (
1212
<header className="program-record-header">
1313
<div className="program-headings">
@@ -117,7 +117,6 @@ ProgramRecordHeader.propTypes = {
117117
last_updated: PropTypes.string,
118118
}).isRequired,
119119
platform: PropTypes.string.isRequired,
120-
intl: intlShape.isRequired,
121120
};
122121

123-
export default injectIntl(ProgramRecordHeader);
122+
export default ProgramRecordHeader;

src/components/ProgramRecord/ProgramRecordTable.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { DataTable, Badge } from '@openedx/paragon';
4-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
4+
import { useIntl } from '@edx/frontend-platform/i18n';
55
import messages from './messages';
66

77
function ProgramRecordTable({ grades, intl }) {
@@ -82,7 +82,6 @@ function ProgramRecordTable({ grades, intl }) {
8282
ProgramRecordTable.propTypes = {
8383
// eslint-disable-next-line react/forbid-prop-types
8484
grades: PropTypes.arrayOf(PropTypes.object).isRequired,
85-
intl: intlShape.isRequired,
8685
};
8786

88-
export default injectIntl(ProgramRecordTable);
87+
export default ProgramRecordTable;

0 commit comments

Comments
 (0)