From dea84b1892be42e8d42db8b67862b56b38c0da75 Mon Sep 17 00:00:00 2001
From: =Corey Hulen <corey@hulen.com>
Date: Thu, 21 Jan 2016 13:54:21 -0600
Subject: PLT-7 Adding react-intl libs

---
 web/react/pages/login.jsx | 70 +++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 62 insertions(+), 8 deletions(-)

(limited to 'web/react/pages/login.jsx')

diff --git a/web/react/pages/login.jsx b/web/react/pages/login.jsx
index 4a565623e..edf2d4f66 100644
--- a/web/react/pages/login.jsx
+++ b/web/react/pages/login.jsx
@@ -1,17 +1,71 @@
 // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
 // See License.txt for license information.
 
+import * as Client from '../utils/client.jsx';
 import Login from '../components/login.jsx';
 
-function setupLoginPage(props) {
+var IntlProvider = ReactIntl.IntlProvider;
+ReactIntl.addLocaleData(ReactIntlLocaleData.en);
+ReactIntl.addLocaleData(ReactIntlLocaleData.es);
+
+class Root extends React.Component {
+    constructor() {
+        super();
+        this.state = {
+            translations: null,
+            loaded: false
+        };
+    }
+
+    static propTypes() {
+        return {
+            map: React.PropTypes.object.isRequired
+        };
+    }
+
+    componentWillMount() {
+        Client.getTranslations(
+            'es',
+            (data) => {
+                this.setState({
+                    translations: data,
+                    loaded: true
+                });
+            },
+            () => {
+                this.setState({
+                    loaded: true
+                });
+            }
+        );
+    }
+
+    render() {
+        if (!this.state.loaded) {
+            return <div></div>;
+        }
+
+        return (
+            <IntlProvider
+                locale='es'
+                messages={this.state.translations}
+            >
+                <Login
+                    teamDisplayName={this.props.map.TeamDisplayName}
+                    teamName={this.props.map.TeamName}
+                    inviteId={this.props.map.InviteId}
+                />
+            </IntlProvider>
+        );
+    }
+}
+
+global.window.setup_login_page = function setup(props) {
     ReactDOM.render(
-        <Login
-            teamDisplayName={props.TeamDisplayName}
-            teamName={props.TeamName}
-            inviteId={props.InviteId}
-        />,
+        <Root map={props} />,
         document.getElementById('login')
     );
-}
+};
+
 
-global.window.setup_login_page = setupLoginPage;
+//locale={this.props.map.Locale}
\ No newline at end of file
-- 
cgit v1.2.3-1-g7c22

