mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-30 18:16:48 +10:00
Merge pull request #131 from sharetribe/remove-edit-listing-link
Remove edit listing link
This commit is contained in:
commit
0dc7bbc2b6
15 changed files with 18 additions and 51 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import { pick } from 'lodash';
|
||||
import { fetchCurrentUser } from '../../ducks/user.duck';
|
||||
|
||||
// ================ Action types ================ //
|
||||
|
||||
|
|
@ -75,10 +74,3 @@ export const initiateOrder = params =>
|
|||
throw e;
|
||||
});
|
||||
};
|
||||
|
||||
// ================ Thunk ================ //
|
||||
|
||||
export const loadData = () =>
|
||||
dispatch => {
|
||||
return dispatch(fetchCurrentUser());
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import * as propTypes from '../../util/propTypes';
|
|||
import { withFlattenedRoutes } from '../../util/contextHelpers';
|
||||
import { AuthorInfo, BookingInfo, NamedRedirect, PageLayout } from '../../components';
|
||||
import { StripePaymentForm } from '../../containers';
|
||||
import { initiateOrder, setInitialValues, loadData } from './CheckoutPage.duck';
|
||||
import { initiateOrder, setInitialValues } from './CheckoutPage.duck';
|
||||
|
||||
import css from './CheckoutPage.css';
|
||||
|
||||
|
|
@ -275,6 +275,4 @@ CheckoutPage.setInitialValues = initialValues => setInitialValues(initialValues)
|
|||
|
||||
CheckoutPage.displayName = 'CheckoutPage';
|
||||
|
||||
CheckoutPage.loadData = loadData;
|
||||
|
||||
export default CheckoutPage;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import { types } from '../../util/sdkLoader';
|
|||
import { NamedRedirect, PageLayout } from '../../components';
|
||||
import { EditListingForm } from '../../containers';
|
||||
import { getListingsById } from '../../ducks/sdk.duck';
|
||||
import { fetchCurrentUser } from '../../ducks/user.duck';
|
||||
import { createSlug } from '../../util/urlHelpers';
|
||||
import * as propTypes from '../../util/propTypes';
|
||||
import {
|
||||
|
|
@ -166,8 +165,4 @@ const EditListingPage = connect(mapStateToProps, mapDispatchToProps)(
|
|||
injectIntl(EditListingPageComponent)
|
||||
);
|
||||
|
||||
EditListingPage.loadData = () => {
|
||||
return fetchCurrentUser();
|
||||
};
|
||||
|
||||
export default EditListingPage;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import React, { Component, PropTypes } from 'react';
|
||||
import { FormattedMessage, intlShape, injectIntl } from 'react-intl';
|
||||
import { intlShape, injectIntl } from 'react-intl';
|
||||
import { connect } from 'react-redux';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { union, without } from 'lodash';
|
||||
|
|
@ -9,7 +9,7 @@ import { types } from '../../util/sdkLoader';
|
|||
import { createSlug } from '../../util/urlHelpers';
|
||||
import { convertMoneyToNumber } from '../../util/currency';
|
||||
import { createResourceLocatorString, findRouteByRouteName } from '../../util/routes';
|
||||
import { Button, Map, ModalInMobile, PageLayout, NamedLink } from '../../components';
|
||||
import { Button, Map, ModalInMobile, PageLayout } from '../../components';
|
||||
import { BookingDatesForm } from '../../containers';
|
||||
import { getListingsById } from '../../ducks/sdk.duck';
|
||||
import { showListing } from './ListingPage.duck';
|
||||
|
|
@ -130,10 +130,10 @@ export class ListingPageComponent extends Component {
|
|||
</div>
|
||||
: null;
|
||||
|
||||
const isOwnListing = currentUser &&
|
||||
currentListing &&
|
||||
currentListing.author &&
|
||||
const userAndListingAuthorAvailable = currentUser && currentListing && currentListing.author;
|
||||
const isOwnListing = userAndListingAuthorAvailable &&
|
||||
currentListing.author.id.uuid === currentUser.id.uuid;
|
||||
const showBookButton = !isOwnListing;
|
||||
|
||||
const pageContent = (
|
||||
<PageLayout title={`${title} ${formattedPrice}`} className={this.state.pageClassNames}>
|
||||
|
|
@ -156,15 +156,13 @@ export class ListingPageComponent extends Component {
|
|||
<BookingDatesForm className={css.bookingForm} onSubmit={this.onSubmit} price={price} />
|
||||
</ModalInMobile>
|
||||
{map ? <div className={css.map}>{map}</div> : null}
|
||||
{isOwnListing
|
||||
? <NamedLink className={css.editListing} name="EditListingPage" params={params}>
|
||||
<FormattedMessage id="ListingPage.editListing" />
|
||||
</NamedLink>
|
||||
: <div className={css.openBookingForm}>
|
||||
{showBookButton
|
||||
? <div className={css.openBookingForm}>
|
||||
<Button onClick={() => this.setState({ isBookingModalOpenOnMobile: true })}>
|
||||
{bookBtnMessage}
|
||||
</Button>
|
||||
</div>}
|
||||
</div>
|
||||
: null}
|
||||
</div>
|
||||
</PageLayout>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { types } from '../../util/sdkLoader';
|
||||
import { addEntities } from '../../ducks/sdk.duck';
|
||||
import { fetchCurrentUser } from '../../ducks/user.duck';
|
||||
|
||||
// ================ Action types ================ //
|
||||
|
||||
|
|
@ -65,9 +64,6 @@ export const loadData = params =>
|
|||
dispatch => {
|
||||
const orderId = new types.UUID(params.id);
|
||||
|
||||
// Current user is needed to render Topbar
|
||||
dispatch(fetchCurrentUser());
|
||||
|
||||
// Order (i.e. transaction entity in API, but from buyers perspective) contains order details
|
||||
return dispatch(fetchOrder(orderId));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -65,8 +65,6 @@ const mapStateToProps = state => {
|
|||
|
||||
const OrderPage = connect(mapStateToProps)(injectIntl(OrderPageComponent));
|
||||
|
||||
OrderPage.loadData = params => {
|
||||
return loadData(params);
|
||||
};
|
||||
OrderPage.loadData = loadData;
|
||||
|
||||
export default OrderPage;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { types } from '../../util/sdkLoader';
|
||||
import { addEntities } from '../../ducks/sdk.duck';
|
||||
import { fetchCurrentUser } from '../../ducks/user.duck';
|
||||
|
||||
// Transition-to keys
|
||||
const TRANSITION_ACCEPT = 'transition/accept';
|
||||
|
|
@ -138,9 +137,6 @@ export const loadData = params =>
|
|||
dispatch => {
|
||||
const saleId = new types.UUID(params.id);
|
||||
|
||||
// Current user is needed to render Topbar
|
||||
dispatch(fetchCurrentUser());
|
||||
|
||||
// Sale (i.e. transaction entity in API, but from buyers perspective) contains sale details
|
||||
return dispatch(fetchSale(saleId));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -87,8 +87,6 @@ const mapDispatchToProps = dispatch => {
|
|||
|
||||
const SalePage = connect(mapStateToProps, mapDispatchToProps)(injectIntl(SalePageComponent));
|
||||
|
||||
SalePage.loadData = params => {
|
||||
return loadData(params);
|
||||
};
|
||||
SalePage.loadData = loadData;
|
||||
|
||||
export default SalePage;
|
||||
|
|
|
|||
|
|
@ -44,8 +44,6 @@ const TopbarComponent = props => {
|
|||
);
|
||||
};
|
||||
|
||||
TopbarComponent.defaultProps = { user: null };
|
||||
|
||||
const { bool, func, shape, arrayOf } = PropTypes;
|
||||
|
||||
TopbarComponent.propTypes = {
|
||||
|
|
@ -59,7 +57,7 @@ TopbarComponent.propTypes = {
|
|||
}).isRequired,
|
||||
|
||||
// from withFlattenedRoutes
|
||||
flattenedRoutes: arrayOf(propTypes.route),
|
||||
flattenedRoutes: arrayOf(propTypes.route).isRequired,
|
||||
};
|
||||
|
||||
const mapStateToProps = state => {
|
||||
|
|
|
|||
|
|
@ -100,8 +100,8 @@ export const login = (username, password) =>
|
|||
// just dispatches the login error action.
|
||||
return sdk
|
||||
.login({ username, password })
|
||||
.then(() => dispatch(fetchCurrentUser()))
|
||||
.then(() => dispatch(loginSuccess()))
|
||||
.then(() => dispatch(fetchCurrentUser()))
|
||||
.catch(e => dispatch(loginError(e)));
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -105,8 +105,8 @@ describe('Auth duck', () => {
|
|||
expect(sdk.login.mock.calls).toEqual([[{ username, password }]]);
|
||||
expect(dispatch.mock.calls).toEqual([
|
||||
[loginRequest()],
|
||||
[expect.anything()], // fetchCurrentUser
|
||||
[loginSuccess()],
|
||||
[expect.anything()], // fetchCurrentUser
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -83,11 +83,10 @@ export const fetchCurrentUser = () =>
|
|||
.me()
|
||||
.then(response => {
|
||||
dispatch(usersMeSuccess(response.data.data));
|
||||
return response;
|
||||
})
|
||||
.catch(e => {
|
||||
// TODO: dispatch flash message
|
||||
dispatch(usersMeError(e));
|
||||
throw e;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import {
|
|||
showMarketplace,
|
||||
showUsers,
|
||||
} from './ducks/sdk.duck';
|
||||
import { fetchCurrentUser } from './ducks/user.duck';
|
||||
import routeConfiguration from './routesConfiguration';
|
||||
|
||||
import './index.css';
|
||||
|
|
@ -41,6 +42,7 @@ const render = store => {
|
|||
const info = authInfoLoaded ? Promise.resolve({}) : store.dispatch(authInfo());
|
||||
info
|
||||
.then(() => {
|
||||
store.dispatch(fetchCurrentUser());
|
||||
ReactDOM.render(<ClientApp store={store} />, document.getElementById('root'));
|
||||
})
|
||||
.catch(e => {
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@ const routesConfiguration = [
|
|||
name: 'CheckoutPage',
|
||||
setInitialValues: initialValues => CheckoutPage.setInitialValues(initialValues),
|
||||
component: props => <CheckoutPage {...props} />,
|
||||
loadData: (params, search) => CheckoutPage.loadData(params, search),
|
||||
},
|
||||
{
|
||||
auth: true,
|
||||
|
|
@ -91,7 +90,6 @@ const routesConfiguration = [
|
|||
exact: true,
|
||||
name: 'NewListingPage',
|
||||
component: props => <EditListingPage {...props} type={'new'} />,
|
||||
loadData: (params, search) => EditListingPage.loadData(params, search),
|
||||
},
|
||||
{
|
||||
auth: true,
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@
|
|||
"InboxPage.stateRejected": "Rejected",
|
||||
"InboxPage.title": "Inbox",
|
||||
"ListingPage.ctaButtonMessage": "Book {title}",
|
||||
"ListingPage.editListing": "Edit listing",
|
||||
"ListingPage.loadingListingData": "Loading listing data",
|
||||
"ListingPage.noListingData": "Could not find listing data",
|
||||
"LoginForm.emailLabel": "Email",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue