* Change models and related files * Update controllers and specs * More renaming * Seek and destroy, I mean search and replace * Round up the stragglers * Ground control to Major Travis... * More fixes * PR feedback * Various fixes * Rename view * Fix list query builder * Unify request specs * Fix some API spec errors * Fix remaining API specs * Make spec conform to API * Fix leftover problems * Fix JS tests * Fix column name in select * Fix API specs * Fix search specs * Paging Mr. Travis
50 lines
1 KiB
JavaScript
50 lines
1 KiB
JavaScript
import PropTypes from 'prop-types';
|
|
import { h } from 'preact';
|
|
import listingPropTypes from './listingPropTypes';
|
|
|
|
const LocationText = ({ location }) => {
|
|
return location ? (
|
|
<a href={`/listings/?q=${location}`}>
|
|
{'・'}
|
|
{location}
|
|
</a>
|
|
) : (
|
|
''
|
|
);
|
|
};
|
|
|
|
LocationText.propTypes = {
|
|
location: PropTypes.string,
|
|
};
|
|
|
|
LocationText.defaultProps = {
|
|
location: null,
|
|
};
|
|
|
|
const AuthorInfo = ({ listing, onCategoryClick }) => {
|
|
const { category, location, author = {} } = listing;
|
|
const { username, name } = author;
|
|
return (
|
|
<div className="single-listing-author-info">
|
|
<a
|
|
href={`/listings/${category}`}
|
|
onClick={(e) => onCategoryClick(e, category)}
|
|
data-no-instant
|
|
>
|
|
{category}
|
|
</a>
|
|
<LocationText location={location} />・<a href={`/${username}`}>{name}</a>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
AuthorInfo.propTypes = {
|
|
listing: listingPropTypes.isRequired,
|
|
onCategoryClick: PropTypes.func,
|
|
};
|
|
|
|
AuthorInfo.defaultProps = {
|
|
onCategoryClick: () => {},
|
|
};
|
|
|
|
export default AuthorInfo;
|