import { FormControl } from '@mui/material';

import CustomHelperText from '../Base/CustomHelperText';
import CustomLabel from '../Base/CustomLabel';
import CustomRangeDatePicker from '../Base/CustomRangeDatePicker';

import { type RangeDatePickerProps } from './types';

const RangeDatePicker = ({
  sx = {},
  label,
  value,
  onChange,
  helperText,
  errorText,
  error,
  fullWidth = true,
  disabled = false,
  ...props
}: RangeDatePickerProps) => {
  return (
    <FormControl
      error={error}
      fullWidth={fullWidth}
      disabled={disabled}
      sx={sx}
    >
      <CustomLabel label={label} />
      <CustomRangeDatePicker
        value={value}
        onChange={onChange}
        disabled={disabled}
        error={error}
        {...props}
      />
      <CustomHelperText helperText={error ? errorText : helperText} />
    </FormControl>
  );
};

export type { RangeDatePickerProps };

export default RangeDatePicker;
