forked from ddrilling/asb_cloud_front
Возможность enum.
Подстановка текста из словаря по ключевому значению.
This commit is contained in:
parent
f384981d7b
commit
3a15744a7a
@ -7,7 +7,7 @@ export const formatNumber = (value, format) =>
|
||||
? (+value).toFixed(format)
|
||||
: (+value).toPrecision(4)
|
||||
|
||||
export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format}) =>{
|
||||
export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format, enumeration}) => {
|
||||
const [val, setVal] = useState('---')
|
||||
const [arrowState, setArrowState] = useState({
|
||||
preVal: NaN,
|
||||
@ -21,6 +21,11 @@ export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format}) =>
|
||||
return
|
||||
}
|
||||
|
||||
if(enumeration && enumeration[value]){
|
||||
setVal(enumeration[value])
|
||||
return
|
||||
}
|
||||
|
||||
if(Number.isFinite(+value)){
|
||||
if ((isArrowVisible) && (arrowState.preTimestamp + 1000 < Date.now()))
|
||||
{
|
||||
@ -50,7 +55,7 @@ export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format}) =>
|
||||
}
|
||||
|
||||
setVal(value)
|
||||
},[value, isArrowVisible, arrowState, format])
|
||||
},[value, isArrowVisible, arrowState, format, enumeration])
|
||||
|
||||
let arrow = null
|
||||
if(isArrowVisible)
|
||||
|
Loading…
Reference in New Issue
Block a user