import { AxiosError } from 'axios';

export type Pagination<TData> = {
  limit: number;
  page: number;
  totalPages: number;
  count: number;
  items: TData;
  cursor?: string;
};

export type CursorPagination<TData> = {
  cursor: string | null;
  items: TData;
};

export enum ResponseCode {
  NO_FORM_ATTEMPTS_AVAILABLE = 'NO_FORM_ATTEMPTS_AVAILABLE',
  TOKEN_EXPIRED = 'TOKEN_EXPIRED',
  ACCESS_DENIED = 'ACCESS_DENIED',
  GROUP_POST_NOT_FOUND = 'GROUP_POST_NOT_FOUND',
  POST_NOT_FOUND = 'POST_NOT_FOUND',
}

export type ResponseError = {
  code: string;
  message: string;
};

export type RequestError = AxiosError<ResponseError>;

export type Request = (...args: any) => any;

export type RequestSuccess<T extends Request> = Awaited<ReturnType<T>>;
