Format boolean values in edit history

This commit is contained in:
Maciej Ziarkowski 2019-11-06 15:39:44 +00:00
parent 5a3c3e6f15
commit ffcf31cb34

View File

@ -6,12 +6,19 @@ interface FieldEditSummaryProps {
oldValue: any;
}
function formatValue(value: any) {
if(typeof value === 'boolean') {
return value ? 'Yes' : 'No';
}
return value;
}
const FieldEditSummary: React.FunctionComponent<FieldEditSummaryProps> = props => (
<>
{props.title}:&nbsp;
<code title="Value before edit" className='edit-history-diff old'>{props.oldValue}</code>
<code title="Value before edit" className='edit-history-diff old'>{formatValue(props.oldValue)}</code>
&nbsp;
<code title="Value after edit" className='edit-history-diff new'>{props.value}</code>
<code title="Value after edit" className='edit-history-diff new'>{formatValue(props.value)}</code>
</>
);