export interface IApiErrorState {
    isError: boolean;
    errorMessage: string;
    error?: IAPIError;
}
export interface IApiResponseDetails<T> extends IApiErrorState {
    data: T;
    isFetching: boolean;
}

export interface IApiCreateState extends IApiErrorState {
    isCreating: boolean;
}
export interface IApiUpdateState extends IApiErrorState {
    isUpdating: boolean;
}
export interface IApiDeleteState extends IApiErrorState {
    isDeleting: boolean;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export interface CustomOptionProps<T> {
    children?: JSX.Element;
    isNonActionable?: boolean;
    isNotSearchable?: boolean;
    isNotSelectable?: boolean;
    actionItem?: React.ReactElement;
}
export interface IOption<T> extends CustomOptionProps<T> {
    label: string;
    value: T;
    additionalInfo?: string | JSX.Element | JSX.Element[];
    disabled?: boolean;
    className?: string;
}
export type WithCustomOptions<T> = Partial<T> & CustomOptionProps<T>;

export type ExtractTypeNames<O, T> = { [K in keyof O]: O[K] extends T ? K : never }[keyof O];
export type ExtractedType<O, T> = Pick<O, ExtractTypeNames<O, T>>;
export type KeyOfExtractedType<O, T> = keyof ExtractedType<O, T>;

export interface IDClassNameProps {
    id?: string;
    className?: string;
}
export interface IMainSectionProps extends IDClassNameProps {
    sectionRef?: React.MutableRefObject<HTMLDivElement>;
}
export interface IAction<T, P> {
    type: T;
    payload?: Partial<P>;
}

// Jwt Token Related
export interface IJwtRealmAccess {
    roles: string[];
}
export interface IJwtAccount {
    roles: string[];
}
export interface ResourceAccess {
    account: IJwtAccount;
}
export interface IPortalJwtToken {
    jti: string;
    exp: number;
    nbf: number;
    iat: number;
    iss: string;
    aud: string;
    sub: string;
    typ: string;
    azp: string;
    nonce: string;
    auth_time: number;
    session_state: string;
    acr: string;
    'allowed-origins': string[];
    realm_access: IJwtRealmAccess;
    resource_access: ResourceAccess;
    REDHAT_LOGIN: string;
    lastName: string;
    account_number: string;
    country: string;
    employeeId: string;
    preferred_username: string;
    firstName: string;
    account_id: string;
    user_id: string;
    organization_id: string;
    siteId: string;
    siteID: string;
    portal_id: string;
    region: string;
    lang: string;
    RHAT_LOGIN: string;
    email: string;
    username: string;
}

export interface IFacetResponse {
    value: string;
    count: number;
    field?: string;
}

export interface IKeyValue<T> {
    key: string;
    value: T;
}

export interface IFieldValue {
    field: string;
    value: string;
}

export interface ISolrResponse<T> {
    docs: T[];
    numFound: number;
    start: number;
}
export interface ILabelValue {
    label: string;
    value: string;
}

export interface IPaginationInfo {
    pageSize: number;
    currentPage: number;
}

export interface IAPIError extends Error {
    status?: number;
    statusText?: string;
}

export interface ITabToRender<T> {
    title: T;
    key: string;
    'data-tracking-id': string;
    onClick?: (e: any) => void;
    component: JSX.Element;
    routePath: string;
    ref?: React.MutableRefObject<HTMLDivElement>;
    id?: string;
}

export interface ICaseDetailsPageParams {
    caseNumber: string;
    activeTab: string;
}

export interface IDropdownOptionItem {
    value: string;
    key: string;
    isNotSearchable?: boolean;
    isNonActionable?: boolean;
    isNotSelectable?: boolean;
    children?: string | React.ReactNode;
}

export type SelectValidatedType = 'success' | 'warning' | 'error' | 'default';
