diff --git a/src/app/admin-component/add-restau/add-restau.component.html b/src/app/admin-component/add-restau/add-restau.component.html
new file mode 100644
index 0000000..1c4213c
--- /dev/null
+++ b/src/app/admin-component/add-restau/add-restau.component.html
@@ -0,0 +1,195 @@
+
\ No newline at end of file
diff --git a/src/app/admin-component/add-restau/add-restau.component.scss b/src/app/admin-component/add-restau/add-restau.component.scss
new file mode 100644
index 0000000..8778894
--- /dev/null
+++ b/src/app/admin-component/add-restau/add-restau.component.scss
@@ -0,0 +1,36 @@
+.login-form {
+ height: 100vh;
+ padding-top: 40px;
+ background-color: #f5f5f5;
+}
+
+.form-signup {
+ width: 100%;
+ max-width: 350px;
+ padding: 15px;
+ margin: auto;
+}
+
+.form-signup .checkbox {
+ font-weight: 400;
+}
+
+.form-signup .form-floating:focus-within {
+ z-index: 2;
+}
+
+.form-signup input[type="email"] {
+ margin-bottom: -1px;
+ border-bottom-right-radius: 0;
+ border-bottom-left-radius: 0;
+}
+
+.form-signup input[type="password"] {
+ margin-bottom: 10px;
+ border-top-left-radius: 0;
+ border-top-right-radius: 0;
+}
+
+.text-left{
+ text-align: left;
+}
\ No newline at end of file
diff --git a/src/app/admin-component/add-restau/add-restau.component.spec.ts b/src/app/admin-component/add-restau/add-restau.component.spec.ts
new file mode 100644
index 0000000..f2d6986
--- /dev/null
+++ b/src/app/admin-component/add-restau/add-restau.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { AddRestauComponent } from './add-restau.component';
+
+describe('AddRestauComponent', () => {
+ let component: AddRestauComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ AddRestauComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(AddRestauComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/admin-component/add-restau/add-restau.component.ts b/src/app/admin-component/add-restau/add-restau.component.ts
new file mode 100644
index 0000000..bf2df6a
--- /dev/null
+++ b/src/app/admin-component/add-restau/add-restau.component.ts
@@ -0,0 +1,81 @@
+
+import { Component, OnInit } from '@angular/core';
+import { FormControl, FormGroup, Validators } from '@angular/forms';
+import { Router } from '@angular/router';
+import { Restaurant } from 'src/app/pages/models/restaurant';
+import { ApiBackService } from 'src/app/services/api-back.service';
+
+@Component({
+ selector: 'app-add-restau',
+ templateUrl: './add-restau.component.html',
+ styleUrls: ['./add-restau.component.scss']
+})
+export class AddRestauComponent implements OnInit {
+
+
+ public signupForm: FormGroup;
+ public errorMessage ?: string;
+
+ constructor( private router: Router, private apiBackService : ApiBackService) {
+ this.signupForm = new FormGroup({});
+ }
+
+ ngOnInit(): void {
+ 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('')
+ })
+ }
+
+ public onSubmit(): void {
+ console.log("value : ", this.signupForm.value);
+ console.log("form : ", this.signupForm);
+ const nomFc = this.signupForm.value['nomFc'];
+ const prixFc = this.signupForm.value['prixFc'];
+ const longitudeFc = this.signupForm.value['longitudeFc'];
+ const latitudeFc = this.signupForm.value['latitudeFc'];
+ const adresseFc = this.signupForm.value['adresseFc'];
+ const telephoneFc = this.signupForm.value['telephoneFc'];
+ const websiteFc = this.signupForm.value['websiteFc'];
+ const surPlaceFc = this.signupForm.value['surPlaceFc'];
+ const aEmporterFc = this.signupForm.value['aEmporterFc'];
+ const accesPMRFc = this.signupForm.value['accesPMRFc'];
+
+ const restaurant: Restaurant = {
+ latitude: latitudeFc,
+ longitude: longitudeFc,
+ nom : nomFc,
+ prix: prixFc,
+ adresse : adresseFc,
+ telephone : telephoneFc,
+ website : websiteFc,
+ surPlace : surPlaceFc,
+ aEmporter : aEmporterFc,
+ accesPMR : accesPMRFc
+ }
+ if( restaurant.latitude !== '' &&
+ restaurant.longitude !== '' &&
+ restaurant.nom !== '' &&
+ restaurant.adresse !== '' ) {
+ this.apiBackService.addRestaurant(restaurant).subscribe(
+ resp=>
+
+ this.router.navigate(['restaurants'])
+ );
+ }else{
+
+ this.errorMessage = "Renseigner les champs obligatoires **";
+ }
+
+ }
+
+}
+
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 2a0d753..1ad877a 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -19,6 +19,7 @@ import { AvisBarComponent } from './filters/avis-bar/avis-bar.component';
import { IconComponent } from './filters/icon/icon.component';
import { TemplatePageComponent } from './components/template-page/template-page.component';
import { AdminPageComponent } from './pages/admin-page/admin-page.component';
+import { AddRestauComponent } from './admin-component/add-restau/add-restau.component';
@NgModule({
declarations: [
@@ -37,7 +38,8 @@ import { AdminPageComponent } from './pages/admin-page/admin-page.component';
IconComponent,
SigninComponent,
TemplatePageComponent,
- AdminPageComponent
+ AdminPageComponent,
+ AddRestauComponent
],
imports: [
BrowserModule,
diff --git a/src/app/pages/admin-page/admin-page.component.html b/src/app/pages/admin-page/admin-page.component.html
index 1c4213c..1e715de 100644
--- a/src/app/pages/admin-page/admin-page.component.html
+++ b/src/app/pages/admin-page/admin-page.component.html
@@ -1,195 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/src/app/pages/admin-page/admin-page.component.scss b/src/app/pages/admin-page/admin-page.component.scss
index 8778894..e69de29 100644
--- a/src/app/pages/admin-page/admin-page.component.scss
+++ b/src/app/pages/admin-page/admin-page.component.scss
@@ -1,36 +0,0 @@
-.login-form {
- height: 100vh;
- padding-top: 40px;
- background-color: #f5f5f5;
-}
-
-.form-signup {
- width: 100%;
- max-width: 350px;
- padding: 15px;
- margin: auto;
-}
-
-.form-signup .checkbox {
- font-weight: 400;
-}
-
-.form-signup .form-floating:focus-within {
- z-index: 2;
-}
-
-.form-signup input[type="email"] {
- margin-bottom: -1px;
- border-bottom-right-radius: 0;
- border-bottom-left-radius: 0;
-}
-
-.form-signup input[type="password"] {
- margin-bottom: 10px;
- border-top-left-radius: 0;
- border-top-right-radius: 0;
-}
-
-.text-left{
- text-align: left;
-}
\ No newline at end of file
diff --git a/src/app/pages/admin-page/admin-page.component.ts b/src/app/pages/admin-page/admin-page.component.ts
index fa9fcd8..e431721 100644
--- a/src/app/pages/admin-page/admin-page.component.ts
+++ b/src/app/pages/admin-page/admin-page.component.ts
@@ -12,69 +12,12 @@ import { Restaurant } from '../models/restaurant';
export class AdminPageComponent implements OnInit {
- public signupForm: FormGroup;
- public errorMessage ?: string;
-
- constructor( private router: Router, private apiBackService : ApiBackService) {
- this.signupForm = new FormGroup({});
+ constructor( ) {
+
}
ngOnInit(): void {
- 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(''),
- surPlaceFc : new FormControl(''),
- aEmporterFc : new FormControl(''),
- accesPMRFc : new FormControl('')
- })
}
- public onSubmit(): void {
- console.log("value : ", this.signupForm.value);
- console.log("form : ", this.signupForm);
- const nomFc = this.signupForm.value['nomFc'];
- const prixFc = this.signupForm.value['prixFc'];
- const longitudeFc = this.signupForm.value['longitudeFc'];
- const latitudeFc = this.signupForm.value['latitudeFc'];
- const adresseFc = this.signupForm.value['adresseFc'];
- const telephoneFc = this.signupForm.value['telephoneFc'];
- const websiteFc = this.signupForm.value['websiteFc'];
- const surPlaceFc = this.signupForm.value['surPlaceFc'];
- const aEmporterFc = this.signupForm.value['aEmporterFc'];
- const accesPMRFc = this.signupForm.value['accesPMRFc'];
-
- const restaurant: Restaurant = {
- latitude: latitudeFc,
- longitude: longitudeFc,
- nom : nomFc,
- prix: prixFc,
- adresse : adresseFc,
- telephone : telephoneFc,
- website : websiteFc,
- surPlace : surPlaceFc,
- aEmporter : aEmporterFc,
- accesPMR : accesPMRFc
- }
- if( restaurant.latitude !== '' &&
- restaurant.longitude !== '' &&
- restaurant.nom !== '' &&
- restaurant.adresse !== '' ) {
- this.apiBackService.addRestaurant(restaurant).subscribe(
- resp=>
-
- this.router.navigate(['restaurants'])
- );
- }else{
- console.log("hello");
-
- this.errorMessage = "Renseigner les champs obligatoires **";
- }
-
- }
}