import { type Attachment } from 'src/types/attachments';
import { type Comment } from 'src/types/comments';
import { type Reaction } from 'src/types/reaction';
import { type User } from 'src/types/user';
import { type PaginationParams } from 'src/utils/pagination';

export type Category = {
  color: string;
  coverPictureUrl?: string;
  id: number;
  name: string;
  originalCoverPictureUrl?: string;
  points: number;
  pointsVisible: boolean;
  confettiVisible: boolean;
};

export type ActiveCategory = {
  id: number;
  name: string;
};

export type AcknowUser = Pick<
  User,
  | 'id'
  | 'deleted'
  | 'profilePicture'
  | 'fullName'
  | 'lastName'
  | 'firstName'
  | 'employeeInternalId'
>;

export type Acknowledgement = {
  id: number;
  body: string;
  acknowledger: AcknowUser;
  acknowledged: AcknowUser;
  acknowledgeds: AcknowUser[] | null;
  updatedAt: string;
  createdAt: string;
  category: Category;
  commentCount: number;
  attachments: Attachment[];
  reactions: Reaction[];
  lastComments: Comment[];
  points: number;
};

export type CreateAcknowledgementParams = {
  body: string;
  acknowledgedId?: number;
  acknowledgedIds?: number[];
  acknowledgementCategoryId: number;
  attachments: Attachment[];
};

type KudosRankingDateFilters = {
  startDate: Date | null;
  endDate: Date | null;
};

export type KudosRankingFiltersState = KudosRankingDateFilters & {
  categoryIds: number[] | null;
  segmentationItemIds: number[] | null;
};

export type KudosRankingFilterValues = KudosRankingDateFilters & {
  categories: Record<string, boolean>;
  segmentationItemIds: Record<string, boolean>;
};

export type FormatedRankingFilters = {
  segmentationItemIds?: string;
  categoryIds?: string;
  startDate?: string;
  endDate?: string;
};

// Socket
export type AcknowledgementReactionSocket = {
  emoji: string;
  unified: string;
  userId: number;
  acknowledgmentId: number;
};

export type AcknowledgementCommentReactionSocket = {
  emoji: string;
  unified: string;
  userId: number;
  parentId: number;
  commentId: number;
  postId: number;
};

export type AcknowledgementCommentCreatedSocket = Comment & {
  acknowledgmentId: number;
};

export type AcknowledgementCommentUpdatedSocket = Comment & {
  acknowledgmentId: number;
};

export type AcknowledgementCommentDeletedSocket = {
  acknowledgmentId: number;
  commentId: number;
  parentId: number;
};

export type AcknowledgementRankingParams = PaginationParams & {
  startDate?: string;
  endDate?: string;
  categoryIds?: string;
  segmentationItemIds?: string;
};

export type RankingUser = {
  userId: number;
  userProfilePicture: string;
  userFirstName: string;
  userLastName: string;
  points: number;
};

export type AvailablePoints = {
  availablePoints: number;
};
