profiles => format clean archi

This commit is contained in:
styve Lioumba
2025-10-20 20:34:45 +02:00
parent 4191ac1ed0
commit ef02c6a537
171 changed files with 25748 additions and 23863 deletions

View File

@@ -0,0 +1,35 @@
import { ProfileRepository } from '@app/domain/profiles/profile.repository';
import { from, Observable } from 'rxjs';
import { Profile } from '@app/domain/profiles/profile.model';
import { Injectable } from '@angular/core';
import PocketBase from 'pocketbase';
import { environment } from '@env/environment';
interface ProfileDTO {
profession: string;
utilisateur: string;
reseaux: any;
}
@Injectable({ providedIn: 'root' })
export class PbProfileRepository implements ProfileRepository {
private pb = new PocketBase(environment.baseUrl);
list(): Observable<Profile[]> {
return from(this.pb.collection('profiles').getFullList<Profile>({ sort: 'profession' }));
}
getByUserId(userId: string): Observable<Profile | null> {
return from(
this.pb.collection('profiles').getFirstListItem<Profile>(`utilisateur="${userId}"`)
);
}
create(profile: ProfileDTO): Observable<Profile> {
return from(this.pb.collection('profiles').create<Profile>(profile));
}
update(id: string, data: Partial<Profile>): Observable<Profile> {
return from(this.pb.collection('profiles').update<Profile>(id, data));
}
}