From 2c24b1a02a1eb2080f4f088bf5e2d3870320f12d Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Tue, 10 Apr 2018 15:40:13 +0300 Subject: [PATCH] Extract booking section into separate file --- src/containers/ListingPage/ListingPage.js | 94 ++--------- src/containers/ListingPage/SectionBooking.js | 98 +++++++++++ .../__snapshots__/ListingPage.test.js.snap | 152 ++++++++---------- 3 files changed, 179 insertions(+), 165 deletions(-) create mode 100644 src/containers/ListingPage/SectionBooking.js diff --git a/src/containers/ListingPage/ListingPage.js b/src/containers/ListingPage/ListingPage.js index 79713184..29ad247d 100644 --- a/src/containers/ListingPage/ListingPage.js +++ b/src/containers/ListingPage/ListingPage.js @@ -19,8 +19,6 @@ import { manageDisableScrolling, isScrollingDisabled } from '../../ducks/UI.duck import { AvatarLarge, AvatarMedium, - Button, - ModalInMobile, Page, NamedLink, NamedRedirect, @@ -30,7 +28,7 @@ import { LayoutWrapperFooter, Footer, } from '../../components'; -import { BookingDatesForm, TopbarContainer, NotFoundPage } from '../../containers'; +import { TopbarContainer, NotFoundPage } from '../../containers'; import { sendEnquiry, loadData, setInitialValues } from './ListingPage.duck'; import SectionImages from './SectionImages'; @@ -41,10 +39,9 @@ import SectionReviews from './SectionReviews'; import SectionHost from './SectionHost'; import SectionRulesMaybe from './SectionRulesMaybe'; import SectionMapMaybe from './SectionMapMaybe'; +import SectionBooking from './SectionBooking'; import css from './ListingPage.css'; -// This defines when ModalInMobile shows content as Modal -const MODAL_BREAKPOINT = 1023; const MIN_LENGTH_FOR_LONG_WORDS_IN_TITLE = 16; const { UUID } = sdkTypes; @@ -332,27 +329,8 @@ export class ListingPageComponent extends Component { }); const authorDisplayName = userDisplayName(ensuredAuthor, bannedUserDisplayName); - const bookBtnMessage = intl.formatMessage({ id: 'ListingPage.ctaButtonMessage' }); const { formattedPrice, priceTitle } = priceData(price, intl); - const showClosedListingHelpText = currentListing.id && isClosed; - const bookingHeading = ( -
-

- -

-
- -
-
- ); - const handleMobileBookModalClose = () => { closeBookModal(history, currentListing); }; @@ -498,60 +476,22 @@ export class ListingPageComponent extends Component { onManageDisableScrolling={onManageDisableScrolling} /> - - -
-

{richTitle}

-
- - - -
-
- - {bookingHeading} - {!isClosed ? ( - - ) : null} -
-
-
-
- {formattedPrice} -
-
- -
-
- - {!isClosed ? ( - - ) : ( -
- -
- )} -
+ /> diff --git a/src/containers/ListingPage/SectionBooking.js b/src/containers/ListingPage/SectionBooking.js new file mode 100644 index 00000000..c568689b --- /dev/null +++ b/src/containers/ListingPage/SectionBooking.js @@ -0,0 +1,98 @@ +import React from 'react'; +import { FormattedMessage } from 'react-intl'; +import { ModalInMobile, Button } from '../../components'; +import { BookingDatesForm } from '../../containers'; + +import css from './ListingPage.css'; + +// This defines when ModalInMobile shows content as Modal +const MODAL_BREAKPOINT = 1023; + +const SectionBooking = props => { + const { + listing, + isOwnListing, + isClosed, + isBook, + unitType, + price, + formattedPrice, + priceTitle, + handleBookingSubmit, + richTitle, + authorDisplayName, + handleBookButtonClick, + handleMobileBookModalClose, + onManageDisableScrolling, + } = props; + const showClosedListingHelpText = listing.id && isClosed; + return ( +
+ +
+

{richTitle}

+
+ + + +
+
+ +
+

+ +

+
+ +
+
+ {!isClosed ? ( + + ) : null} +
+
+
+
+ {formattedPrice} +
+
+ +
+
+ + {!isClosed ? ( + + ) : ( +
+ +
+ )} +
+
+ ); +}; + +export default SectionBooking; diff --git a/src/containers/ListingPage/__snapshots__/ListingPage.test.js.snap b/src/containers/ListingPage/__snapshots__/ListingPage.test.js.snap index 8e51d88c..8183998b 100644 --- a/src/containers/ListingPage/__snapshots__/ListingPage.test.js.snap +++ b/src/containers/ListingPage/__snapshots__/ListingPage.test.js.snap @@ -328,95 +328,71 @@ exports[`ListingPage matches snapshot 1`] = ` title="listing1 title" /> - -
-

- - listing1 - - title - -

-
- - - -
-
-
-

- - - listing1 - - title - - , - } - } - /> -

-
- -
-
- -
-
-
-
- 55 -
-
- -
-
- -
+ } + onManageDisableScrolling={[Function]} + price={ + Money { + "amount": 5500, + "currency": "USD", + } + } + priceTitle={55} + richTitle={ + + + listing1 + + title + + + } + unitType="line-item/night" + />