import React, { Component } from 'react';

require('./user-info.scss')


class UserInfo extends Component {


	render() {
		let { user, name } = this.props;
		if (!user) {
			user = ( window.cfg && window.cfg.user ) || {};
		}
        if (!name) {
            name = window.cfg && window.cfg.unit && window.cfg.unit.name;
        }

		let img = user.avatar || require("./user-placeholder.png");

		return (
            <div className="user-placeholder">
                <img src={ img } />
                <br/>
                <span className="user-name">{ name || (user.firstName + " " + user.lastName) }</span>
                <br/>
                <span>{ user.email || "" }</span>
                <br/>
                <span>{ user.position || "" }</span>
            </div>
		);

	}

}


export default UserInfo;
