2020-03-27 17:06:02 -08:00
|
|
|
import React from 'react'
|
|
|
|
|
import PropTypes from 'prop-types'
|
2021-07-17 09:15:32 -08:00
|
|
|
import { useRecordContext } from 'react-admin'
|
2024-09-28 07:54:36 -08:00
|
|
|
import { formatRange } from './formatRange'
|
2020-03-27 17:06:02 -08:00
|
|
|
|
2021-07-17 09:15:32 -08:00
|
|
|
export const RangeField = ({ className, source, ...rest }) => {
|
|
|
|
|
const record = useRecordContext(rest)
|
2020-10-30 11:46:34 -08:00
|
|
|
return <span className={className}>{formatRange(record, source)}</span>
|
2020-03-27 17:06:02 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RangeField.propTypes = {
|
|
|
|
|
label: PropTypes.string,
|
|
|
|
|
record: PropTypes.object,
|
|
|
|
|
source: PropTypes.string.isRequired,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RangeField.defaultProps = {
|
|
|
|
|
addLabel: true,
|
|
|
|
|
}
|