import { h, Component } from 'preact'; import PropTypes from 'prop-types'; import Header from './Header'; import AuthorInfo from './AuthorInfo'; import listingPropTypes from './listingPropTypes'; export class SingleListing extends Component { listingContent = (listing, currentUserId, onChangeCategory, onOpenModal, onAddTag) => { return (
); }; listingInline = (listing, currentUserId, onChangeCategory, onOpenModal, onAddTag) => { return (
{this.listingContent( listing, currentUserId, onChangeCategory, onOpenModal, onAddTag )}
); }; listingModal = (listing, currentUserId, onChangeCategory, onOpenModal, onAddTag) => { return (
{this.listingContent( listing, currentUserId, onChangeCategory, onOpenModal, onAddTag, )}
); }; render() { const { listing, currentUserId, onChangeCategory, onOpenModal, isOpen, onAddTag } = this.props; return ( isOpen ? this.listingModal( listing, currentUserId, onChangeCategory, onOpenModal, onAddTag ) : this.listingInline( listing, currentUserId, onChangeCategory, onOpenModal, onAddTag ) ); } } SingleListing.propTypes = { listing: listingPropTypes.isRequired, onOpenModal: PropTypes.func.isRequired, onChangeCategory: PropTypes.func.isRequired, isOpen: PropTypes.bool.isRequired, currentUserId: PropTypes.number, onAddTag: PropTypes.func.isRequired }; SingleListing.defaultProps = { currentUserId: null, }; SingleListing.displayName = 'SingleListing';