import { ChatListItem, Responsible } from 'src/types/chats';
import { Position } from 'src/types/position';
import { Pagination } from 'src/types/services';

export enum TicketAgentStatus {
  UNASSIGNED = 'UNASSIGNED',
  ASSIGNED = 'ASSIGNED',
  PENDING = 'PENDING',
  CLOSED = 'CLOSED',
}

export type Topic = Position & {
  id: number;
  name: string;
  faq: {
    body: string;
  };
  responsibles: Responsible[];
  autoMessage: string;
  deleted: boolean;
  notifyByEmail: boolean;
  status: string;
};

export type TicketAgentStats = {
  amountOfTicketsWhichNeedAttention: number;
  isResponsible: boolean;
};

// Request data
export type TicketData = {
  topicId: number;
  subject: string;
  firstMessage: string;
};

export type FeedbackData = {
  value: number;
};

// Responses
export type CreateTicketResponse = ChatListItem;

export const ERROR_CODE = {
  LOGGED_USER_RESPONSIBLE: 'LOGGED_USER_RESPONSIBLE',
};

// Sockets
export type CreateTicketSocket = ChatListItem;

export type TicketTopicUpdatedSocket = Topic;

export type TicketTopicDeletedSocket = { id: number };

export type DeleteUnassignedTicketSocket = ChatListItem;

export type ChatMessageAgentSocket = ChatListItem;

export type TopicOfTicketUpdatedSocket = {
  ticketId: number;
  oldTopicId: number;
  newTopicId: number;
  chatId: number;
  newTopicResponsibleIds: number[];
};

export type TicketsPaginationResponse = Pagination<ChatListItem[]>;

export type UpdateTicketAssignmentSocket = ChatListItem;
