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

49 lines
1.6 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 { buildingUserFields, dataFields } from '../../config/data-fields-config';
import { CopyProps } from '../data-containers/category-view-props';
import { DataTitleCopyable } from './data-title';
2019-08-14 16:54:31 -04:00
interface LikeDataEntryProps {
mode: 'view' | 'edit' | 'multi-edit';
userValue: boolean;
aggregateValue: number;
copy: CopyProps;
onChange: (key: string, value: boolean) => void;
}
const LikeDataEntry: React.FunctionComponent<LikeDataEntryProps> = (props) => {
const fieldName = 'community_like';
2019-08-14 16:54:31 -04:00
return (
2021-08-12 16:11:00 -04:00
<>
<DataTitleCopyable
slug={fieldName}
title={buildingUserFields.community_like.title}
copy={props.copy}
/>
2021-08-12 16:11:00 -04:00
<label className="form-check-label">
<input className="form-check-input" type="checkbox"
name="like"
checked={!!props.userValue}
2021-08-12 16:11:00 -04:00
disabled={props.mode === 'view'}
onChange={e => props.onChange(fieldName, e.target.checked)}
/> Yes
2021-08-12 16:11:00 -04:00
</label>
<p>
2019-08-14 16:54:31 -04:00
{
(props.aggregateValue != null)?
(props.aggregateValue === 1)?
`${props.aggregateValue} person likes this building`
: `${props.aggregateValue} 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>
2021-08-12 16:11:00 -04:00
</>
2019-08-14 16:54:31 -04:00
);
2019-11-07 03:13:30 -05:00
};
2019-08-14 16:54:31 -04:00
export default LikeDataEntry;