From 878bb9266fec9dfcc8d3a28822cd6e55d8c505fe Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Fri, 7 Apr 2017 02:42:50 +0300 Subject: [PATCH] Add BookingDatesForm to ListingPage --- src/containers/ListingPage/ListingPage.css | 6 +++++- src/containers/ListingPage/ListingPage.js | 18 ++++++++++++++-- .../ListingPage/ListingPage.test.js | 21 ++++++++++++------- .../__snapshots__/ListingPage.test.js.snap | 11 +++++++--- 4 files changed, 42 insertions(+), 14 deletions(-) diff --git a/src/containers/ListingPage/ListingPage.css b/src/containers/ListingPage/ListingPage.css index fa6e4aaa..3eea1da6 100644 --- a/src/containers/ListingPage/ListingPage.css +++ b/src/containers/ListingPage/ListingPage.css @@ -67,7 +67,11 @@ background-color: #eee; } -.openDatePickerForm { +.bookingForm { + margin: 0 1rem; +} + +.openBookingForm { position: fixed; bottom: 0; left: 0; diff --git a/src/containers/ListingPage/ListingPage.js b/src/containers/ListingPage/ListingPage.js index 9843212c..12494fbe 100644 --- a/src/containers/ListingPage/ListingPage.js +++ b/src/containers/ListingPage/ListingPage.js @@ -6,6 +6,7 @@ import config from '../../config'; import { types } from '../../util/sdkLoader'; import { convertMoneyToNumber } from '../../util/currency'; import { Button, Map, ModalInMobile, PageLayout } from '../../components'; +import { BookingDatesForm } from '../../containers'; import { getListingsById } from '../../ducks/sdk.duck'; import { showListing } from './ListingPage.duck'; import css from './ListingPage.css'; @@ -39,9 +40,22 @@ export class ListingPageComponent extends Component { isBookingModalOpenOnMobile: tab && tab === 'book', pageClassNames: '', }; + + this.onSubmit = this.onSubmit.bind(this); this.togglePageClassNames = this.togglePageClassNames.bind(this); } + onSubmit(values) { + const { marketplaceData, params } = this.props; + const id = new UUID(params.id); + const listingsById = getListingsById(marketplaceData, [id]); + const currentListing = listingsById.length > 0 ? listingsById[0] : null; + + this.setState({ isBookingModalOpenOnMobile: false }); + // eslint-disable-next-line no-console + console.log('Submitting with bookedDates', values, ' and listing price', currentListing.attributes.price); + } + togglePageClassNames(className, addClass = true) { this.setState(prevState => { const prevPageClassNames = prevState.pageClassNames.split(' '); @@ -116,10 +130,10 @@ export class ListingPageComponent extends Component { title={bookBtnMessage} togglePageClassNames={this.togglePageClassNames} > - ModalInMobile content + {map ?
{map}
: null} -
+
diff --git a/src/containers/ListingPage/ListingPage.test.js b/src/containers/ListingPage/ListingPage.test.js index 8c76c2b1..b0ed9c03 100644 --- a/src/containers/ListingPage/ListingPage.test.js +++ b/src/containers/ListingPage/ListingPage.test.js @@ -11,14 +11,19 @@ const { UUID } = types; describe('ListingPage', () => { it('matches snapshot', () => { const marketplaceData = { entities: { listing: { listing1: createListing('listing1') } } }; - const tree = renderShallow( - l} - /> - ); + const props = { + flattenedRoutes: [], + location: { search: '' }, + history: { + push: () => console.log('HistoryPush called'), + }, + params: { slug: 'listing1-title', id: 'listing1' }, + marketplaceData, + intl: fakeIntl, + onLoadListing: () => {}, + }; + + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); diff --git a/src/containers/ListingPage/__snapshots__/ListingPage.test.js.snap b/src/containers/ListingPage/__snapshots__/ListingPage.test.js.snap index 762e291e..c6acbc7c 100644 --- a/src/containers/ListingPage/__snapshots__/ListingPage.test.js.snap +++ b/src/containers/ListingPage/__snapshots__/ListingPage.test.js.snap @@ -24,9 +24,14 @@ exports[`ListingPage matches snapshot 1`] = ` showAsModalMaxWidth={2500} title="ListingPage.ctaButtonMessage" togglePageClassNames={[Function]}> - - ModalInMobile content - +