import { LocationDescriptor } from 'history';
import React from 'react';
import { ConfirmationConfig, ConfirmationMode } from './ConfirmDialog';
import { MessageBarProps } from './MessageBar';

export type StationError = Pick<MessageBarProps, 'title'> & {
  /**
   * Optional body for the MessageBar
   * If the body type is a 'string', body will be wrapped in a 'p' element.
   */
  body?: string | React.ReactNode;
};

export type StationMessage = MessageBarProps & {
  /**
   * Optional body for the StationMessage
   * If the body type is a 'string', body will be wrapped in a 'p' element.
   */
  body?: string | React.ReactNode;
};

/**
 * Possible error options the engine will handle
 */
// eslint-disable-next-line @typescript-eslint/ban-types
export type ErrorType = StationError | string | Object | Error;

/** Properties to generate a link */
export interface LinkAction {
  /** Where to navigate to when the action is clicked. */
  path: LocationDescriptor<unknown>;
  /** If set to true, the link will open in a new tab. */
  openInNewTab?: boolean;
}

/**
 * Properties for Action click confirmation
 */
export interface ConfirmAction {
  /** If set to 'Simple', the action will require confirmation. If set to 'Advanced', action will require confirmation via a confirmation pop up. (default: 'None') */
  confirmationMode?: ConfirmationMode;
  /** Optional text overrides for the confirmation pop up. */
  confirmationConfig?: ConfirmationConfig;
}

/**
 * Default Action click event handler
 */
export type DefaultHandler = () =>
  | Promise<ErrorType | undefined | void>
  | ErrorType
  | undefined
  | void;
