Home Reference Source

application/components/home.js

import React from 'react';
import {connect} from 'react-redux';

import {Link, browserHistory} from 'react-router';
import Paper from 'material-ui/Paper';
import Markdown from 'react-remarkable';

import {Row, Col} from './flexbox';

import Config from '../config';

class Home extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            landing: false
        };
    }

    componentWillMount() {
        let landing = Config.get('landing');

        if (landing.indexOf('dashboard') !== -1) {
            browserHistory.push('/ceo/dashboard');
            return;
        }

        if (!landing || !landing.length) {
            browserHistory.push('/ceo/all');
            return;
        }

        this.setState({'landing': atob(landing)});
    }

    render() {

        return (
            <div id='home-root'>
                <Row>
                    <Col xs={12} md={10} lg={9} offsetMd={1} offsetLg={1}>
                        <Paper className='padded clear-top clear-bottom'>
                            {
                                !this.state.landing.length
                                ? 'Loading...'
                                : <Markdown source={this.state.landing} />
                            }
                        </Paper>
                    </Col>
                </Row>
            </div>
        );
    }
}

export default connect()(Home);