{"size": 1720, "ext": "js", "max_stars_repo_path": "src/containers/AdminLayout/AdminHeader.js", "max_stars_repo_name": "soft821/DFSADmin-new", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/containers/AdminLayout/AdminHeader.js", "max_issues_repo_name": "soft821/DFSADmin-new", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/containers/AdminLayout/AdminHeader.js", "max_forks_repo_name": "soft821/DFSADmin-new", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.4615384615, "max_line_length": 140, "alphanum_fraction": 0.638372093}
import React, { Component } from 'react';
import { Badge, DropdownItem, DropdownMenu, DropdownToggle,Button, Nav, NavItem, NavLink } from 'reactstrap';
import PropTypes from 'prop-types';
import { Route, Redirect } from 'react-router-dom';

import { AppAsideToggler, AppHeaderDropdown, AppNavbarBrand, AppSidebarToggler } from '@coreui/react';
import logo from '../../assets/img/brand/img_logo.png'


const propTypes = {
  children: PropTypes.node,
};

const defaultProps = {};

class AdminHeader extends Component {

  state = {
    redirectToLogin: false
  }

  handleLogout(event){

    localStorage.setItem('token', 'none');
    this.setState({redirectToLogin : true});

  }

  render() {

    // eslint-disable-next-line
    const { children, ...attributes } = this.props;
    const { redirectToLogin } = this.state;

    if (redirectToLogin) {
      return <Redirect to="/login" />;
    }

    return (
      <React.Fragment>
        <AppSidebarToggler className="d-lg-none" display="md" mobile />
        <AppNavbarBrand
          full={{ src: logo, width: 40, height: 40, alt: 'DraftMatch' }}
          minimized={{ src: logo, width: 40, height: 40, alt: 'DraftMatch' }}
        />
        <AppSidebarToggler className="d-md-down-none" display="lg" />

        
        <Nav className="ml-auto" navbar>
          <NavItem className="d-md-down-none" style={{marginRight: 2+'em'}}>
            <Button block color="light" onClick={this.handleLogout.bind(this)}><i className="icon-logout"></i><span> Logout </span></Button>
          </NavItem>
          
        </Nav>

      </React.Fragment>
    );
  }
}

AdminHeader.propTypes = propTypes;
AdminHeader.defaultProps = defaultProps;

export default AdminHeader;
