11import React from 'react' ;
22import PropTypes from 'prop-types' ;
33import { ActionRow , AlertModal , Button } from '@openedx/paragon' ;
4- import { FormattedMessage , injectIntl , intlShape } from '@edx/frontend-platform/i18n' ;
4+ import { FormattedMessage , useIntl } from '@edx/frontend-platform/i18n' ;
55
66import ModalErrorListItem from './ModalErrorListItem' ;
77import messages from './messages' ;
88
99const ModalError = ( {
10- intl, isError, handleUndoChanges, showErrorModal, errorList, settingsData,
11- } ) => (
12- < AlertModal
13- title = { intl . formatMessage ( messages . modalErrorTitle ) }
14- isOpen = { isError }
15- variant = "danger"
16- footerNode = { (
17- < ActionRow >
18- < Button
19- variant = "tertiary"
20- onClick = { ( ) => showErrorModal ( ! isError ) }
21- >
22- { intl . formatMessage ( messages . modalErrorButtonChangeManually ) }
23- </ Button >
24- < Button onClick = { handleUndoChanges } >
25- { intl . formatMessage ( messages . modalErrorButtonUndoChanges ) }
26- </ Button >
27- </ ActionRow >
10+ isError, handleUndoChanges, showErrorModal, errorList, settingsData,
11+ } ) => {
12+ const intl = useIntl ( ) ;
13+ return (
14+ < AlertModal
15+ title = { intl . formatMessage ( messages . modalErrorTitle ) }
16+ isOpen = { isError }
17+ variant = "danger"
18+ footerNode = { (
19+ < ActionRow >
20+ < Button
21+ variant = "tertiary"
22+ onClick = { ( ) => showErrorModal ( ! isError ) }
23+ >
24+ { intl . formatMessage ( messages . modalErrorButtonChangeManually ) }
25+ </ Button >
26+ < Button onClick = { handleUndoChanges } >
27+ { intl . formatMessage ( messages . modalErrorButtonUndoChanges ) }
28+ </ Button >
29+ </ ActionRow >
2830 ) }
29- >
30- < p >
31- < FormattedMessage
32- id = "course-authoring.advanced-settings.modal.error.description"
33- defaultMessage = "There was {errorCounter} while trying to save the course settings in the database.
31+ >
32+ < p >
33+ < FormattedMessage
34+ id = "course-authoring.advanced-settings.modal.error.description"
35+ defaultMessage = "There was {errorCounter} while trying to save the course settings in the database.
3436 Please check the following validation feedbacks and reflect them in your course settings:"
35- values = { { errorCounter : < strong > { errorList . length } validation error </ strong > } }
36- />
37- </ p >
38- < hr />
39- < ul className = "p-0" >
40- { errorList . map ( ( settingName ) => (
41- < ModalErrorListItem
42- key = { settingName . key }
43- settingName = { settingName }
44- settingsData = { settingsData }
37+ values = { { errorCounter : < strong > { errorList . length } validation error </ strong > } }
4538 />
46- ) ) }
47- </ ul >
48- </ AlertModal >
49- ) ;
39+ </ p >
40+ < hr />
41+ < ul className = "p-0" >
42+ { errorList . map ( ( settingName ) => (
43+ < ModalErrorListItem
44+ key = { settingName . key }
45+ settingName = { settingName }
46+ settingsData = { settingsData }
47+ />
48+ ) ) }
49+ </ ul >
50+ </ AlertModal >
51+ ) ;
52+ } ;
5053
5154ModalError . propTypes = {
52- intl : intlShape . isRequired ,
5355 isError : PropTypes . bool . isRequired ,
5456 handleUndoChanges : PropTypes . func . isRequired ,
5557 showErrorModal : PropTypes . func . isRequired ,
@@ -60,4 +62,4 @@ ModalError.propTypes = {
6062 settingsData : PropTypes . shape ( { } ) . isRequired ,
6163} ;
6264
63- export default injectIntl ( ModalError ) ;
65+ export default ModalError ;
0 commit comments