import PropTypes from 'prop-types';
import { h } from 'preact';
export const SingleListing = ({
listing,
onAddTag,
currentUserId,
onChangeCategory,
onOpenModal,
isOpen,
}) => {
const tagLinks = listing.tag_list.map(tag => (
onAddTag(e, tag)}
data-no-instant
>
{tag}
));
const editButton =
currentUserId === listing.user_id ? (
・edit
) : (
・report abuse
);
const locationText = listing.location ? (
・
{listing.location}
) : (
''
);
const definedClass = isOpen
? 'single-classified-listing single-classified-listing--opened'
: 'single-classified-listing';
const listingCard = () => {
return (
);
};
return listingCard();
};
SingleListing.propTypes = {
listing: PropTypes.shape({
id: PropTypes.number,
category: PropTypes.string,
contact_via_connect: PropTypes.bool,
location: PropTypes.string,
processed_html: PropTypes.string,
slug: PropTypes.string,
title: PropTypes.string,
user_id: PropTypes.number,
tag_list: PropTypes.arrayOf(PropTypes.string),
author: PropTypes.shape({
name: PropTypes.string.isRequired,
username: PropTypes.string.isRequired,
profile_image_90: PropTypes.string.isRequired,
}),
}).isRequired,
onAddTag: PropTypes.func.isRequired,
onOpenModal: PropTypes.func.isRequired,
onChangeCategory: PropTypes.func.isRequired,
isOpen: PropTypes.bool.isRequired,
currentUserId: PropTypes.number,
};