import { User } from "@prisma/client";
import { Request } from "express";
import { Socket } from "socket.io";

export type AuthenticatedRequest = Request & {
  user?: {
    userId: string;
    email: string;
    username: string;
  };
};

export type JWTPayload = {
  userId: string;
  email: string;
  username: string;
};

export type AuthenticatedSocket = Socket & {
  userId: string;
  user: User;
};

export type SendMessageRequest = {
  roomId: string;
  content: string;
  image?: string;
};

export type ReactToMessageRequest = {
  messageId: string;
  type: string;
};

export type MessageWithSeenBy = {
  messageId: string;
  seenBy: string[];
};

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

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

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

export type PaginationQuery = {
  page?: string;
  limit?: string;
};

export type GetMessagesQuery = PaginationQuery & {
  roomId: string;
};

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

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

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

export type AddChatRoomMemberRequest = {
  username: string;
};

export type RemoveChatRoomMemberRequest = {
  userId: string;
};
