import { Profile } from '@app/domain/profiles/profile.model';
import { mockProfiles } from '@app/testing/profile.mock';
import { ProfileRepository } from '@app/domain/profiles/profile.repository';
import { Observable, of } from 'rxjs';

export class FakeProfileRepository implements ProfileRepository {
  list(): Observable<Profile[]> {
    return of(mockProfiles);
  }

  getByUserId(userId: string): Observable<Profile> {
    const profile = mockProfiles.find((p) => p.utilisateur === userId) ?? ({} as Profile);
    return of(profile);
  }

  create(profile: Profile): Observable<Profile> {
    return of(profile);
  }

  update(id: string, data: Partial<Profile>): Observable<Profile> {
    const existing = mockProfiles.find((p) => p.id === id) ?? mockProfiles[0];
    return of({ ...existing, ...data });
  }
}
