Files
old-kivi/web/src/components/ListingDetails.js

127 lines
3.5 KiB
JavaScript
Raw Normal View History

2017-04-11 10:43:05 +02:00
import React from 'react'
import Gallery from './gallery'
import {formatPrice} from '../lib/helpers'
2017-04-11 14:23:58 +02:00
import ContactModal from './ContactModal';
2016-11-15 00:03:59 +01:00
export default class ListingDetails extends React.Component {
2017-03-31 14:31:56 +02:00
onReadMore (e) {
2017-04-11 10:43:05 +02:00
e.preventDefault()
this.props.dispatch({type: 'EXPAND_DESCRIPTION'})
2017-03-31 14:31:56 +02:00
}
2017-04-11 10:43:05 +02:00
onBackClick () {
this.props.dispatch({
type: 'UPDATE_ROUTE',
action: {
toDispatch: {
type: 'BACK_TO_RESULTS'
},
params: {
listingId: null
}
2017-04-09 19:34:08 +02:00
}
2017-04-11 10:43:05 +02:00
})
this.props.dispatch({type: 'BACK_TO_RESULTS'})
2016-11-15 00:03:59 +01:00
}
2017-03-31 14:31:56 +02:00
2017-04-11 14:23:58 +02:00
onContactClick () {
this.props.dispatch({
type: 'OPEN_CONTACT'
});
}
2017-04-11 10:43:05 +02:00
render () {
2017-04-11 14:23:58 +02:00
const {listing, descriptionExpanded, contactFormOpen} = this.props
2017-04-02 03:31:39 +02:00
if (!listing) {
2017-04-11 10:43:05 +02:00
return null
2017-04-02 03:31:39 +02:00
}
2017-04-11 10:43:05 +02:00
const descriptionClasses = descriptionExpanded
? 'ld-description expanded'
: 'ld-description'
const images = listing.images.map(image => ({
original: image,
thumbnail: image
}))
2017-04-02 03:31:39 +02:00
2016-11-15 00:03:59 +01:00
return (
<div className="ld-container">
<div className="ld-header">
<div className="back-to-results">
2017-04-11 10:43:05 +02:00
<button
className="back-to-results-btn"
onClick={this.onBackClick.bind(this)}
>
<i className="fa fa-arrow-left" aria-hidden="true" />
2016-11-15 00:03:59 +01:00
<span>
Nazad na rezultate
</span>
</button>
</div>
<button className="hide-listing">
2017-04-11 10:43:05 +02:00
<i className="fa fa-thumbs-o-down" aria-hidden="true" />
2016-11-15 00:03:59 +01:00
<span>
Sakrij
</span>
</button>
</div>
<div className="ld-details">
2017-04-02 03:31:39 +02:00
<Gallery
dispatch={this.props.dispatch}
images={listing.images}
2017-04-11 10:43:05 +02:00
imageIndex={this.props.imageIndex}
/>
2016-11-15 00:03:59 +01:00
<div className="ld-price-address-box">
<div className="ld-price">
2017-04-05 00:14:30 +02:00
{formatPrice(listing.price)}
2016-11-15 00:03:59 +01:00
</div>
<div className="ld-address">
2017-03-31 14:31:56 +02:00
<div className="">{listing.address}</div>
<div className="">{listing.location}</div>
2016-11-15 00:03:59 +01:00
</div>
</div>
<div className="ld-features">
<div className="ld-feature-box">
2017-04-11 10:43:05 +02:00
<i className="fa fa-bed" />
{listing.rooms} sobe
2016-11-15 00:03:59 +01:00
</div>
<div className="ld-feature-box">
2017-04-11 10:43:05 +02:00
<i className="fa fa-home" />
2017-03-31 14:31:56 +02:00
{listing.size}m2
2016-11-15 00:03:59 +01:00
</div>
<div className="ld-feature-box">
2017-04-11 10:43:05 +02:00
<i className="fa fa-home" />
{listing.floor}. sprat
2016-11-15 00:03:59 +01:00
</div>
<div className="ld-feature-box">
2017-04-11 10:43:05 +02:00
<i className="fa fa-home" />
--
2016-11-15 00:03:59 +01:00
</div>
</div>
<div className="ld-check-availability">
2017-04-11 14:23:58 +02:00
<button onClick={this.onContactClick.bind(this)}>Kontaktiraj</button>
2016-11-15 00:03:59 +01:00
</div>
2017-03-31 14:31:56 +02:00
<div className={descriptionClasses}>
{listing.longDescription}
2016-11-15 00:03:59 +01:00
</div>
2017-03-31 14:31:56 +02:00
{!descriptionExpanded
2017-04-11 10:43:05 +02:00
? <div className="ld-read-more">
<a href="" onClick={this.onReadMore.bind(this)}>
Pročitajte više
</a>
2017-03-31 14:31:56 +02:00
</div>
2017-04-11 10:43:05 +02:00
: null}
<div className="ld-footer" />
2016-11-15 00:03:59 +01:00
</div>
2017-04-11 14:23:58 +02:00
2017-04-12 13:08:06 +02:00
{contactFormOpen ? <ContactModal
2017-04-13 17:23:46 +02:00
listingId={this.props.listing._id}
2017-04-12 13:08:06 +02:00
contact={this.props.contact}
dispatch={this.props.dispatch} /> : null}
2017-04-11 10:43:05 +02:00
</div>
)
2016-11-15 00:03:59 +01:00
}
}