import { LabeledInput } from '@/components/ra-inputs/LabeledInput';
import { styled } from '@mui/material/styles';
import { DateTimeInputProps, DateTimeInput as RaDateTimeInput } from 'react-admin';

const StyledDateInput = styled(RaDateTimeInput, { slot: 'root' })(({ label }) => ({
  '& legend': {
    width: label === false ? 0 : 'auto'
  }
}));

function DateTimeInput(props: DateTimeInputProps): JSX.Element {
  return (
    /** @ts-ignore */
    <LabeledInput {...props}>
      {/** @ts-ignore */}
      <StyledDateInput />
    </LabeledInput>
  );
}

export { DateTimeInput };
export type { DateTimeInputProps };
