// Tipos

import { type InfiniteData } from 'react-query';

import { type AxiosResponse } from 'axios';

import { type Pagination } from 'src/types/services';

export enum DocumentErrorCodes {
  SIGNATURE_INVALID_COORDINATES = 'SIGNATURE_INVALID_COORDINATES',
}

export enum SignatureStatus {
  PENDING = 'PENDING',
  SIGNATURE_NOT_NEEDED = 'SIGNATURE_NOT_NEEDED',
  SIGNED = 'SIGNED',
  SIGNED_IN_AGREEMENT = 'SIGNED_IN_AGREEMENT',
  SIGNED_IN_DISAGREEMENT = 'SIGNED_IN_DISAGREEMENT',
}

export type Document = {
  id: number;
  name: string;
  source: string;
  createdAt: string;
  updatedAt: string;
  signatureStatus: SignatureStatus | null;
  extension: string;
  size: string;
  folderId: number;
  ownerId: number;
  allowDisagreement?: boolean;
  signatureDate: string;
  canBeSigned: boolean;
};

export type Folder = {
  id: number;
  name: string;
  instanceId: number;
  createdAt: string;
  updatedAt: string;
  newDocuments: number;
  type: 'FOLDER';
};

export type DocumentNotifications = {
  newSignatureNotNeededDocumentsNotifications: number;
  pendingSignatureNotifications: number;
};

// Response

export type FolderResponse = Folder;

export type DocumentResponse = Document;

export type FolderListResponse = Pagination<Folder[]>;

export type DocumentListResponse = Pagination<Document[]>;

export type DocumentsInfiniteData<T> = InfiniteData<AxiosResponse<T>>;

export type DocumentSignSubmitData = {
  id: number | string;
  signatureUrl: string;
  inDisagreement?: boolean;
};

export enum VisitedFrom {
  PUSH_NOTIFICATION = 'PUSH_NOTIFICATION',
  NAVBAR = 'NAVBAR',
}
