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 { init } from 'Duck/site'; 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' ]), account: state.getIn([ 'user', 'account' ]), }), { setSiteId, pushNewSite, init }) export default class SiteDropdown extends React.PureComponent { state = { showProductModal: false } closeModal = (e, newSite) => { this.setState({ showProductModal: false }) }; newSite = () => { this.props.init({}) this.setState({showProductModal: true}) } render() { const { sites, siteId, account, location: { pathname } } = this.props; const { showProductModal } = this.state; const isAdmin = account.admin || account.superAdmin; const activeSite = sites.find(s => s.id == siteId); const disabled = !siteChangeAvaliable(pathname); const showCurrent = hasSiteId(pathname) || siteChangeAvaliable(pathname); const canAddSites = isAdmin && account.limits.projects && account.limits.projects.remaining !== 0; return (