import { UserRepository } from '@app/domain/users/user.repository';
import { Observable, of } from 'rxjs';
import { User } from '@app/domain/users/user.model';
import { fakeUsers } from '@app/testing/user.mock';

export class FakeUserRepository implements UserRepository {
  getUserById(userId: string): Observable<User> {
    const user = fakeUsers.find((u) => u.id === userId) ?? ({} as User);
    return of(user);
  }

  update(userId: string, user: Partial<User> | User): Observable<User> {
    const existingUser = fakeUsers.find((u) => u.id === userId) ?? fakeUsers[0];
    return of({ ...existingUser, ...user });
  }
}
