export type User = {
  id: string;
  username: string;
  email: string;
  avatar?: string;
  isOnline: boolean;
  lastSeen: string;
};

export type ChatRoom = {
  id: string;
  name: string;
  description?: string;
  isPrivate: boolean;
  createdAt: string;
  members: ChatRoomMember[];
  _count: {
    messages: number;
  };
};

export type ChatRoomMember = {
  id: string;
  userId: string;
  roomId: string;
  joinedAt: string;
  role: string;
  user: User;
};

export type Message = {
  id: string;
  content: string;
  image?: string;
  createdAt: string;
  userId: string;
  roomId: string;
  user: User;
  reactions: MessageReaction[];
  seenBy?: string[];
};

export type MessageReaction = {
  id: string;
  type: string;
  createdAt: string;
  userId: string;
  messageId: string;
  user: User;
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type ApiResponse<T = any> = {
  success: boolean;
  data?: T;
  error?: string;
  message?: string;
};

export type LoginRequest = {
  email: string;
  password: string;
};

export type RegisterRequest = {
  username: string;
  email: string;
  password: string;
};

export type UpdateUserRequest = {
  username?: string;
  email?: string;
  password?: string;
  avatar?: string | null;
};

export type CreateChatRoomRequest = {
  name: string;
  description?: string;
  memberUsernames: string[];
};

export type UpdateChatRoomRequest = {
  name: string;
  description?: string;
};

export type AddChatRoomMemberRequest = {
  username: string;
};

export type RemoveChatRoomMemberRequest = {
  userId: string;
};
