From 53e495cf335d3c6b44361627288db252aae1f4ad Mon Sep 17 00:00:00 2001
From: Elias Nahum <nahumhbl@gmail.com>
Date: Thu, 28 Jan 2016 16:16:39 -0300
Subject: PLT-7: Refactoring frontend (chunk 4)

---
 web/react/components/login_email.jsx | 49 ++++++++++++++++++++++++++++++------
 1 file changed, 41 insertions(+), 8 deletions(-)

(limited to 'web/react/components/login_email.jsx')

diff --git a/web/react/components/login_email.jsx b/web/react/components/login_email.jsx
index cfe34d1c7..cf1e1bc40 100644
--- a/web/react/components/login_email.jsx
+++ b/web/react/components/login_email.jsx
@@ -5,7 +5,32 @@ import * as Utils from '../utils/utils.jsx';
 import * as Client from '../utils/client.jsx';
 import UserStore from '../stores/user_store.jsx';
 
-export default class LoginEmail extends React.Component {
+import {injectIntl, intlShape, defineMessages, FormattedMessage} from 'mm-intl';
+
+var holders = defineMessages({
+    badTeam: {
+        id: 'login_email.badTeam',
+        defaultMessage: 'Bad team name'
+    },
+    emailReq: {
+        id: 'login_email.emailReq',
+        defaultMessage: 'An email is required'
+    },
+    pwdReq: {
+        id: 'login_email.pwdReq',
+        defaultMessage: 'A password is required'
+    },
+    email: {
+        id: 'login_email.email',
+        defaultMessage: 'Email'
+    },
+    pwd: {
+        id: 'login_email.pwd',
+        defaultMessage: 'Password'
+    }
+});
+
+class LoginEmail extends React.Component {
     constructor(props) {
         super(props);
 
@@ -17,25 +42,26 @@ export default class LoginEmail extends React.Component {
     }
     handleSubmit(e) {
         e.preventDefault();
+        const {formatMessage} = this.props.intl;
         var state = {};
 
         const name = this.props.teamName;
         if (!name) {
-            state.serverError = 'Bad team name';
+            state.serverError = formatMessage(holders.badTeam);
             this.setState(state);
             return;
         }
 
         const email = this.refs.email.value.trim();
         if (!email) {
-            state.serverError = 'An email is required';
+            state.serverError = formatMessage(holders.emailReq);
             this.setState(state);
             return;
         }
 
         const password = this.refs.password.value.trim();
         if (!password) {
-            state.serverError = 'A password is required';
+            state.serverError = formatMessage(holders.pwdReq);
             this.setState(state);
             return;
         }
@@ -55,7 +81,7 @@ export default class LoginEmail extends React.Component {
                 }
             },
             (err) => {
-                if (err.message === 'Login failed because email address has not been verified') {
+                if (err.id === 'api.user.login.not_verified.app_error') {
                     window.location.href = '/verify_email?teamname=' + encodeURIComponent(name) + '&email=' + encodeURIComponent(email);
                     return;
                 }
@@ -87,6 +113,7 @@ export default class LoginEmail extends React.Component {
             priorEmail = decodeURIComponent(emailParam);
         }
 
+        const {formatMessage} = this.props.intl;
         return (
             <form onSubmit={this.handleSubmit}>
                 <div className='signup__email-container'>
@@ -101,7 +128,7 @@ export default class LoginEmail extends React.Component {
                             name='email'
                             defaultValue={priorEmail}
                             ref='email'
-                            placeholder='Email'
+                            placeholder={formatMessage(holders.email)}
                             spellCheck='false'
                         />
                     </div>
@@ -112,7 +139,7 @@ export default class LoginEmail extends React.Component {
                             className='form-control'
                             name='password'
                             ref='password'
-                            placeholder='Password'
+                            placeholder={formatMessage(holders.pwd)}
                             spellCheck='false'
                         />
                     </div>
@@ -121,7 +148,10 @@ export default class LoginEmail extends React.Component {
                             type='submit'
                             className='btn btn-primary'
                         >
-                            {'Sign in'}
+                            <FormattedMessage
+                                id='login_email.signin'
+                                defaultMessage='Sign in'
+                            />
                         </button>
                     </div>
                 </div>
@@ -133,5 +163,8 @@ LoginEmail.defaultProps = {
 };
 
 LoginEmail.propTypes = {
+    intl: intlShape.isRequired,
     teamName: React.PropTypes.string.isRequired
 };
+
+export default injectIntl(LoginEmail);
\ No newline at end of file
-- 
cgit v1.2.3-1-g7c22

