From 9b133cdc38e809f18c6edc163a858fb98351f8e8 Mon Sep 17 00:00:00 2001 From: Hannu Lyytikainen Date: Tue, 11 Dec 2018 08:09:49 +0200 Subject: [PATCH] Change BookingPanel title handling Use title and sub title provided by a parent component. --- .../BookingPanel/BookingPanel.example.js | 6 +++-- src/components/BookingPanel/BookingPanel.js | 25 +++++++++---------- src/containers/ListingPage/ListingPage.js | 8 +++++- .../__snapshots__/ListingPage.test.js.snap | 22 ++++++++++------ src/translations/en.json | 6 ++--- src/translations/fr.json | 6 ++--- 6 files changed, 44 insertions(+), 29 deletions(-) diff --git a/src/components/BookingPanel/BookingPanel.example.js b/src/components/BookingPanel/BookingPanel.example.js index 686a9ec36e..589027c148 100644 --- a/src/components/BookingPanel/BookingPanel.example.js +++ b/src/components/BookingPanel/BookingPanel.example.js @@ -10,7 +10,8 @@ export const Default = { className: css.example, listing: createListing('listing_1'), handleBookingSubmit: values => console.log('Submit:', values), - title: title, + title: Booking title, + subTitle: 'Hosted by Author N', authorDisplayName: 'Author Name', onManageDisableScrolling: () => null, }, @@ -22,7 +23,8 @@ export const WithClosedListing = { className: css.example, listing: createListing('listing_1', { state: LISTING_STATE_CLOSED }), handleBookingSubmit: values => console.log('Submit:', values), - title: title, + title: Booking title, + subTitle: 'Hosted by Author N', authorDisplayName: 'Author Name', onManageDisableScrolling: () => null, }, diff --git a/src/components/BookingPanel/BookingPanel.js b/src/components/BookingPanel/BookingPanel.js index 3ff57a6c0a..bec513b007 100644 --- a/src/components/BookingPanel/BookingPanel.js +++ b/src/components/BookingPanel/BookingPanel.js @@ -57,6 +57,7 @@ const BookingPanel = props => { unitType, handleBookingSubmit, title, + subTitle, authorDisplayName, onManageDisableScrolling, timeSlots, @@ -72,6 +73,12 @@ const BookingPanel = props => { const { formattedPrice, priceTitle } = priceData(price, intl); const isBook = !!parse(location.search).book; + const subTitleText = !!subTitle + ? subTitle + : showClosedListingHelpText + ? intl.formatMessage({ id: 'BookingPanel.subTitleClosedListing' }) + : null; + const classes = classNames(rootClassName || css.root, className); return ( @@ -92,18 +99,8 @@ const BookingPanel = props => {
-

- -

-
- -
+

{title}

+ {subTitleText ?
{subTitleText}
: null}
{!isClosed ? ( ); + const bookingTitle = ( + + ); + const bookingSubTitle = intl.formatMessage({ id: 'ListingPage.bookingSubTitle' }); + const topbar = ; if (showListingError && showListingError.status === 404) { @@ -437,7 +442,8 @@ export class ListingPageComponent extends Component { isOwnListing={isOwnListing} unitType={unitType} handleBookingSubmit={handleBookingSubmit} - title={richTitle} + title={bookingTitle} + subTitle={bookingSubTitle} authorDisplayName={authorDisplayName} onManageDisableScrolling={onManageDisableScrolling} timeSlots={timeSlots} diff --git a/src/containers/ListingPage/__snapshots__/ListingPage.test.js.snap b/src/containers/ListingPage/__snapshots__/ListingPage.test.js.snap index 09ad09147c..847f36678d 100644 --- a/src/containers/ListingPage/__snapshots__/ListingPage.test.js.snap +++ b/src/containers/ListingPage/__snapshots__/ListingPage.test.js.snap @@ -305,15 +305,23 @@ exports[`ListingPage matches snapshot 1`] = ` } } onManageDisableScrolling={[Function]} + subTitle="ListingPage.bookingSubTitle" timeSlots={null} title={ - - - listing1 - - title - - + + + listing1 + + title + + , + } + } + /> } unitType="line-item/night" /> diff --git a/src/translations/en.json b/src/translations/en.json index 67ea3ca282..33d553a14d 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -67,13 +67,11 @@ "BookingDatesForm.requiredDate": "Oops, make sure your date is correct!", "BookingDatesForm.timeSlotsError": "Loading listing availability failed. Please refresh the page.", "BookingDatesForm.youWontBeChargedInfo": "You won't be charged yet", - "BookingPanel.bookingHelp": "Start by choosing your dates.", - "BookingPanel.bookingHelpClosedListing": "Sorry, this listing has been closed.", - "BookingPanel.bookingTitle": "Book {title}", "BookingPanel.closedListingButtonText": "Sorry, this listing has been closed.", "BookingPanel.ctaButtonMessage": "Request to book", "BookingPanel.hostedBy": "Hosted by {name}", "BookingPanel.perUnit": "per night", + "BookingPanel.subTitleClosedListing": "Sorry, this listing has been closed.", "CheckoutPage.bookingTimeNotAvailableMessage": "Unfortunately, the requested time is already booked.", "CheckoutPage.errorlistingLinkText": "the sauna page", "CheckoutPage.goToLandingPage": "Go to homepage", @@ -294,6 +292,8 @@ "ListingCard.unsupportedPrice": "({currency})", "ListingCard.unsupportedPriceTitle": "Unsupported currency ({currency})", "ListingPage.bannedUserDisplayName": "Banned user", + "ListingPage.bookingSubTitle": "Start by choosing your dates.", + "ListingPage.bookingTitle": "Book {title}", "ListingPage.closedListing": "This listing has been closed and can't be booked.", "ListingPage.contactUser": "Contact", "ListingPage.descriptionTitle": "About this sauna", diff --git a/src/translations/fr.json b/src/translations/fr.json index 84a4e6d561..fb0d7495ff 100644 --- a/src/translations/fr.json +++ b/src/translations/fr.json @@ -67,13 +67,11 @@ "BookingDatesForm.requiredDate": "Oups, vérifiez que la date est correcte", "BookingDatesForm.timeSlotsError": "Le chargement des disponibilités pour cette annonce a échoué. Veuillez rafraîchir la page.", "BookingDatesForm.youWontBeChargedInfo": "Vous ne serez pas facturé immédiatement", - "BookingPanel.bookingHelp": "À quelle date souhaiteriez-vous réserver ?", - "BookingPanel.bookingHelpClosedListing": "Navré, cette annonce est close.", - "BookingPanel.bookingTitle": "Réserver {title}", "BookingPanel.closedListingButtonText": "Navré, cette annonce est close.", "BookingPanel.ctaButtonMessage": "Réserver", "BookingPanel.hostedBy": "Proposé par {name}", "BookingPanel.perUnit": "par nuit", + "BookingPanel.subTitleClosedListing": "Navré, cette annonce est close.", "CheckoutPage.bookingTimeNotAvailableMessage": "Hélas, le créneau souhaité est déjà réservé.", "CheckoutPage.errorlistingLinkText": "la page de l'annonce", "CheckoutPage.goToLandingPage": "Aller sur la page d'accueil", @@ -294,6 +292,8 @@ "ListingCard.unsupportedPrice": "({currency})", "ListingCard.unsupportedPriceTitle": "Devise non supportée ({currency})", "ListingPage.bannedUserDisplayName": "Utilisateur banni", + "ListingPage.bookingSubTitle": "À quelle date souhaiteriez-vous réserver ?", + "ListingPage.bookingTitle": "Réserver {title}", "ListingPage.closedListing": "Cette annonce est close et ne peut être réservée.", "ListingPage.contactUser": "Envoyer un message", "ListingPage.descriptionTitle": "À propos de ce sauna",