import React from 'react'; import Admin from './../admin' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' import { fetchEntity } from '../actions/index' interface CurrentUserProps { fetchEntity: any; permissionIds: number[]; teamIds: number[]; user: any; webinar: any; } interface CurrentUserDropDownState { imageUrl: string; webinar: { url: string } } class CurrentUserDropDown extends React.Component { constructor(props) { super(props); this.state = { imageUrl: Admin.currentUser.imageUrl, webinar: { url: "" } }; } componentDidMount() { let pathDirectories = window.location.pathname.split('/'); if (pathDirectories[pathDirectories.length - 1] === "chat") { this.props.fetchEntity({ id: pathDirectories[pathDirectories.length - 2], directory: 'webinars', entityName: 'webinar' }).then(() => { this.setState({ webinar: this.props.webinar }); }); } } clickMyAccount() { window.location.pathname = `admin/users/${Admin.currentUser.id}`; } render() { return(
{ this.renderWebinarLinks() } { this.renderSpacer() }
); } renderSpacer() { if (window.location.pathname.split("/").indexOf("chat") >= 0) { return(
); } else { return null; } } renderWebinarLinks() { if (window.location.pathname.split("/").indexOf("chat") >= 0) { return(
Webinar Links
); } else { return null; } } } const mapStateToProps = (reducers, props) => { return reducers.standardReducer; }; function mapDispatchToProps(dispatch) { return bindActionCreators({ fetchEntity }, dispatch); } export default connect(mapStateToProps, mapDispatchToProps)(CurrentUserDropDown);