flex-template-web/src/containers/ListingPage/SectionHeading.js
Vesa Luusua b1eb69f6d3 Refactored className usage for InlineTextButton
They are changed to use rootClassName for consistency
and protection against future bundling order changes.
2019-02-19 15:49:49 +02:00

59 lines
1.7 KiB
JavaScript

import React from 'react';
import { FormattedMessage } from 'react-intl';
import { InlineTextButton } from '../../components';
import { LINE_ITEM_NIGHT, LINE_ITEM_DAY } from '../../util/types';
import config from '../../config';
import css from './ListingPage.css';
const SectionHeading = props => {
const {
priceTitle,
formattedPrice,
richTitle,
category,
hostLink,
showContactUser,
onContactUser,
} = props;
const unitType = config.bookingUnitType;
const isNightly = unitType === LINE_ITEM_NIGHT;
const isDaily = unitType === LINE_ITEM_DAY;
const unitTranslationKey = isNightly
? 'ListingPage.perNight'
: isDaily
? 'ListingPage.perDay'
: 'ListingPage.perUnit';
return (
<div className={css.sectionHeading}>
<div className={css.desktopPriceContainer}>
<div className={css.desktopPriceValue} title={priceTitle}>
{formattedPrice}
</div>
<div className={css.desktopPerUnit}>
<FormattedMessage id={unitTranslationKey} />
</div>
</div>
<div className={css.heading}>
<h1 className={css.title}>{richTitle}</h1>
<div className={css.author}>
{category}
<FormattedMessage id="ListingPage.hostedBy" values={{ name: hostLink }} />
{showContactUser ? (
<span className={css.contactWrapper}>
<span className={css.separator}></span>
<InlineTextButton rootClassName={css.contactLink} onClick={onContactUser}>
<FormattedMessage id="ListingPage.contactUser" />
</InlineTextButton>
</span>
) : null}
</div>
</div>
</div>
);
};
export default SectionHeading;