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 f9a446c..f552562 100644 --- a/src/app/admin-component/add-restau/add-restau.component.html +++ b/src/app/admin-component/add-restau/add-restau.component.html @@ -9,15 +9,28 @@ 'is-invalid': signupForm.controls['nomFc'].touched && !signupForm.controls['nomFc'].valid}"> + + + +
; public expanded = false; - constructor( private router: Router, private apiBackService : ApiBackService) { + constructor(private router: Router, private apiBackService: ApiBackService) { this.signupForm = new FormGroup({}); - this.listCategories = []; + this.listCategories$ = this.getCategories(); } ngOnInit(): void { - - this.getCategories(); - this.signupForm = new FormGroup({ - nomFc : new FormControl('', [Validators.required]), - prixFc : new FormControl(''), - longitudeFc : new FormControl('', [Validators.required,]), // chercher une meilleure regex - latitudeFc : new FormControl('', [Validators.required]), - adresseFc : new FormControl('', [Validators.required]), - telephoneFc : new FormControl(''), - websiteFc : new FormControl('',[Validators.pattern("/^(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}/")]), - surPlaceFc : new FormControl(''), - aEmporterFc : new FormControl(''), - accesPMRFc : new FormControl(''), - // typerestausFc : new FormControl('') + nomFc: new FormControl('', [Validators.required]), + prixFc: new FormControl(''), + longitudeFc: new FormControl('', [Validators.required,]), // chercher une meilleure regex + latitudeFc: new FormControl('', [Validators.required]), + adresseFc: new FormControl('', [Validators.required]), + telephoneFc: new FormControl(''), + websiteFc: new FormControl('', [Validators.pattern("/^(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}/")]), + surPlaceFc: new FormControl(''), + aEmporterFc: new FormControl(''), + accesPMRFc: new FormControl(''), + typerestausFc: new FormArray([]) }) } - public getCategories() : void{ - this.apiBackService.getCategories().subscribe((listCategories: any[]) => { - // console.log(listCategories); - - this.listCategories = listCategories; - - }); + public getCategories(): Observable { + return this.apiBackService.getCategories(); } @@ -66,37 +58,63 @@ export class AddRestauComponent implements OnInit { const surPlaceFc = this.signupForm.value['surPlaceFc']; const aEmporterFc = this.signupForm.value['aEmporterFc']; const accesPMRFc = this.signupForm.value['accesPMRFc']; - // const typerestausFc = this.signupForm.value['typerestausFc']; + const typerestausFc = this.signupForm.value['typerestausFc']; + + console.log(typerestausFc); + const restaurant: Restaurant = { latitude: latitudeFc, longitude: longitudeFc, - nom : nomFc, + nom: nomFc, prix: prixFc, - adresse : adresseFc, - telephone : telephoneFc, - website : websiteFc, - surPlace : surPlaceFc, - aEmporter : aEmporterFc, - accesPMR : accesPMRFc, - // typerestaus : typerestausFc + adresse: adresseFc, + telephone: telephoneFc, + website: websiteFc, + surPlace: surPlaceFc, + aEmporter: aEmporterFc, + accesPMR: accesPMRFc, + typerestaus: typerestausFc } - if( restaurant.latitude !== '' && - restaurant.longitude !== '' && - restaurant.nom !== '' && - restaurant.adresse !== '' ) { - this.apiBackService.addRestaurant(restaurant).subscribe( - resp=> - + if (restaurant.latitude !== '' && + restaurant.longitude !== '' && + restaurant.nom !== '' && + restaurant.adresse !== '') { + this.apiBackService.addRestaurant(restaurant).subscribe( + resp => this.router.navigate(['restaurants']) - ); - }else{ - + ); + } else { + this.errorMessage = "Renseigner les champs obligatoires **"; } - + } + onCheckChange(event : any) { + const formArray: FormArray = this.signupForm.get('typerestausFc') as FormArray; + console.log(FormArray); + + if (event.target.checked) { + + formArray.push(new FormControl({id : event.target.value})); + + }else { + let i: number = 0; + + formArray.controls.forEach((ctrl) => { + + if (ctrl.value['id'] == event.target.value) { + formArray.removeAt(i); + return; + } + + i++; + }); + } + } + + } 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 3a81ced..4a65ea7 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,6 +6,7 @@ {{restau.nom}}
+
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 ea7d325..38af860 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 @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Restaurant } from 'src/app/pages/models/restaurant'; import { ApiBackService } from 'src/app/services/api-back.service'; @@ -10,14 +10,13 @@ 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 = []; } - ngOnInit(): void { - - } + ngOnInit(): void {} saveRestauList(event : any){ @@ -28,11 +27,12 @@ export class UpdateDelRestauComponent implements OnInit { deleteRestau(idRestau : number | undefined){ this.apiBackService.deleteRestau(idRestau).subscribe( resp =>{ - - this.restauList = this.restauList.filter(restaus => restaus.id != idRestau) - }); } + modifRestau(idRestau : number | undefined){ + this.idRestauAModif.emit(idRestau); + } + } \ No newline at end of file diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 644c2ab..a01b041 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -7,16 +7,20 @@ import { RestoPageComponent } from './pages/resto-page/resto-page.component'; import { PageNotFoundComponent } from './pages/page-not-found/page-not-found.component'; import { FiltersPageComponent } from './pages/filters-page/filters-page.component'; import { SigninComponent } from './pages/signin/signin.component'; +import { SignupComponent } from './pages/signup/signup.component'; import { AdminPageComponent } from './pages/admin-page/admin-page.component'; import { AuthGuard } from './services/auth.guard'; +import { PageAccountComponent } from './pages/page-account/page-account.component'; const routes: Routes = [ - { path: '', redirectTo: 'signin', pathMatch: 'full' }, + { path: '', redirectTo: 'home', pathMatch: 'full' }, {path: 'signin', component: SigninComponent}, + {path: 'signup', component: SignupComponent}, { path: 'home', component: HomePageComponent }, { path: 'categories', component: ListCategoriesComponent }, { path: 'favoris', component: FavorisUserComponent }, { path: 'filtres', component: FiltersPageComponent }, + { path: 'profil', component: PageAccountComponent }, { path: 'Deconnexion', redirectTo: 'home'}, {path: 'restaurants', canActivate: [AuthGuard], component: RestoPageComponent}, {path: 'page-not-found',component: PageNotFoundComponent}, diff --git a/src/app/app.component.html b/src/app/app.component.html index 19dd0a6..0aa81f4 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -3,4 +3,4 @@ - + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index be5ed0d..18917ec 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,6 +1,7 @@ import { Component } from '@angular/core'; import { NavigationEnd, Router } from '@angular/router'; import { ApiBackService } from './services/api-back.service'; +import { AuthGuard } from './services/auth.guard'; @Component({ selector: 'app-root', @@ -11,7 +12,7 @@ export class AppComponent { title = 'simpleat'; dontShow: boolean = false; - constructor(public router:Router, private apiBackService : ApiBackService){ + constructor(public router:Router, private apiBackService : ApiBackService, private authgard : AuthGuard){ this.router.events.subscribe(e=>{ //console.log(e); if(e instanceof NavigationEnd){ @@ -26,6 +27,7 @@ export class AppComponent { } - ngOnInit(): void { } + ngOnInit(): void {} + } + -} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 6d701ea..de864a8 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -24,6 +24,8 @@ import { UpdateDelRestauComponent } from './admin-component/update-del-restau/up import { HeaderLogoComponent } from './header/components/header-logo/header-logo.component'; import { AuthInterceptor } from './services/auth.interceptor'; import { FavorisUserComponent } from './pages/favoris-user/favoris-user.component'; +import { SignupComponent } from './pages/signup/signup.component'; +import { PageAccountComponent } from './pages/page-account/page-account.component'; @NgModule({ declarations: [ @@ -46,7 +48,9 @@ import { FavorisUserComponent } from './pages/favoris-user/favoris-user.componen AddRestauComponent, UpdateDelRestauComponent, HeaderLogoComponent, - FavorisUserComponent + FavorisUserComponent, + SignupComponent, + PageAccountComponent ], imports: [ BrowserModule, diff --git a/src/app/header/components/nav-bar/nav-bar.component.html b/src/app/header/components/nav-bar/nav-bar.component.html index fc3055f..6a99db4 100644 --- a/src/app/header/components/nav-bar/nav-bar.component.html +++ b/src/app/header/components/nav-bar/nav-bar.component.html @@ -10,12 +10,13 @@