2019-08-14 16:54:31 -04:00
|
|
|
import React, { Fragment } from 'react';
|
|
|
|
import { NavLink } from 'react-router-dom';
|
|
|
|
|
2021-08-22 21:26:58 -04:00
|
|
|
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
|
|
|
|
2019-10-18 10:06:50 -04:00
|
|
|
|
|
|
|
interface LikeDataEntryProps {
|
|
|
|
mode: 'view' | 'edit' | 'multi-edit';
|
2021-08-22 21:26:58 -04:00
|
|
|
userValue: boolean;
|
|
|
|
aggregateValue: number;
|
|
|
|
copy: CopyProps;
|
|
|
|
onChange: (key: string, value: boolean) => void;
|
2019-10-18 10:06:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
const LikeDataEntry: React.FunctionComponent<LikeDataEntryProps> = (props) => {
|
2021-08-22 21:26:58 -04:00
|
|
|
const fieldName = 'community_like';
|
|
|
|
|
2019-08-14 16:54:31 -04:00
|
|
|
return (
|
2021-08-12 16:11:00 -04:00
|
|
|
<>
|
2021-08-22 21:26:58 -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"
|
2021-08-22 21:26:58 -04:00
|
|
|
checked={!!props.userValue}
|
2021-08-12 16:11:00 -04:00
|
|
|
disabled={props.mode === 'view'}
|
2021-08-22 21:26:58 -04:00
|
|
|
onChange={e => props.onChange(fieldName, e.target.checked)}
|
|
|
|
/> Yes
|
2021-08-12 16:11:00 -04:00
|
|
|
</label>
|
2019-08-23 12:35:17 -04:00
|
|
|
<p>
|
2019-08-14 16:54:31 -04:00
|
|
|
{
|
2021-08-22 21:26:58 -04:00
|
|
|
(props.aggregateValue != null)?
|
|
|
|
(props.aggregateValue === 1)?
|
|
|
|
`${props.aggregateValue} person likes this building`
|
|
|
|
: `${props.aggregateValue} 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>
|
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;
|