11import PropTypes from 'prop-types' ;
22import React from 'react' ;
33import { Link } from 'react-router' ;
4- import { withTranslation } from 'react-i18next' ;
4+ import { useTranslation } from 'react-i18next' ;
55
6- class ErrorModal extends React . Component {
7- forceAuthentication ( ) {
6+ const ErrorModal = ( { type, service, closeModal } ) => {
7+ const { t } = useTranslation ( ) ;
8+
9+ function forceAuthentication ( ) {
810 return (
911 < p >
10- { this . props . t ( 'ErrorModal.MessageLogin' ) }
11- < Link to = "/login" onClick = { this . props . closeModal } >
12+ { t ( 'ErrorModal.MessageLogin' ) }
13+ < Link to = "/login" onClick = { closeModal } >
1214 { ' ' }
13- { this . props . t ( 'ErrorModal.Login' ) }
15+ { t ( 'ErrorModal.Login' ) }
1416 </ Link >
15- { this . props . t ( 'ErrorModal.LoginOr' ) }
16- < Link to = "/signup" onClick = { this . props . closeModal } >
17- { this . props . t ( 'ErrorModal.SignUp' ) }
17+ { t ( 'ErrorModal.LoginOr' ) }
18+ < Link to = "/signup" onClick = { closeModal } >
19+ { t ( 'ErrorModal.SignUp' ) }
1820 </ Link >
1921 .
2022 </ p >
2123 ) ;
2224 }
2325
24- oauthError ( ) {
25- const { t, service } = this . props ;
26+ function oauthError ( ) {
2627 const serviceLabels = {
2728 github : 'GitHub' ,
2829 google : 'Google'
@@ -34,50 +35,47 @@ class ErrorModal extends React.Component {
3435 ) ;
3536 }
3637
37- staleSession ( ) {
38+ function staleSession ( ) {
3839 return (
3940 < p >
40- { this . props . t ( 'ErrorModal.MessageLoggedOut' ) }
41- < Link to = "/login" onClick = { this . props . closeModal } >
42- { this . props . t ( 'ErrorModal.LogIn' ) }
41+ { t ( 'ErrorModal.MessageLoggedOut' ) }
42+ < Link to = "/login" onClick = { closeModal } >
43+ { t ( 'ErrorModal.LogIn' ) }
4344 </ Link >
4445 .
4546 </ p >
4647 ) ;
4748 }
4849
49- staleProject ( ) {
50- return < p > { this . props . t ( 'ErrorModal.SavedDifferentWindow' ) } </ p > ;
50+ function staleProject ( ) {
51+ return < p > { t ( 'ErrorModal.SavedDifferentWindow' ) } </ p > ;
5152 }
5253
53- render ( ) {
54- return (
55- < div className = "error-modal__content" >
56- { ( ( ) => { // eslint-disable-line
57- if ( this . props . type === 'forceAuthentication' ) {
58- return this . forceAuthentication ( ) ;
59- } else if ( this . props . type === 'staleSession' ) {
60- return this . staleSession ( ) ;
61- } else if ( this . props . type === 'staleProject' ) {
62- return this . staleProject ( ) ;
63- } else if ( this . props . type === 'oauthError' ) {
64- return this . oauthError ( ) ;
65- }
66- } ) ( ) }
67- </ div >
68- ) ;
69- }
70- }
54+ return (
55+ < div className = "error-modal__content" >
56+ { ( ( ) => { // eslint-disable-line
57+ if ( type === 'forceAuthentication' ) {
58+ return forceAuthentication ( ) ;
59+ } else if ( type === 'staleSession' ) {
60+ return staleSession ( ) ;
61+ } else if ( type === 'staleProject' ) {
62+ return staleProject ( ) ;
63+ } else if ( type === 'oauthError' ) {
64+ return oauthError ( ) ;
65+ }
66+ } ) ( ) }
67+ </ div >
68+ ) ;
69+ } ;
7170
7271ErrorModal . propTypes = {
7372 type : PropTypes . string . isRequired ,
7473 closeModal : PropTypes . func . isRequired ,
75- t : PropTypes . func . isRequired ,
7674 service : PropTypes . string
7775} ;
7876
7977ErrorModal . defaultProps = {
8078 service : ''
8179} ;
8280
83- export default withTranslation ( ) ( ErrorModal ) ;
81+ export default ErrorModal ;
0 commit comments