admin:crea suppr restau, search bar

This commit is contained in:
Thomas Cardon 2022-03-02 12:43:16 +01:00
parent 4d92ddb960
commit e72283e305
19 changed files with 276 additions and 173 deletions

View file

@ -0,0 +1,12 @@
<h2>Modifier/Supprimer un restaurant</h2>
<app-search-bar (resultSearch)="saveRestauList($event)"></app-search-bar>
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between" *ngFor="let restau of restauList" >
<div>
{{restau.nom}}
</div>
<div>
<button class="btn btn-danger" type="button" (click)="deleteRestau(restau.id)"><i class="bi bi-trash"></i></button>
</div>
</li>
</ul>

View file

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { UpdateDelRestauComponent } from './update-del-restau.component';
describe('UpdateDelRestauComponent', () => {
let component: UpdateDelRestauComponent;
let fixture: ComponentFixture<UpdateDelRestauComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ UpdateDelRestauComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(UpdateDelRestauComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,38 @@
import { Component, Input, OnInit } from '@angular/core';
import { Restaurant } from 'src/app/pages/models/restaurant';
import { ApiBackService } from 'src/app/services/api-back.service';
@Component({
selector: 'app-update-del-restau',
templateUrl: './update-del-restau.component.html',
styleUrls: ['./update-del-restau.component.scss']
})
export class UpdateDelRestauComponent implements OnInit {
restauList : Restaurant[];
constructor(private apiBackService : ApiBackService) {
this.restauList = [];
}
ngOnInit(): void {
}
saveRestauList(event : any){
console.log(event);
this.restauList = event;
}
deleteRestau(idRestau : number | undefined){
this.apiBackService.deleteRestau(idRestau).subscribe(
resp =>{
this.restauList = this.restauList.filter(restaus => restaus.id != idRestau)
});
}
}