import React from "react" import { IconButton, SvgIcon } from "@mui/material" import { DataFilterType, FiltersMessage } from "../types/filter.type" import { FilterAutocompleteField, FilterInputContainer, FilterTextField } from "./style" export interface DataTableFilterBooleanProps { style?: React.CSSProperties, messages: FiltersMessage, value: DataFilterType | [DataFilterType, DataFilterType] onChange: (value: boolean | null) => void, } export const DataTableFilterBoolean: React.FC = ({ style, messages, value, onChange }) => { const getValue = () => { const bool = (v: any): boolean | null => { return typeof v === 'boolean' ? v : v === 'true' ? true : v === 'false' ? false : null } return Array.isArray(value) ? !value.length ? null : bool(value[0]) : bool(value) } const handleChange = (event: any, value: any) => { onChange(value) } const handleClear = () => { onChange(null) } return ( option ? messages.true : messages.false} value={getValue()} onChange={handleChange} renderInput={(params: any) => { let endAdornment = params.InputProps.endAdornment as any; const adornmentChildren = endAdornment && endAdornment.props && endAdornment.props.children ? endAdornment.props.children : null; if (adornmentChildren && Array.isArray(adornmentChildren) && adornmentChildren.length > 0) { endAdornment = adornmentChildren[adornmentChildren.length - 1]; } return ( ) }} /> ) } const CloseIcon = () => ( )