import { Attachment } from 'src/types/attachments';
import { Comment } from 'src/types/comments';
import { Reaction } from 'src/types/reaction';
import { User, TaggedUser } from 'src/types/user';

import { ApprovalStatus } from './groups';
import { PostType } from './posts';

export type MarketplacePost = {
  id: number;
  body: string;
  bodyAttributes?: TaggedUser[];
  user: User;
  updatedAt: Date;
  createdAt: Date;
  commentCount: number;
  attachments: Attachment[];
  reactions: Reaction[];
  state: string;
  price: number;
  currencyCode: string | null;
  currencySymbol: string | null;
  lastComments: Comment[];

  type: PostType.MarketplaceType;
  approvalStatus: ApprovalStatus.APPROVED;
  bodyHtml: string;
  commentsEnabled: true;
  externalId: null;
  isExternal: false;
  group: null;
  hasBeenSegmented: false;
  isKeyUpdate: false;
  languageCode: null;
  linkPreviews: null;
  poll: null;
  public: true;
  publicationDatetime: Date;
  sendNotification: false;
  stream: null;
  taggedUserIds: number[];
  viewed: null;
};

// Data
export type MarketplacePostData = {
  price: number;
  currencyCode: string | null;
  body: string;
  bodyAttributes?: TaggedUser[];
  attachments: Attachment[];
  taggedUserIds: number[];
};

// Response
export type MarketplaceNotificationsResponse = {
  marketplaceNotifications: number;
};

export type MyListTotalCountResponse = {
  totalCount: number;
};

// Sockets
export type MarketplacePostReactionSocket = {
  emoji: string;
  unified: string;
  userId: number;
  marketplacePostId: number;
  postId: number;
};

export type MarketplacePostCommentReactionSocket = {
  emoji: string;
  userId: number;
  commentId: number;
  postId: number;
};

export type MarketplacePostCommentCreatedSocket = Comment & {
  postId: number;
};

export type MarketplacePostCommentDeletedSocket = {
  commentId: number;
  postId: number;
};
