Link to sales/orders in Topbar modal based on users listings

If the current user has created listings, always link to sales,
otherwise to orders.
This commit is contained in:
Kimmo Puputti 2017-05-09 10:17:32 +03:00
parent 841c00a4aa
commit 4337493cad
2 changed files with 19 additions and 6 deletions

View file

@ -9,7 +9,7 @@ import { Avatar, InlineButton, NamedLink } from '../../components';
import css from './MobileMenu.css';
const MobileMenu = props => {
const { isAuthenticated, name, onLogout } = props;
const { isAuthenticated, currentUserHasListings, name, onLogout } = props;
if (!isAuthenticated) {
return (
@ -31,6 +31,12 @@ const MobileMenu = props => {
);
}
const inboxLink = (
<NamedLink name="InboxPage" params={{ tab: currentUserHasListings ? 'sales' : 'orders' }}>
<FormattedMessage id="MobileMenu.inboxLink" />
</NamedLink>
);
return (
<div className={css.root}>
<div className={css.user}>
@ -43,9 +49,7 @@ const MobileMenu = props => {
</div>
</div>
<div className={css.content}>
<NamedLink name="InboxPage" params={{ tab: 'orders' }}>
<FormattedMessage id="MobileMenu.inboxLink" />
</NamedLink>
{inboxLink}
</div>
<div className={css.footer}>
<InlineButton className={css.logoutButton} onClick={onLogout}>
@ -62,6 +66,7 @@ const { bool, func, string } = PropTypes;
MobileMenu.propTypes = {
isAuthenticated: bool.isRequired,
currentUserHasListings: bool.isRequired,
name: string,
onLogout: func.isRequired,
};

View file

@ -84,6 +84,7 @@ class TopbarComponent extends Component {
isAuthenticated,
authInProgress,
currentUser,
currentUserHasListings,
intl,
location,
togglePageClassNames,
@ -100,7 +101,12 @@ class TopbarComponent extends Component {
const isMobileMenuOpen = mobilemenu === 'open';
const isMobileSearchOpen = mobilesearch === 'open';
const mobileMenu = (
<MobileMenu isAuthenticated={isAuthenticated} name={name} onLogout={this.handleLogout} />
<MobileMenu
isAuthenticated={isAuthenticated}
currentUserHasListings={currentUserHasListings}
name={name}
onLogout={this.handleLogout}
/>
);
// Only render current search if full place object is available in the URL params
@ -161,6 +167,7 @@ TopbarComponent.propTypes = {
isAuthenticated: bool.isRequired,
authInProgress: bool.isRequired,
currentUser: propTypes.currentUser,
currentUserHasListings: bool.isRequired,
onLogout: func.isRequired,
togglePageClassNames: func.isRequired,
@ -181,11 +188,12 @@ TopbarComponent.propTypes = {
const mapStateToProps = state => {
const { isAuthenticated } = state.Auth;
const { currentUser } = state.user;
const { currentUser, currentUserHasListings } = state.user;
return {
isAuthenticated,
authInProgress: authenticationInProgress(state),
currentUser,
currentUserHasListings,
};
};