import { useState } from 'react';

import TextField from '@mui/material/TextField';
// ----------------------------------------------------------------------

type BoolFilterProps = {
    label: string;
}

const isNumbers = (str: string) => /^[0-9]*$/.test(str);

export function IntFilter({ label }: BoolFilterProps) {
    const [val, setVal] = useState("");

    const onInputChange = (event: any) => {
        const value = event.target.value;
        if (isNumbers(value)) {
            setVal(value);
        }
    };

    return <TextField label={label} value={val} onChange={onInputChange} variant="filled" />;
}

export function DecimalFilter({ label }: BoolFilterProps) {
    return <TextField type="number" label={label} variant="filled" />;
}