import React, { Component } from 'react' import PropTypes from 'prop-types' import AccountMenu from './AccountMenu' import LoginForm from './LoginForm' import NotificationIcon from './NotificationIcon' import NotificationBox from './NotificationBox' class UpperRightUI extends Component { static propTypes = { currentUser: PropTypes.object, signInPage: PropTypes.bool, unreadNotificationsCount: PropTypes.number, fetchNotifications: PropTypes.func, notifications: PropTypes.array, markAsRead: PropTypes.func.isRequired, markAsUnread: PropTypes.func.isRequired, openInviteLightbox: PropTypes.func } static contextTypes = { location: PropTypes.object } constructor(props) { super(props) this.state = { accountBoxOpen: false, notificationsBoxOpen: false } } reset = () => { this.setState({ accountBoxOpen: false, notificationsBoxOpen: false }) } toggleAccountBox = () => { this.setState({ accountBoxOpen: !this.state.accountBoxOpen, notificationsBoxOpen: false }) } toggleNotificationsBox = () => { this.setState({ notificationsBoxOpen: !this.state.notificationsBoxOpen, accountBoxOpen: false }) } render () { const { currentUser, signInPage, unreadNotificationsCount, notifications, fetchNotifications, openInviteLightbox, markAsRead, markAsUnread } = this.props const { accountBoxOpen, notificationsBoxOpen } = this.state const { pathname } = this.context.location const unauthedHome = pathname === '/' && !currentUser return