import { connect } from 'react-redux'; import { setSiteId } from 'Duck/user'; import { withRouter } from 'react-router-dom'; import { hasSiteId, siteChangeAvaliable } from 'App/routes'; import { STATUS_COLOR_MAP, GREEN } from 'Types/site'; import { Icon, SlideModal } from 'UI'; import { pushNewSite } from 'Duck/user' import styles from './siteDropdown.css'; import cn from 'classnames'; import NewSiteForm from '../Client/Sites/NewSiteForm'; @withRouter @connect(state => ({ sites: state.getIn([ 'site', 'list' ]), siteId: state.getIn([ 'user', 'siteId' ]), }), { setSiteId, pushNewSite }) export default class SiteDropdown extends React.PureComponent { state = { showProductModal: false } closeModal = (e, newSite) => { this.setState({ showProductModal: false }) if (newSite) { this.props.pushNewSite(newSite) this.props.setSiteId(newSite.id) } }; render() { const { sites, siteId, location: { pathname } } = this.props; const { showProductModal } = this.state; const activeSite = sites.find(s => s.id == siteId); const disabled = !siteChangeAvaliable(pathname); const showCurrent = hasSiteId(pathname) || siteChangeAvaliable(pathname); return (