2022-12-16 15:00:01 +01:00
|
|
|
import { NumberInput } from '@mantine/core';
|
2022-08-27 15:58:36 +02:00
|
|
|
import { useEffect } from 'react';
|
2022-10-27 14:22:15 +02:00
|
|
|
import { INumber } from '../../../../interfaces/dialog';
|
2022-09-08 12:00:41 +02:00
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
2022-06-19 14:57:03 +02:00
|
|
|
|
|
|
|
|
interface Props {
|
2022-08-09 23:50:14 +02:00
|
|
|
row: INumber;
|
2022-06-19 14:57:03 +02:00
|
|
|
index: number;
|
2022-08-09 23:50:14 +02:00
|
|
|
handleChange: (value: number, index: number) => void;
|
2022-06-19 14:57:03 +02:00
|
|
|
}
|
|
|
|
|
|
2022-08-09 23:50:14 +02:00
|
|
|
const NumberField: React.FC<Props> = (props) => {
|
2022-08-05 15:10:37 +02:00
|
|
|
useEffect(() => {
|
2022-08-27 15:54:43 +02:00
|
|
|
if (props.row.default) props.handleChange(props.row.default, props.index);
|
2022-08-05 15:10:37 +02:00
|
|
|
}, []);
|
|
|
|
|
|
2022-06-19 14:57:03 +02:00
|
|
|
return (
|
2022-12-16 15:00:01 +01:00
|
|
|
<NumberInput
|
|
|
|
|
label={props.row.label}
|
|
|
|
|
description={props.row.description}
|
|
|
|
|
defaultValue={props.row.default}
|
|
|
|
|
min={props.row.min}
|
|
|
|
|
max={props.row.max}
|
|
|
|
|
disabled={props.row.disabled}
|
|
|
|
|
onChange={(value) => props.handleChange(value as number, props.index)}
|
|
|
|
|
icon={props.row.icon && <FontAwesomeIcon icon={props.row.icon} fixedWidth />}
|
|
|
|
|
/>
|
2022-06-19 14:57:03 +02:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-09 23:50:14 +02:00
|
|
|
export default NumberField;
|