import { ITransactionManager } from "@/core/common/infrastructure/database";
import { Collection, Result } from "@repo/rdx-utils";
import { User } from "../../domain";
import { IUserService } from "../../domain/services";

export class ListUsersUseCase {
  constructor(
    private readonly userService: IUserService,
    private readonly transactionManager: ITransactionManager
  ) {}

  public execute(): Promise<Result<Collection<User>, Error>> {
    return this.transactionManager.complete((transaction) => {
      return this.userService.findUsers(transaction);
    });
  }
}
