import { ChatWatchType, MessageActionStatus, MessageType } from '@/constants/message';
import { JobDetails } from '@/types/job';
import { AnchorInfo } from '@/types/material';
import { UserInfo } from '@/types/user';

export interface UserMessage {
  count: number;
}

export interface MainMessage {
  chatId: string;
  toUserId: string;
  toUserName: string;
  toUserAvatarUrl: string;
  lastContactMsgContent: string;
  unReadMsgCount: number;
  lastContactTime: number;
}

export interface IJobMessage
  extends Pick<
    JobDetails,
    | 'id'
    | 'title'
    | 'employType'
    | 'salary'
    | 'lowPriceForFullTime'
    | 'highPriceForFullTime'
    | 'lowPriceForPartyTime'
    | 'highPriceForPartyTime'
  > {}

export interface IMaterialMessage
  extends Pick<
    AnchorInfo,
    'id' | 'name' | 'age' | 'height' | 'weight' | 'gender' | 'shoeSize' | 'workedSecCategoryStr'
  > {}

export interface ILocationMessage {
  name: string;
  address: string;
  latitude: number;
  longitude: number;
}

export interface IChatUser extends Pick<UserInfo, 'userId' | 'nickName'> {}

export interface IChatMessage {
  msgId: string;
  type: MessageType;
  content: string;
  actionId: string;
  actionObject: string;
  senderUserId: string;
  senderName: string;
  senderAvatarUrl: string;
  receiverUserId: string;
  receiverName: string;
  receiverAvatarUrl: string;
  timestamp: number;
  jobId: string;
  isRead: boolean;
}

export interface IChatInfo {
  chatId: string;
  participants: IChatUser[];
  lastContactTime: number;
  lastContactContent: string;
  unReadCount: number;
  messages: IChatMessage[];
  lastJobId: string;
}

export interface IMessageStatus {
  msgId: string;
  isRead: boolean;
}

export interface IChatActionDetail {
  id: string;
  chatId: string;
  status: MessageActionStatus;
  type: MessageType;
  bizId: string;
  created: string;
}

export interface PostMessageRequest {
  chatId: string;
  type: MessageType;
  bizId: string;
  content?: string;
  actionObject?: string;
}

export interface PostConfirmActionRequest {
  actionId: string;
  status: boolean;
}

export interface PostActionDetailRequest {
  type: MessageType;
  bizId: string;
  toUserId: string;
}

export interface GetNewChatMessagesRequest {
  chatId: string;
  // 上次接口调用返回的最新的msgId Message.msgId字段
  lastMsgId?: string;
}

export interface ChatWatchRequest {
  type: ChatWatchType;
  status: boolean;
  jobId: string;
  toUserId: string;
}
