import { SearchRequest } from ".";

export type UserDTO = {
  id: string;
  lastname: string;
  firstname: string;
  fullname: string;
  email: string;
  role: UserRole;
};

export const roles = {
  ADMIN: "ADMIN",
  USER: "USER",
  SUPER_ADMIN: "SUPER_ADMIN",
};

export type UserRole = keyof typeof roles;

export type CreateUserDTO = {
  lastname: string;
  firstname: string;
  email: string;
  role: UserRole;
  password: string;
};

export type UpdateUserDTO = {
  lastname?: string;
  firstname?: string;
  role?: UserRole;
};

export type ChangePasswordDTO = {
  password: string;
  oldPassword: string;
};

export type CurrentUser<T> = T & {
  currentUser: UserDTO;
};

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

export type TokenDTO = {
  access_token: string;
  user: UserDTO;
};

export type SearchUserDTO = SearchRequest<{}>;

export type UserActivityDTO = {
  id: string;
  userId?: string;
  action?: string;
  endpoint?: string;
  method?: string;
  ipAddress?: string;
  status?: number;
  entityId?: string;
  metadata?: Record<string, any>;
  htmlContent?: string | null;
  createdAt: string;
};

export type CreateUserActivityDTO = {
  userId?: string;
  action?: string;
  endpoint?: string;
  method?: string;
  entityId?: string;
  metadata?: Record<string, any>;
};

export type SearchUserActivityDTO = {
  userId?: string;
  action?: string[];
  method?: string;
  entityId?: string;
  startDate?: string;
  endDate?: string;
  status?: number;
};

export type TrackActivityDTO = {
  action: string;
  entityId?: string;
};

export type UpdateUserPasswordDTO = {
  password: string;
};
