2019-08-14 16:54:31 -04:00
|
|
|
import React, { Fragment } from 'react';
|
|
|
|
import { NavLink } from 'react-router-dom';
|
|
|
|
|
|
|
|
import Tooltip from '../../components/tooltip';
|
|
|
|
|
2019-10-18 10:06:50 -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>
|
2019-08-23 12:35:17 -04:00
|
|
|
<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
|
2019-09-08 20:11:45 -04:00
|
|
|
to={`/multi-edit/like?data=${data_string}`}
|
2019-08-23 12:35:17 -04:00
|
|
|
className="icon-button like">
|
|
|
|
Like more
|
2019-08-14 16:54:31 -04:00
|
|
|
</NavLink>
|
|
|
|
</div>
|
2019-08-23 12:35:17 -04:00
|
|
|
<label>Number of likes</label>
|
|
|
|
</div>
|
|
|
|
<p>
|
2019-08-14 16:54:31 -04:00
|
|
|
{
|
2019-10-18 10:06:50 -04:00
|
|
|
(props.totalLikes != null)?
|
|
|
|
(props.totalLikes === 1)?
|
|
|
|
`${props.totalLikes} person likes this building`
|
|
|
|
: `${props.totalLikes} people like this building`
|
2019-08-23 12:35:17 -04:00
|
|
|
: "0 people like this building so far - you could be the first!"
|
2019-08-14 16:54:31 -04:00
|
|
|
}
|
2019-08-23 12:35:17 -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"
|
2019-10-18 10:06:50 -04:00
|
|
|
checked={!!props.userLike}
|
2019-10-16 15:34:29 -04:00
|
|
|
disabled={props.mode === 'view'}
|
2019-10-18 10:06:50 -04:00
|
|
|
onChange={e => props.onLike(e.target.checked)}
|
2019-10-16 15:34:29 -04:00
|
|
|
/>
|
2019-08-23 12:35:17 -04:00
|
|
|
I like this building and think it contributes to the city!
|
|
|
|
</label>
|
2019-08-14 16:54:31 -04:00
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default LikeDataEntry;
|