Skip to content

Commit

Permalink
Merge branch 'develop' into feature/delete-account
Browse files Browse the repository at this point in the history
  • Loading branch information
allanasp committed Aug 19, 2022
2 parents e0d4288 + f0c6545 commit 758521a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 91 deletions.
6 changes: 0 additions & 6 deletions src/components/Topbar/Topbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ class TopbarComponent extends Component {
authInProgress,
currentUser,
currentUserHasListings,
currentUserListing,
currentUserListingFetched,
currentUserHasOrders,
currentPage,
notificationCount,
Expand Down Expand Up @@ -167,8 +165,6 @@ class TopbarComponent extends Component {
<TopbarMobileMenu
isAuthenticated={isAuthenticated}
currentUserHasListings={currentUserHasListings}
currentUserListing={currentUserListing}
currentUserListingFetched={currentUserListingFetched}
currentUser={currentUser}
onLogout={this.handleLogout}
notificationCount={notificationCount}
Expand Down Expand Up @@ -228,8 +224,6 @@ class TopbarComponent extends Component {
<TopbarDesktop
className={desktopClassName}
currentUserHasListings={currentUserHasListings}
currentUserListing={currentUserListing}
currentUserListingFetched={currentUserListingFetched}
currentUser={currentUser}
currentPage={currentPage}
initialSearchFormValues={initialSearchFormValues}
Expand Down
58 changes: 12 additions & 46 deletions src/components/TopbarDesktop/TopbarDesktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import {
MenuContent,
MenuItem,
NamedLink,
ListingLink,
OwnListingLink,
} from '../../components';
import { TopbarSearchForm } from '../../forms';

Expand All @@ -27,8 +25,6 @@ const TopbarDesktop = props => {
currentPage,
rootClassName,
currentUserHasListings,
currentUserListing,
currentUserListingFetched,
notificationCount,
intl,
isAuthenticated,
Expand Down Expand Up @@ -83,21 +79,14 @@ const TopbarDesktop = props => {
<Avatar className={css.avatar} user={currentUser} disableProfileLink />
</MenuLabel>
<MenuContent className={css.profileMenuContent}>
<MenuItem key="EditListingPage">
<OwnListingLink
listing={currentUserListing}
listingFetched={currentUserListingFetched}
className={css.yourListingsLink}
<MenuItem key="ManageListingsPage">
<NamedLink
className={classNames(css.yourListingsLink, currentPageClass('ManageListingsPage'))}
name="ManageListingsPage"
>
<div>
<span className={css.menuItemBorder} />
{currentUserListing ? (
<FormattedMessage id="TopbarDesktop.editYourListingLink" />
) : (
<FormattedMessage id="TopbarDesktop.addYourListingLink" />
)}
</div>
</OwnListingLink>
<span className={css.menuItemBorder} />
<FormattedMessage id="TopbarDesktop.yourListingsLink" />
</NamedLink>
</MenuItem>
<MenuItem key="ProfileSettingsPage">
<NamedLink
Expand Down Expand Up @@ -143,28 +132,6 @@ const TopbarDesktop = props => {
</NamedLink>
);

const listingLink =
authenticatedOnClientSide && currentUserListingFetched && currentUserListing ? (
<ListingLink
className={css.createListingLink}
listing={currentUserListing}
children={
<span className={css.createListing}>
<FormattedMessage id="TopbarDesktop.viewListing" />
</span>
}
/>
) : null;

const createListingLink =
isAuthenticatedOrJustHydrated && !(currentUserListingFetched && !currentUserListing) ? null : (
<NamedLink className={css.createListingLink} name="NewListingPage">
<span className={css.createListing}>
<FormattedMessage id="TopbarDesktop.createListing" />
</span>
</NamedLink>
);

return (
<nav className={classes}>
<NamedLink className={css.logoLink} name="LandingPage">
Expand All @@ -175,8 +142,11 @@ const TopbarDesktop = props => {
/>
</NamedLink>
{search}
{listingLink}
{createListingLink}
<NamedLink className={css.createListingLink} name="NewListingPage">
<span className={css.createListing}>
<FormattedMessage id="TopbarDesktop.createListing" />
</span>
</NamedLink>
{inboxLink}
{profileMenu}
{signupLink}
Expand All @@ -192,16 +162,12 @@ TopbarDesktop.defaultProps = {
currentPage: null,
notificationCount: 0,
initialSearchFormValues: {},
currentUserListing: null,
currentUserListingFetched: false,
};

TopbarDesktop.propTypes = {
rootClassName: string,
className: string,
currentUserHasListings: bool.isRequired,
currentUserListing: propTypes.ownListing,
currentUserListingFetched: bool,
currentUser: propTypes.currentUser,
currentPage: string,
isAuthenticated: bool.isRequired,
Expand Down
42 changes: 6 additions & 36 deletions src/components/UserNav/UserNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,20 @@ import { FormattedMessage } from '../../util/reactIntl';
import classNames from 'classnames';
import { ACCOUNT_SETTINGS_PAGES } from '../../routeConfiguration';
import { LinkTabNavHorizontal } from '../../components';
import { ensureOwnListing } from '../../util/data';
import { LISTING_STATE_DRAFT } from '../../util/types';
import { getListingType, createSlug } from '../../util/urlHelpers';

import css from './UserNav.module.css';

const listingTab = (listing, selectedPageName) => {
if (!listing) {
return {
text: <FormattedMessage id="UserNav.newListing" />,
selected: selectedPageName === 'NewListingPage',
linkProps: {
name: 'NewListingPage',
},
};
}
const currentListing = ensureOwnListing(listing);
const id = currentListing.id.uuid;
const { title = '', state } = currentListing.attributes;
const slug = createSlug(title);
const isDraft = state === LISTING_STATE_DRAFT;

return {
text: <FormattedMessage id="UserNav.editListing" />,
selected: selectedPageName === 'EditListingPage',
linkProps: {
name: 'EditListingPage',
params: {
id,
slug,
type: getListingType(isDraft),
tab: 'photos',
},
},
};
};

const UserNav = props => {
const { className, rootClassName, selectedPageName, listing } = props;
const { className, rootClassName, selectedPageName } = props;
const classes = classNames(rootClassName || css.root, className);

const tabs = [
{
...listingTab(listing, selectedPageName),
text: <FormattedMessage id="ManageListingsPage.yourListings" />,
selected: selectedPageName === 'ManageListingsPage',
linkProps: {
name: 'ManageListingsPage',
},
},
{
text: <FormattedMessage id="UserNav.profileSettingsPage" />,
Expand Down
10 changes: 9 additions & 1 deletion src/routeConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const EmailVerificationPage = loadable(() => import(/* webpackChunkName: "EmailV
const InboxPage = loadable(() => import(/* webpackChunkName: "InboxPage" */ './containers/InboxPage/InboxPage'));
const LandingPage = loadable(() => import(/* webpackChunkName: "LandingPage" */ './containers/LandingPage/LandingPage'));
const ListingPage = loadable(() => import(/* webpackChunkName: "ListingPage" */ /* webpackPrefetch: true */ './containers/ListingPage/ListingPage'));
const ManageListingsPage = loadable(() => import(/* webpackChunkName: "ManageListingsPage" */ './containers/ManageListingsPage/ManageListingsPage'));
const PasswordChangePage = loadable(() => import(/* webpackChunkName: "PasswordChangePage" */ './containers/PasswordChangePage/PasswordChangePage'));
const PasswordRecoveryPage = loadable(() => import(/* webpackChunkName: "PasswordRecoveryPage" */ './containers/PasswordRecoveryPage/PasswordRecoveryPage'));
const PasswordResetPage = loadable(() => import(/* webpackChunkName: "PasswordResetPage" */ './containers/PasswordResetPage/PasswordResetPage'));
Expand Down Expand Up @@ -130,7 +131,6 @@ const routeConfiguration = () => {
name: 'EditListingPage',
auth: true,
component: EditListingPage,
extraProps: { allowOnlyOneListing: true },
loadData: pageDataLoadingAPI.EditListingPage.loadData,
},
{
Expand Down Expand Up @@ -234,6 +234,14 @@ const routeConfiguration = () => {
authPage: 'LoginPage',
component: props => <NamedRedirect name="SaleDetailsPage" params={{ ...props.params }} />,
},
{
path: '/listings',
name: 'ManageListingsPage',
auth: true,
authPage: 'LoginPage',
component: ManageListingsPage,
loadData: pageDataLoadingAPI.ManageListingsPage.loadData,
},
{
path: '/sale/:id/details',
name: 'SaleDetailsPage',
Expand Down
7 changes: 5 additions & 2 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
"CookiePolicyPage.privacyTabTitle": "Privacy Policy",
"CookiePolicyPage.schemaTitle": "Cookie Policy | {siteTitle}",
"CookiePolicyPage.tosTabTitle": "Terms of Service",
"CookiePolicyPage.cookieTabTitle": "Cookie Policy",
"DateInput.clearDate": "Clear Date",
"DateInput.closeDatePicker": "Close",
"DateInput.defaultPlaceholder": "Date input",
Expand Down Expand Up @@ -519,7 +520,7 @@
"LoginForm.passwordRequired": "This field is required",
"ManageListingCard.actionFailed": "Whoops, something went wrong. Please refresh the page and try again.",
"ManageListingCard.closedListing": "This SkillPickr profile is closed and not visible on the marketplace.",
"ManageListingCard.closeListing": "Close SkillPickr profile",
"ManageListingCard.closeListing": "Close listing",
"ManageListingCard.draftOverlayText": "{listingTitle} is a draft and can't be booked.",
"ManageListingCard.editListing": "Edit SkillPickr profile",
"ManageListingCard.finishListingDraft": "Finish SkillPickr profile",
Expand All @@ -540,6 +541,7 @@
"ManageListingsPage.queryError": "Query failed. Please try again.",
"ManageListingsPage.title": "Manage your SkillPickr profile",
"ManageListingsPage.youHaveListings": "You have {count} {count, plural, one {listing} other {listings}}",
"ManageListingsPage.yourListings": "Your listings",
"Modal.close": "CLOSE",
"Modal.closeModal": "Close modal",
"ModalMissingInformation.checkInbox": "Please check your inbox and verify your email address {email}",
Expand Down Expand Up @@ -1094,7 +1096,7 @@
"Topbar.searchIcon": "Open search",
"TopbarDesktop.accountSettingsLink": "Account settings",
"TopbarDesktop.addYourListingLink": "Start earning on SkillPickr",
"TopbarDesktop.createListing": "Start earning on SkillPickr",
"TopbarDesktop.createListing": "+ Add new listing",
"TopbarDesktop.editYourListingLink": "Edit listing",
"TopbarDesktop.inbox": "Inbox",
"TopbarDesktop.login": "Log in",
Expand All @@ -1103,6 +1105,7 @@
"TopbarDesktop.profileSettingsLink": "User profile",
"TopbarDesktop.signup": "Sign up to book",
"TopbarDesktop.viewListing": "SkillPickr profile",
"TopbarDesktop.yourListingsLink": "Your listings",
"TopbarMobileMenu.accountSettingsLink": "Account settings",
"TopbarMobileMenu.greeting": "Hello {displayName}",
"TopbarMobileMenu.inboxLink": "Inbox",
Expand Down

0 comments on commit 758521a

Please sign in to comment.