diff --git a/src/app/admin/components/validation-attachment/validation-attachment.component.html b/src/app/admin/components/validation-attachment/validation-attachment.component.html index 03e52cde1c53241a2185494cff013c5bdee0bbee..f32fd6e7bd10b35d9d2ed5c15a3154da08e4c859 100644 --- a/src/app/admin/components/validation-attachment/validation-attachment.component.html +++ b/src/app/admin/components/validation-attachment/validation-attachment.component.html @@ -1,5 +1,5 @@ <div fxLayout="row" fxLayoutAlign="center center"> - <table> + <table *ngIf="demandsAttachment"> <thead> <th>Utilisateur</th> <th>Structure</th> diff --git a/src/app/admin/components/validation-attachment/validation-attachment.component.ts b/src/app/admin/components/validation-attachment/validation-attachment.component.ts index 78fe3329bdddfb6c3b6c3435334b334d45b070ca..e7d1ff21fd880689330316159e5e377d2c98cb23 100644 --- a/src/app/admin/components/validation-attachment/validation-attachment.component.ts +++ b/src/app/admin/components/validation-attachment/validation-attachment.component.ts @@ -15,21 +15,26 @@ export class ValidationAttachmentComponent implements OnInit { constructor(private adminService: AdminService) {} ngOnInit(): void { - this.demandsAttachment = this.adminService.getPendingAttachmentsStructure(); + this.adminService.getPendingAttachmentsStructure().subscribe((demands) => { + this.demandsAttachment = demands; + }); } + // Todo : Appeler removeDemand(demand) dans le subscribe de acceptAttachmentStructure() quand l'api sera faite. public acceptDemand(demand: demandAttachment): void { console.log('accept'); - this.removeDemand(demand); this.adminService.acceptAttachmentStructure(demand.userEmail, demand.structureId); + this.removeDemand(demand); } + // Todo : Appeler removeDemand(demand) dans le subscribe de acceptAttachmentStructure() quand l'api sera faite. public refuseDemand(demand: demandAttachment): void { console.log('refuse'); this.adminService.refuseAttachmentStructure(demand.userEmail, demand.structureId); this.removeDemand(demand); } + // Remove the request that was accepted or refused private removeDemand(demand: demandAttachment): void { const index = this.demandsAttachment.findIndex((d: demandAttachment) => d === demand); if (index > -1) { diff --git a/src/app/admin/models/demandAttachment.model.ts b/src/app/admin/models/demandAttachment.model.ts index 497b93b816cba202eb28cb0ca5c7e1dc89eef27c..a7fb8378f9de127b85e2522edfdd34b12a610fe4 100644 --- a/src/app/admin/models/demandAttachment.model.ts +++ b/src/app/admin/models/demandAttachment.model.ts @@ -1,6 +1,3 @@ -import { Structure } from '../../models/structure.model'; -import { User } from '../../models/user.model'; - export class demandAttachment { userEmail: string; structureId: number; diff --git a/src/app/admin/services/admin.service.ts b/src/app/admin/services/admin.service.ts index f5f928647e2b59250b2655f3ec34e85930cdcd43..4b50fd04a04b17719add420f471590df6e71196a 100644 --- a/src/app/admin/services/admin.service.ts +++ b/src/app/admin/services/admin.service.ts @@ -1,20 +1,22 @@ +import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; import { demandAttachment } from '../models/demandAttachment.model'; @Injectable({ providedIn: 'root', }) export class AdminService { - constructor() {} + constructor(private http: HttpClient) {} // Return pendingAttachments of all profiles. - public getPendingAttachmentsStructure(): demandAttachment[] { - return [{ userEmail: 'jb@test.fr', structureId: 53 }]; + public getPendingAttachmentsStructure(): Observable<demandAttachment[]> { + return this.http.get<any>('api/users/pendingAttachments'); } - // Post - public acceptAttachmentStructure(mailUser, idStructure): void {} + // Todo : Api post qui retourne vrai si aucune erreur sinon httpException + public acceptAttachmentStructure(mailUser, idStructure) {} - // Post - public refuseAttachmentStructure(mailUser, idStructure): void {} + // Todo : Api post qui retourne vrai si aucune erreur sinon httpException + public refuseAttachmentStructure(mailUser, idStructure) {} }