Skip to content

Commit

Permalink
Merge pull request #52 from sharetribe/fix-footer-become-a-teacher-link
Browse files Browse the repository at this point in the history
Fix footer become a teacher link
  • Loading branch information
Gnito authored Nov 19, 2019
2 parents fea67d5 + 4008671 commit bf17b02
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ https://github.com/sharetribe/flex-template-web/

## Upcoming version 2019-XX-XX

- [fix] Add allowOnlyOneListing prop to EditListingPage and redirect to existing listing if true.
[#52](https://github.com/sharetribe/ftw-time/pull/52)
- [fix] Recently added Footer on EditListingWizard was on top of payout details modal.
[#51](https://github.com/sharetribe/ftw-time/pull/51)
- [change] Hide policy tab ("sauna rules") from `EditListingWizard`. Also, fix height of the page
Expand Down
25 changes: 24 additions & 1 deletion src/containers/EditListingPage/EditListingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { types as sdkTypes } from '../../util/sdkLoader';
import {
LISTING_PAGE_PARAM_TYPE_DRAFT,
LISTING_PAGE_PARAM_TYPE_NEW,
LISTING_PAGE_PARAM_TYPE_EDIT,
LISTING_PAGE_PARAM_TYPES,
LISTING_PAGE_PENDING_APPROVAL_VARIANT,
createSlug,
Expand Down Expand Up @@ -41,6 +42,8 @@ const { UUID } = sdkTypes;
export const EditListingPageComponent = props => {
const {
currentUser,
currentUserListing,
currentUserListingFetched,
createStripeAccountError,
fetchInProgress,
getOwnListing,
Expand All @@ -61,6 +64,7 @@ export const EditListingPageComponent = props => {
page,
params,
scrollingDisabled,
allowOnlyOneListing,
} = props;

const { id, type } = params;
Expand Down Expand Up @@ -102,6 +106,19 @@ export const EditListingPageComponent = props => {
};

return <NamedRedirect {...redirectProps} />;
} else if (allowOnlyOneListing && isNewURI && currentUserListingFetched && currentUserListing) {
// If we allow only one listing per provider, we need to redirect to correct listing.
return (
<NamedRedirect
name="EditListingPage"
params={{
id: currentUserListing.id.uuid,
slug: createSlug(currentUserListing.attributes.title),
type: LISTING_PAGE_PARAM_TYPE_EDIT,
tab: 'description',
}}
/>
);
} else if (showForm) {
const {
createListingDraftError = null,
Expand Down Expand Up @@ -226,12 +243,16 @@ EditListingPageComponent.defaultProps = {
listingDraft: null,
notificationCount: 0,
sendVerificationEmailError: null,
currentUserListing: null,
currentUserListingFetched: false,
};

EditListingPageComponent.propTypes = {
createStripeAccountError: propTypes.error,
currentUser: propTypes.currentUser,
getOwnListing: func.isRequired,
currentUserListing: propTypes.ownListing,
currentUserListingFetched: bool,
onAddAvailabilityException: func.isRequired,
onDeleteAvailabilityException: func.isRequired,
onCreateListingDraft: func.isRequired,
Expand Down Expand Up @@ -265,7 +286,7 @@ EditListingPageComponent.propTypes = {
const mapStateToProps = state => {
const page = state.EditListingPage;
const { createStripeAccountInProgress, createStripeAccountError } = state.stripe;
const { currentUser } = state.user;
const { currentUser, currentUserListing, currentUserListingFetched } = state.user;

const fetchInProgress = createStripeAccountInProgress;

Expand All @@ -277,6 +298,8 @@ const mapStateToProps = state => {
return {
createStripeAccountError,
currentUser,
currentUserListing,
currentUserListingFetched,
fetchInProgress,
getOwnListing,
page,
Expand Down
2 changes: 1 addition & 1 deletion src/routeConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const routeConfiguration = () => {
path: '/l/:slug/:id/:type/:tab',
name: 'EditListingPage',
auth: true,
component: props => <EditListingPage {...props} />,
component: props => <EditListingPage {...props} allowOnlyOneListing />,
loadData: EditListingPage.loadData,
},

Expand Down

0 comments on commit bf17b02

Please sign in to comment.