import { IResponse } from "../../../../types/response.types";

export type CreateTaskType = {
  title: string;
  taskPhaseId: string;
  order: number;
  projectId: string;
  userIds?: string[];
};

export type TaskItemType = {
  id: string;
  title: string;
  taskPhaseId: string;
  order?: number;
  priority?: number;
  createdAt?: string;
  updatedAt?: string;
  description?: string | null;
  color?: string | null;
  startDate?: string | null;
  endDate?: string | null;
  tag?: string;
  dateRange?: string;
  attachments?: number;
  checklistDone?: number;
  checklistTotal?: number;
};

export type TaskPhaseTasksPagerType = {
  limit: number;
  nextCursor: string | null;
  previousCursor: string | null;
  hasNextPage: boolean;
  hasPreviousPage: boolean;
};

export type TaskPhaseTasksDataType = {
  items: TaskItemType[];
  pager: TaskPhaseTasksPagerType;
};

export type TaskLabelType = {
  id: string;
  title: string;
  color: string;
};

export type CreateTaskRemarkType = {
  title: string;
  color: string;
  taskId: string;
};

export interface CreateTaskRemarkResponse extends IResponse<{ remark: TaskLabelType }> {
  statusCode: number;
}

export type TaskUserType = {
  id: string;
  firstName: string;
  lastName: string;
  profilePic?: string;
};

export type TaskChecklistItemType = {
  id: string;
  title: string;
  isDone: boolean;
};

export type CreateCheckListItemType = {
  title: string;
  isDone: boolean;
  taskId: string;
};

export interface CreateCheckListItemResponse extends IResponse<{ checkListItem: TaskChecklistItemType }> {
  statusCode: number;
}

export type UpdateCheckListItemType = {
  isDone: boolean;
};

export interface UpdateCheckListItemResponse extends IResponse<{ checkListItem: TaskChecklistItemType }> {
  statusCode: number;
}

export type TaskChecklistType = {
  id: string;
  title: string;
  items: TaskChecklistItemType[];
};

export type TaskAttachmentType = {
  id: string;
  title: string;
  type: "file" | "link";
  file?: string;
  createdAt?: string;
};

export type CreateTaskAttachmentType = {
  file: string;
  title: string;
  type: "file" | "link";
  taskId: string;
};

export type TaskDetailType = {
  id: string;
  createdAt: string;
  updatedAt: string;
  title: string;
  description?: string | null;
  color?: string | null;
  taskPhaseId: string;
  order?: number;
  projectId?: string;
  startDate?: string | null;
  endDate?: string | null;
  labels?: TaskLabelType[];
  remarks?: TaskLabelType[];
  users?: TaskUserType[];
  checkListItems?: TaskChecklistItemType[];
  checkListItemCount?: number;
  completedCheckListItemCount?: number;
  attachments?: TaskAttachmentType[];
};

export type ChangeTaskPhaseType = {
  taskPhaseId: string;
};

export type UpdateTaskType = Partial<
  Pick<TaskDetailType, "title" | "description" | "taskPhaseId" | "order" | "startDate" | "endDate">
> & {
  color?: string | null;
  userIds?: string[];
};

export interface GetTaskDetailResponse extends IResponse<TaskDetailType> {
  statusCode: number;
}

export interface GetTasksByTaskPhaseResponse extends IResponse<TaskPhaseTasksDataType> {
  statusCode: number;
}
