import { type SxProps } from '@mui/material';

export enum SelectedDate {
  START = 0,
  END = 1,
}

export type DateRange = { fromDate: Date | null; toDate: Date | null };

export type CustomRangePickerProps = {
  value: DateRange;
  onChange: (value: DateRange) => void;
  /* Function to format the date to display in the input */
  dateFormatter: (date: Date, format?: string) => string;
  sx?: SxProps;
  enableClear?: boolean;
  minDate?: Date;
  maxDate?: Date;
  /* Limit the difference between the start and end dates */
  minMaxDatesDifference?: number;
  datePlaceholder?: string;
  disabled?: boolean;
  error?: boolean;
  /* For now these props are mandatory to avoid relying on isolated i18n translations */
  slotProps: {
    CalendarHeader: {
      previousMonthText: string;
      nextMonthText: string;
      changeMonthText: string;
    };
    clearButtonAriaLabel?: string;
    openPickerButtonAriaLabel?: string;
    RangeSelector: {
      clearDatesText: string;
      applyDatesText: string;
    };
  };
};

export type CustomRangeSelectorProps = {
  anchorElement: HTMLElement | null;
  handleClose: () => void;
  value: DateRange;
  onChange: (value: DateRange) => void;
  minDate?: Date;
  maxDate?: Date;
  minMaxDatesDifference?: number;
  disabled?: boolean;
  slotProps: CustomRangePickerProps['slotProps'];
};
