diff --git a/src/app/admin-component/add-restau/add-restau.component.html b/src/app/admin-component/add-restau/add-restau.component.html index f552562..701b664 100644 --- a/src/app/admin-component/add-restau/add-restau.component.html +++ b/src/app/admin-component/add-restau/add-restau.component.html @@ -78,17 +78,17 @@

Sur Place :

-
+ [value]="false" formControlName="surPlaceFc">
-
@@ -98,17 +98,17 @@

A Emporter :

+ [value]="true" formControlName="aEmporterFc">
+ [value]="false" formControlName="aEmporterFc">
+ [value]="null" formControlName="aEmporterFc">
@@ -116,17 +116,17 @@

Accès PMR :

-
+ [value]="false" formControlName="accesPMRFc">
-
diff --git a/src/app/admin-component/add-restau/add-restau.component.ts b/src/app/admin-component/add-restau/add-restau.component.ts index 586719a..a28523e 100644 --- a/src/app/admin-component/add-restau/add-restau.component.ts +++ b/src/app/admin-component/add-restau/add-restau.component.ts @@ -1,8 +1,8 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; import { FormArray, FormControl, FormGroup, Validators } from '@angular/forms'; import { Router } from '@angular/router'; -import { Observable } from 'rxjs'; +import { Observable, Subscription } from 'rxjs'; import { Restaurant } from 'src/app/pages/models/restaurant'; import { ApiBackService } from 'src/app/services/api-back.service'; @@ -18,6 +18,7 @@ export class AddRestauComponent implements OnInit { public errorMessage?: string; public listCategories$: Observable; public expanded = false; + public idRestau : Subscription | undefined; constructor(private router: Router, private apiBackService: ApiBackService) { this.signupForm = new FormGroup({}); @@ -38,6 +39,36 @@ export class AddRestauComponent implements OnInit { accesPMRFc: new FormControl(''), typerestausFc: new FormArray([]) }) + + this.idRestau = this.apiBackService.restauAModif.subscribe(restau => { + + + // const formArray: FormArray = this.signupForm.get('typerestausFc') as FormArray; + // if(restau.typerestaus != undefined){ + // for (let index = 0; index < restau.typerestaus.length; index++) { + // //listCategories.filter(categorie => categorie.id == restau.typerestaus[index]['id']) + // this.signupForm.patchValue({typerestausFc : {restau.typerestaus[index]['id'] : true}}); + // formArray.push(new FormControl(restau.typerestaus[index]['id'] : true)); + + // } + // } + // console.log(formArray); + + this.signupForm = new FormGroup({ + nomFc: new FormControl(restau.nom, [Validators.required]), + prixFc: new FormControl(restau.prix), + longitudeFc: new FormControl(restau.longitude, [Validators.required,]), // chercher une meilleure regex + latitudeFc: new FormControl(restau.latitude, [Validators.required]), + adresseFc: new FormControl(restau.adresse, [Validators.required]), + telephoneFc: new FormControl(restau.telephone), + websiteFc: new FormControl(restau.website, [Validators.pattern("/^(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}/")]), + surPlaceFc: new FormControl(restau.surPlace), + aEmporterFc: new FormControl(restau.aEmporter), + accesPMRFc: new FormControl(restau.accesPMR), + typerestausFc: new FormArray([]) + }) + } + ) } public getCategories(): Observable { @@ -117,5 +148,12 @@ export class AddRestauComponent implements OnInit { } + ngOnDestroy() { + if (this.idRestau) { + this.idRestau.unsubscribe(); + this.idRestau = undefined; + } + } + } diff --git a/src/app/admin-component/update-del-restau/update-del-restau.component.html b/src/app/admin-component/update-del-restau/update-del-restau.component.html index d18c0d9..8b5e5a5 100644 --- a/src/app/admin-component/update-del-restau/update-del-restau.component.html +++ b/src/app/admin-component/update-del-restau/update-del-restau.component.html @@ -6,10 +6,8 @@ {{restau.nom}}
+
-
- -
\ No newline at end of file diff --git a/src/app/admin-component/update-del-restau/update-del-restau.component.ts b/src/app/admin-component/update-del-restau/update-del-restau.component.ts index eb41ba8..721618f 100644 --- a/src/app/admin-component/update-del-restau/update-del-restau.component.ts +++ b/src/app/admin-component/update-del-restau/update-del-restau.component.ts @@ -10,7 +10,6 @@ import { ApiBackService } from 'src/app/services/api-back.service'; export class UpdateDelRestauComponent implements OnInit { restauList : Restaurant[]; - @Output() idRestauAModif = new EventEmitter(); constructor(private apiBackService : ApiBackService) { this.restauList = []; @@ -36,8 +35,8 @@ export class UpdateDelRestauComponent implements OnInit { }); } - modifRestau(idRestau : number | undefined){ - this.idRestauAModif.emit(idRestau); + modifRestau(restau : Restaurant){ + this.apiBackService.idRestauAModifier(restau); } } \ No newline at end of file diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 644c2ab..fe37095 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -18,7 +18,7 @@ const routes: Routes = [ { path: 'favoris', component: FavorisUserComponent }, { path: 'filtres', component: FiltersPageComponent }, { path: 'Deconnexion', redirectTo: 'home'}, - {path: 'restaurants', canActivate: [AuthGuard], component: RestoPageComponent}, + {path: 'restaurants', canActivate: [AuthGuard], /*data : {ROLE : "ROLE_ADMIN"},*/ component: RestoPageComponent}, {path: 'page-not-found',component: PageNotFoundComponent}, {path: 'admin', component: AdminPageComponent}, {path: '**', redirectTo: 'page-not-found' } diff --git a/src/app/header/components/nav-bar/nav-bar.component.ts b/src/app/header/components/nav-bar/nav-bar.component.ts index fc81ce2..a3b0d3d 100644 --- a/src/app/header/components/nav-bar/nav-bar.component.ts +++ b/src/app/header/components/nav-bar/nav-bar.component.ts @@ -17,7 +17,7 @@ export class NavBarComponent implements OnInit { } onCloseSession() : void { -this.tokenService.destroyToken(); +this.tokenService.destroyToken(this.tokenKey); this.route.navigate(['signin']); } diff --git a/src/app/pages/admin-page/admin-page.component.html b/src/app/pages/admin-page/admin-page.component.html index fd8ef34..757318b 100644 --- a/src/app/pages/admin-page/admin-page.component.html +++ b/src/app/pages/admin-page/admin-page.component.html @@ -1,6 +1,6 @@
- +