Skip to content
Snippets Groups Projects
Commit 16e621cd authored by Jérémie BRISON's avatar Jérémie BRISON Committed by Hugo SUBTIL
Browse files

feat(admin) : add service + model

parent ebc9c3ae
No related branches found
No related tags found
3 merge requests!68Recette,!67Dev,!51Feat/admin panel attachment
<div fxLayout="row" fxLayoutAlign="center center"><p>validation-attachment works!</p></div>
<div fxLayout="row" fxLayoutAlign="center center">
<table>
<thead>
<th>Utilisateur</th>
<th>Structure</th>
<th>Options</th>
</thead>
<tbody>
<tr *ngFor="let demand of demandsAttachment">
<td>{{ demand.user.email }}</td>
<td>{{ demande.structure.structureName }}</td>
<td>
<button (click)="acceptDemand(demand)">Valider</button><button (click)="refuseDemand(demand)">Refuser</button>
</td>
</tr>
<tr *ngIf="!demandsAttachment.length">
<td colspan="3">Aucune demande en attente</td>
</tr>
</tbody>
</table>
</div>
import { Component, OnInit } from '@angular/core';
import { userInfo } from 'os';
import { Structure } from '../../../models/structure.model';
import { User } from '../../../models/user.model';
import { demandAttachment } from '../../models/demandAttachment.model';
import { AdminService } from '../../services/admin.service';
@Component({
selector: 'app-admin-validation-attachment',
......@@ -6,7 +11,30 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./validation-attachment.component.scss'],
})
export class ValidationAttachmentComponent implements OnInit {
constructor() {}
demandsAttachment: demandAttachment[];
constructor(private adminService: AdminService) {}
ngOnInit(): void {}
ngOnInit(): void {
this.demandsAttachment = this.adminService.getPendingAttachmentsStructure();
}
public acceptDemand(demand: demandAttachment): void {
console.log('accept');
this.removeDemand(demand);
this.adminService.acceptAttachmentStructure(demand.user.email, demand.structure.id);
}
public refuseDemand(demand: demandAttachment): void {
console.log('refuse');
this.adminService.refuseAttachmentStructure(demand.user.email, demand.structure.id);
this.removeDemand(demand);
}
private removeDemand(demand: demandAttachment): void {
const index = this.demandsAttachment.findIndex((d: demandAttachment) => d === demand);
if (index > -1) {
this.demandsAttachment.splice(index, 1);
}
}
}
import { Structure } from '../../models/structure.model';
import { User } from '../../models/user.model';
export class demandAttachment {
user: User;
structure: Structure;
}
import { TestBed } from '@angular/core/testing';
import { AdminService } from './admin.service';
describe('AdminService', () => {
let service: AdminService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(AdminService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
import { demandAttachment } from '../models/demandAttachment.model';
@Injectable({
providedIn: 'root',
})
export class AdminService {
constructor() {}
// Return pendingAttachments of all profiles.
public getPendingAttachmentsStructure(): demandAttachment[] {
return [new demandAttachment()];
}
public acceptAttachmentStructure(mailUser, idStructure): void {}
public refuseAttachmentStructure(mailUser, idStructure): void {}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment