import { Collection, ensureString } from "@repo/rdx-utils";
import { User } from "../../domain";
import { IListUsersResponseDTO } from "../../dto";

export interface IListUsersPresenter {
  toDTO: (users: Collection<User>) => IListUsersResponseDTO[];
}

export const listUsersPresenter: IListUsersPresenter = {
  toDTO: (users: Collection<User>): IListUsersResponseDTO[] =>
    users.map((user) => ({
      id: ensureString(user.id.toString()),
      email: ensureString(user.email.toString()),
      username: ensureString(user.username.toString()),
    })),
};
