Skip to content

Commit 903fe28

Browse files
KristinAokibradenmacdonald
authored andcommitted
refactor: change to useIntl
1 parent 14c662d commit 903fe28

File tree

71 files changed

+746
-877
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+746
-877
lines changed

src/alerts/access-expiration-alert/AccessExpirationAlert.jsx

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import PropTypes from 'prop-types';
22
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
3-
import {
4-
FormattedMessage, FormattedDate, injectIntl, intlShape,
5-
} from '@edx/frontend-platform/i18n';
3+
import { FormattedMessage, FormattedDate, useIntl } from '@edx/frontend-platform/i18n';
64
import { Alert, Hyperlink } from '@openedx/paragon';
75
import { Info } from '@openedx/paragon/icons';
86

97
import messages from './messages';
108

11-
const AccessExpirationAlert = ({ intl, payload }) => {
9+
const AccessExpirationAlert = ({ payload }) => {
10+
const intl = useIntl();
1211
const {
1312
accessExpiration,
1413
courseId,
@@ -119,7 +118,6 @@ const AccessExpirationAlert = ({ intl, payload }) => {
119118
};
120119

121120
AccessExpirationAlert.propTypes = {
122-
intl: intlShape.isRequired,
123121
payload: PropTypes.shape({
124122
accessExpiration: PropTypes.shape({
125123
expirationDate: PropTypes.string.isRequired,
@@ -134,4 +132,4 @@ AccessExpirationAlert.propTypes = {
134132
}).isRequired,
135133
};
136134

137-
export default injectIntl(AccessExpirationAlert);
135+
export default AccessExpirationAlert;

src/alerts/active-enteprise-alert/ActiveEnterpriseAlert.jsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import React from 'react';
2-
import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n';
2+
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
33
import PropTypes from 'prop-types';
44
import { Alert, Hyperlink } from '@openedx/paragon';
55
import { WarningFilled } from '@openedx/paragon/icons';
66

77
import { getConfig } from '@edx/frontend-platform';
88
import genericMessages from './messages';
99

10-
const ActiveEnterpriseAlert = ({ intl, payload }) => {
10+
const ActiveEnterpriseAlert = ({ payload }) => {
11+
const intl = useIntl();
1112
const { text, courseId } = payload;
1213
const changeActiveEnterprise = (
1314
<Hyperlink
@@ -38,11 +39,10 @@ const ActiveEnterpriseAlert = ({ intl, payload }) => {
3839
};
3940

4041
ActiveEnterpriseAlert.propTypes = {
41-
intl: intlShape.isRequired,
4242
payload: PropTypes.shape({
4343
text: PropTypes.string,
4444
courseId: PropTypes.string,
4545
}).isRequired,
4646
};
4747

48-
export default injectIntl(ActiveEnterpriseAlert);
48+
export default ActiveEnterpriseAlert;

src/alerts/enrollment-alert/EnrollmentAlert.jsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
2+
import { useIntl } from '@edx/frontend-platform/i18n';
33
import PropTypes from 'prop-types';
44
import { Alert, Button } from '@openedx/paragon';
55
import { Info, WarningFilled } from '@openedx/paragon/icons';
@@ -11,7 +11,8 @@ import { useModel } from '../../generic/model-store';
1111
import messages from './messages';
1212
import useEnrollClickHandler from './clickHook';
1313

14-
const EnrollmentAlert = ({ intl, payload }) => {
14+
const EnrollmentAlert = ({ payload }) => {
15+
const intl = useIntl();
1516
const {
1617
canEnroll,
1718
courseId,
@@ -58,7 +59,6 @@ const EnrollmentAlert = ({ intl, payload }) => {
5859
};
5960

6061
EnrollmentAlert.propTypes = {
61-
intl: intlShape.isRequired,
6262
payload: PropTypes.shape({
6363
canEnroll: PropTypes.bool,
6464
courseId: PropTypes.string,
@@ -67,4 +67,4 @@ EnrollmentAlert.propTypes = {
6767
}).isRequired,
6868
};
6969

70-
export default injectIntl(EnrollmentAlert);
70+
export default EnrollmentAlert;

src/alerts/logistration-alert/AccountActivationAlert.jsx

+4-9
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ import {
99
Icon,
1010
} from '@openedx/paragon';
1111
import { Check, ArrowForward } from '@openedx/paragon/icons';
12-
import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n';
12+
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
1313
import { sendActivationEmail } from '../../courseware/data';
1414
import messages from './messages';
1515

16-
const AccountActivationAlert = ({
17-
intl,
18-
}) => {
16+
const AccountActivationAlert = () => {
17+
const intl = useIntl();
1918
const [showModal, setShowModal] = useState(false);
2019
const [showSpinner, setShowSpinner] = useState(false);
2120
const [showCheck, setShowCheck] = useState(false);
@@ -125,8 +124,4 @@ const AccountActivationAlert = ({
125124
);
126125
};
127126

128-
AccountActivationAlert.propTypes = {
129-
intl: intlShape.isRequired,
130-
};
131-
132-
export default injectIntl(AccountActivationAlert);
127+
export default AccountActivationAlert;

src/alerts/logistration-alert/LogistrationAlert.jsx

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import React from 'react';
22
import { getConfig } from '@edx/frontend-platform';
3-
import { injectIntl, intlShape, FormattedMessage } from '@edx/frontend-platform/i18n';
3+
import { useIntl, FormattedMessage } from '@edx/frontend-platform/i18n';
44
import { getLoginRedirectUrl } from '@edx/frontend-platform/auth';
55
import { Alert, Hyperlink } from '@openedx/paragon';
66
import { WarningFilled } from '@openedx/paragon/icons';
77

88
import genericMessages from '../../generic/messages';
99

10-
const LogistrationAlert = ({ intl }) => {
10+
const LogistrationAlert = () => {
11+
const intl = useIntl();
1112
const signIn = (
1213
<Hyperlink
1314
style={{ textDecoration: 'underline' }}
@@ -43,8 +44,4 @@ const LogistrationAlert = ({ intl }) => {
4344
);
4445
};
4546

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

src/course-home/courseware-search/CoursewareResultsFilter.jsx

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useMemo } from 'react';
2-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
2+
import { useIntl } from '@edx/frontend-platform/i18n';
33
import { Tabs, Tab } from '@openedx/paragon';
44

55
import { useParams } from 'react-router';
@@ -13,7 +13,8 @@ const filterTypes = ['text', 'video', 'sequence'];
1313
const filterOther = 'other';
1414
const validFilters = [filterAll, ...filterTypes, filterOther];
1515

16-
export const CoursewareSearchResultsFilter = ({ intl }) => {
16+
export const CoursewareSearchResultsFilter = () => {
17+
const intl = useIntl();
1718
const { courseId } = useParams();
1819
const lastSearch = useModel('contentSearchResults', courseId);
1920
const { filter: filterKeyword, setFilter } = useCoursewareSearchParams();
@@ -73,8 +74,4 @@ export const CoursewareSearchResultsFilter = ({ intl }) => {
7374
);
7475
};
7576

76-
CoursewareSearchResultsFilter.propTypes = {
77-
intl: intlShape.isRequired,
78-
};
79-
80-
export default injectIntl(CoursewareSearchResultsFilter);
77+
export default CoursewareSearchResultsFilter;
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import React from 'react';
2-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
2+
import { useIntl } from '@edx/frontend-platform/i18n';
33
import messages from './messages';
44

5-
const CoursewareSearchEmpty = ({ intl }) => (
6-
<div className="courseware-search-results">
7-
<p className="courseware-search-results__empty" data-testid="no-results">{intl.formatMessage(messages.searchResultsNone)}</p>
8-
</div>
9-
);
10-
11-
CoursewareSearchEmpty.propTypes = {
12-
intl: intlShape.isRequired,
5+
const CoursewareSearchEmpty = () => {
6+
const intl = useIntl();
7+
return (
8+
<div className="courseware-search-results">
9+
<p className="courseware-search-results__empty" data-testid="no-results">{intl.formatMessage(messages.searchResultsNone)}</p>
10+
</div>
11+
);
1312
};
1413

15-
export default injectIntl(CoursewareSearchEmpty);
14+
export default CoursewareSearchEmpty;

src/course-home/courseware-search/CoursewareSearchToggle.jsx

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import React, { useEffect } from 'react';
2-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
2+
import { useIntl } from '@edx/frontend-platform/i18n';
33
import { Button } from '@openedx/paragon';
44
import { ManageSearch } from '@openedx/paragon/icons';
55
import { useDispatch } from 'react-redux';
66
import messages from './messages';
77
import { useCoursewareSearchFeatureFlag, useCoursewareSearchParams } from './hooks';
88
import { setShowSearch } from '../data/slice';
99

10-
const CoursewareSearchToggle = ({
11-
intl,
12-
}) => {
10+
const CoursewareSearchToggle = () => {
11+
const intl = useIntl();
1312
const dispatch = useDispatch();
1413
const enabled = useCoursewareSearchFeatureFlag();
1514
const { query } = useCoursewareSearchParams();
@@ -41,8 +40,4 @@ const CoursewareSearchToggle = ({
4140
);
4241
};
4342

44-
CoursewareSearchToggle.propTypes = {
45-
intl: intlShape.isRequired,
46-
};
47-
48-
export default injectIntl(CoursewareSearchToggle);
43+
export default CoursewareSearchToggle;

src/course-home/dates-tab/DatesTab.jsx

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { useSelector } from 'react-redux';
33
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
4-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
4+
import { useIntl } from '@edx/frontend-platform/i18n';
55

66
import messages from './messages';
77
import Timeline from './timeline/Timeline';
@@ -14,7 +14,8 @@ import ShiftDatesAlert from '../suggested-schedule-messaging/ShiftDatesAlert';
1414
import UpgradeToCompleteAlert from '../suggested-schedule-messaging/UpgradeToCompleteAlert';
1515
import UpgradeToShiftDatesAlert from '../suggested-schedule-messaging/UpgradeToShiftDatesAlert';
1616

17-
const DatesTab = ({ intl }) => {
17+
const DatesTab = () => {
18+
const intl = useIntl();
1819
const {
1920
courseId,
2021
} = useSelector(state => state.courseHome);
@@ -59,8 +60,4 @@ const DatesTab = ({ intl }) => {
5960
);
6061
};
6162

62-
DatesTab.propTypes = {
63-
intl: intlShape.isRequired,
64-
};
65-
66-
export default injectIntl(DatesTab);
63+
export default DatesTab;

src/course-home/dates-tab/timeline/Day.jsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import { useSelector } from 'react-redux';
55
import {
66
FormattedDate,
77
FormattedTime,
8-
injectIntl,
9-
intlShape,
8+
useIntl,
109
} from '@edx/frontend-platform/i18n';
1110
import { Tooltip, OverlayTrigger } from '@openedx/paragon';
1211
import { faInfoCircle } from '@fortawesome/free-solid-svg-icons';
@@ -20,10 +19,10 @@ import { isLearnerAssignment } from '../utils';
2019
const Day = ({
2120
date,
2221
first,
23-
intl,
2422
items,
2523
last,
2624
}) => {
25+
const intl = useIntl();
2726
const {
2827
courseId,
2928
} = useSelector(state => state.courseHome);
@@ -108,7 +107,6 @@ const Day = ({
108107
Day.propTypes = {
109108
date: PropTypes.objectOf(Date).isRequired,
110109
first: PropTypes.bool,
111-
intl: intlShape.isRequired,
112110
items: PropTypes.arrayOf(PropTypes.shape({
113111
date: PropTypes.string,
114112
dateType: PropTypes.string,
@@ -126,4 +124,4 @@ Day.defaultProps = {
126124
last: false,
127125
};
128126

129-
export default injectIntl(Day);
127+
export default Day;

src/course-home/discussion-tab/DiscussionTab.jsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { getConfig } from '@edx/frontend-platform';
2-
import { injectIntl } from '@edx/frontend-platform/i18n';
32
import React, { useState } from 'react';
43
import { useSelector } from 'react-redux';
54
import { useParams, generatePath, useNavigate } from 'react-router-dom';
@@ -30,6 +29,4 @@ const DiscussionTab = () => {
3029
);
3130
};
3231

33-
DiscussionTab.propTypes = {};
34-
35-
export default injectIntl(DiscussionTab);
32+
export default DiscussionTab;

src/course-home/goal-unsubscribe/GoalUnsubscribe.jsx

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect, useState } from 'react';
22
import { useParams } from 'react-router-dom';
33
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
4-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
4+
import { useIntl } from '@edx/frontend-platform/i18n';
55

66
import HeaderSlot from '../../plugin-slots/HeaderSlot';
77
import PageLoading from '../../generic/PageLoading';
@@ -10,7 +10,8 @@ import { unsubscribeFromCourseGoal } from '../data/api';
1010
import messages from './messages';
1111
import ResultPage from './ResultPage';
1212

13-
const GoalUnsubscribe = ({ intl }) => {
13+
const GoalUnsubscribe = () => {
14+
const intl = useIntl();
1415
const { token } = useParams();
1516
const [error, setError] = useState(false);
1617
const [isLoading, setIsLoading] = useState(true);
@@ -51,8 +52,4 @@ const GoalUnsubscribe = ({ intl }) => {
5152
);
5253
};
5354

54-
GoalUnsubscribe.propTypes = {
55-
intl: intlShape.isRequired,
56-
};
57-
58-
export default injectIntl(GoalUnsubscribe);
55+
export default GoalUnsubscribe;

src/course-home/goal-unsubscribe/ResultPage.jsx

+17-20
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
import PropTypes from 'prop-types';
22
import { getConfig } from '@edx/frontend-platform';
3-
import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n';
3+
import { useIntl } from '@edx/frontend-platform/i18n';
44
import { Button, Hyperlink } from '@openedx/paragon';
55

66
import messages from './messages';
77
import { ReactComponent as UnsubscribeIcon } from './unsubscribe.svg';
88

9-
const ResultPage = ({ courseTitle, error, intl }) => {
10-
const errorDescription = (
11-
<FormattedMessage
12-
id="learning.goals.unsubscribe.errorDescription"
13-
defaultMessage="We were unable to unsubscribe you from goal reminder emails. Please try again later or {contactSupport} for help."
14-
values={{
15-
contactSupport: (
16-
<Hyperlink
17-
className="text-reset"
18-
style={{ textDecoration: 'underline' }}
19-
destination={`${getConfig().CONTACT_URL}`}
20-
>
21-
{intl.formatMessage(messages.contactSupport)}
22-
</Hyperlink>
23-
),
24-
}}
25-
/>
9+
const ResultPage = ({ courseTitle, error }) => {
10+
const intl = useIntl();
11+
const errorDescription = intl.formatMessage(
12+
messages.errorDescription,
13+
{
14+
contactSupport: (
15+
<Hyperlink
16+
className="text-reset"
17+
style={{ textDecoration: 'underline' }}
18+
destination={`${getConfig().CONTACT_URL}`}
19+
>
20+
{intl.formatMessage(messages.contactSupport)}
21+
</Hyperlink>
22+
),
23+
},
2624
);
2725

2826
const header = error
@@ -54,7 +52,6 @@ ResultPage.defaultProps = {
5452
ResultPage.propTypes = {
5553
courseTitle: PropTypes.string,
5654
error: PropTypes.bool,
57-
intl: intlShape.isRequired,
5855
};
5956

60-
export default injectIntl(ResultPage);
57+
export default ResultPage;

0 commit comments

Comments
 (0)