docbrown/app/javascript/listings/singleListing/Header.jsx
Zachary Dixon cf2af6c2dc
Add dropdown menu to listings (#4184) [deploy]
* Resolves 2826, add dropdown menu to listings

* Fixed dropdown position

* Refactored single listing

* Revert schema.rb to master

* Fixed tests
2020-02-18 18:08:39 -05:00

34 lines
858 B
JavaScript

import PropTypes from 'prop-types';
import { h } from 'preact';
import listingPropTypes from './listingPropTypes';
import DropdownMenu from './DropdownMenu';
const Header = ({ listing, currentUserId, onTitleClick }) => {
const { id, user_id: userId, category, slug, title } = listing;
return (
<h3 className="single-classified-listing-header">
<a
href={`/listings/${category}/${slug}`}
data-no-instant
onClick={e => onTitleClick(e, listing)}
data-listing-id={id}
>
{title}
</a>
<DropdownMenu listing={listing} isOwner={currentUserId === userId} />
</h3>
);
};
Header.propTypes = {
listing: listingPropTypes.isRequired,
currentUserId: PropTypes.number,
onTitleClick: PropTypes.func.isRequired,
};
Header.defaultProps = {
currentUserId: null,
};
export default Header;