Skip to content

Commit

Permalink
Change BookingPanel title handling
Browse files Browse the repository at this point in the history
Use title and sub title provided by a parent component.
  • Loading branch information
lyyder committed Dec 11, 2018
1 parent b9fbf64 commit 9b133cd
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 29 deletions.
6 changes: 4 additions & 2 deletions src/components/BookingPanel/BookingPanel.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export const Default = {
className: css.example,
listing: createListing('listing_1'),
handleBookingSubmit: values => console.log('Submit:', values),
title: <span>title</span>,
title: <span>Booking title</span>,
subTitle: 'Hosted by Author N',
authorDisplayName: 'Author Name',
onManageDisableScrolling: () => null,
},
Expand All @@ -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: <span>title</span>,
title: <span>Booking title</span>,
subTitle: 'Hosted by Author N',
authorDisplayName: 'Author Name',
onManageDisableScrolling: () => null,
},
Expand Down
25 changes: 12 additions & 13 deletions src/components/BookingPanel/BookingPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const BookingPanel = props => {
unitType,
handleBookingSubmit,
title,
subTitle,
authorDisplayName,
onManageDisableScrolling,
timeSlots,
Expand All @@ -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 (
Expand All @@ -92,18 +99,8 @@ const BookingPanel = props => {
</div>

<div className={css.bookingHeading}>
<h2 className={css.bookingTitle}>
<FormattedMessage id="BookingPanel.bookingTitle" values={{ title }} />
</h2>
<div className={css.bookingHelp}>
<FormattedMessage
id={
showClosedListingHelpText
? 'BookingPanel.bookingHelpClosedListing'
: 'BookingPanel.bookingHelp'
}
/>
</div>
<h2 className={css.bookingTitle}>{title}</h2>
{subTitleText ? <div className={css.bookingHelp}>{subTitleText}</div> : null}
</div>
{!isClosed ? (
<BookingDatesForm
Expand Down Expand Up @@ -149,6 +146,7 @@ BookingPanel.defaultProps = {
rootClassName: null,
className: null,
isOwnListing: false,
subTitle: null,
unitType: config.bookingUnitType,
timeSlots: null,
fetchTimeSlotsError: null,
Expand All @@ -161,7 +159,8 @@ BookingPanel.propTypes = {
isOwnListing: bool,
unitType: propTypes.bookingUnitType,
handleBookingSubmit: func.isRequired,
title: oneOfType([object, string]),
title: oneOfType([object, string]).isRequired,
subTitle: oneOfType([object, string]),
authorDisplayName: string.isRequired,
onManageDisableScrolling: func.isRequired,
timeSlots: arrayOf(propTypes.timeSlot),
Expand Down
8 changes: 7 additions & 1 deletion src/containers/ListingPage/ListingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ export class ListingPageComponent extends Component {
</span>
);

const bookingTitle = (
<FormattedMessage id="ListingPage.bookingTitle" values={{ title: richTitle }} />
);
const bookingSubTitle = intl.formatMessage({ id: 'ListingPage.bookingSubTitle' });

const topbar = <TopbarContainer />;

if (showListingError && showListingError.status === 404) {
Expand Down Expand Up @@ -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}
Expand Down
22 changes: 15 additions & 7 deletions src/containers/ListingPage/__snapshots__/ListingPage.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,23 @@ exports[`ListingPage matches snapshot 1`] = `
}
}
onManageDisableScrolling={[Function]}
subTitle="ListingPage.bookingSubTitle"
timeSlots={null}
title={
<span>
listing1
title
</span>
<FormattedMessage
id="ListingPage.bookingTitle"
values={
Object {
"title": <span>
listing1
title
</span>,
}
}
/>
}
unitType="line-item/night"
/>
Expand Down
6 changes: 3 additions & 3 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions src/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 9b133cd

Please sign in to comment.