colouring-montreal/app/src/frontend/building/data-components/like-data-entry.tsx

53 lines
1.9 KiB
TypeScript
Raw Normal View History

2019-08-14 16:54:31 -04:00
import React, { Fragment } from 'react';
import { NavLink } from 'react-router-dom';
import Tooltip from '../../components/tooltip';
import { Category } from '../../config/categories-config';
2019-08-14 16:54:31 -04:00
interface LikeDataEntryProps {
mode: 'view' | 'edit' | 'multi-edit';
userLike: boolean;
totalLikes: number;
onLike: (userLike: boolean) => void;
}
const LikeDataEntry: React.FunctionComponent<LikeDataEntryProps> = (props) => {
2019-08-14 16:54:31 -04:00
const data_string = JSON.stringify({like: true});
return (
<Fragment>
<div className="data-title">
2019-08-14 17:46:35 -04:00
<Tooltip text="People who like the building and think it contributes to the city." />
2019-08-14 16:54:31 -04:00
<div className="icon-buttons">
<NavLink
to={`/multi-edit/${Category.Community}?data=${data_string}`}
className="icon-button like">
Like more
2019-08-14 16:54:31 -04:00
</NavLink>
</div>
<label>Number of likes</label>
</div>
<p>
2019-08-14 16:54:31 -04:00
{
(props.totalLikes != null)?
(props.totalLikes === 1)?
`${props.totalLikes} person likes this building`
: `${props.totalLikes} people like this building`
: "0 people like this building so far - you could be the first!"
2019-08-14 16:54:31 -04:00
}
</p>
2019-10-16 15:34:29 -04:00
<label className="form-check-label">
<input className="form-check-input" type="checkbox"
name="like"
checked={!!props.userLike}
2019-10-16 15:34:29 -04:00
disabled={props.mode === 'view'}
onChange={e => props.onLike(e.target.checked)}
2019-10-16 15:34:29 -04:00
/>
I like this building and think it contributes to the city!
</label>
2019-08-14 16:54:31 -04:00
</Fragment>
);
2019-11-07 03:13:30 -05:00
};
2019-08-14 16:54:31 -04:00
export default LikeDataEntry;