From a344348b7a44e9e852dd5b46b7ff22c3b16b4bb4 Mon Sep 17 00:00:00 2001 From: Sana EL HIRI Date: Thu, 20 Jan 2022 17:58:46 +0100 Subject: [PATCH] creation-team incomplet --- src/app/app-routing.module.ts | 2 + src/app/app.module.ts | 2 + src/app/models/membre.ts | 6 +- src/app/models/team.ts | 3 + .../page-creation-team.component.html | 30 ++++++++ .../page-creation-team.component.scss | 32 +++++++++ .../page-creation-team.component.spec.ts | 25 +++++++ .../page-creation-team.component.ts | 72 +++++++++++++++++++ .../page-signup/page-signup.component.ts | 11 +-- src/app/services/auth.service.ts | 18 ++++- src/environments/environment.ts | 2 +- 11 files changed, 193 insertions(+), 10 deletions(-) create mode 100644 src/app/models/team.ts create mode 100644 src/app/pages/page-creation-team/page-creation-team.component.html create mode 100644 src/app/pages/page-creation-team/page-creation-team.component.scss create mode 100644 src/app/pages/page-creation-team/page-creation-team.component.spec.ts create mode 100644 src/app/pages/page-creation-team/page-creation-team.component.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index ac4db0b..463ee54 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -4,6 +4,7 @@ import { PageAccountComponent } from './pages/page-account/page-account.componen import { PageAccueilComponent } from './pages/page-accueil/page-accueil.component'; import { PageAddMemberComponent } from './pages/page-add-member/page-add-member.component'; import { PageAgendaComponent } from './pages/page-agenda/page-agenda.component'; +import { PageCreationTeamComponent } from './pages/page-creation-team/page-creation-team.component'; import { PageDashboardComponent } from './pages/page-dashboard/page-dashboard.component'; import { PageDeleteMemberComponent } from './pages/page-delete-member/page-delete-member.component'; import { PageForgotPasswordComponent } from './pages/page-forgot-password/page-forgot-password.component'; @@ -30,6 +31,7 @@ const routes: Routes = [ { path: 'creation-compte', component: PageSignupComponent }, { path: 'to-do-list', component: PageToDoListComponent }, { path: 'modifier-membre', component: PageUpdateMemberComponent }, + { path: 'creation-team', component : PageCreationTeamComponent}, { path: '**', component: PageNotFoundComponent }, ]; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 9b55ae7..8c02ccc 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -33,6 +33,7 @@ import { PaginationComponent } from './components/pagination/pagination.componen import { CreneauComponent } from './components/creneau/creneau.component'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { HttpClientModule } from '@angular/common/http'; +import { PageCreationTeamComponent } from './pages/page-creation-team/page-creation-team.component'; @NgModule({ declarations: [ @@ -65,6 +66,7 @@ import { HttpClientModule } from '@angular/common/http'; FicheContactComponent, PaginationComponent, CreneauComponent, + PageCreationTeamComponent, ], imports: [ BrowserModule, diff --git a/src/app/models/membre.ts b/src/app/models/membre.ts index 798a31c..cea8af4 100644 --- a/src/app/models/membre.ts +++ b/src/app/models/membre.ts @@ -1,10 +1,10 @@ export interface Membre { - firstName: string; - lastName: string; + nom: string; + prenom: string; email: string; password: string; dateNaissance: Date; - teamName: string; profil: boolean; + roleList: string[]; passwordConfirm: string; } diff --git a/src/app/models/team.ts b/src/app/models/team.ts new file mode 100644 index 0000000..2b5752e --- /dev/null +++ b/src/app/models/team.ts @@ -0,0 +1,3 @@ +export interface Team { + nom : string; +} diff --git a/src/app/pages/page-creation-team/page-creation-team.component.html b/src/app/pages/page-creation-team/page-creation-team.component.html new file mode 100644 index 0000000..27d1f6c --- /dev/null +++ b/src/app/pages/page-creation-team/page-creation-team.component.html @@ -0,0 +1,30 @@ + + +
+
+
+

Créer votre team!

+
+ + +
+ +

+ Value : {{ teamForm.value | json }} +

+

+ Form valid : {{ teamForm.valid }} +

+ +
+
+
diff --git a/src/app/pages/page-creation-team/page-creation-team.component.scss b/src/app/pages/page-creation-team/page-creation-team.component.scss new file mode 100644 index 0000000..333e617 --- /dev/null +++ b/src/app/pages/page-creation-team/page-creation-team.component.scss @@ -0,0 +1,32 @@ +.login-form { + height: 100vh; + padding-top: 40px; + background-color: #f5f5f5; +} + +.form-signup { + width: 100%; + max-width: 330px; + 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; +} diff --git a/src/app/pages/page-creation-team/page-creation-team.component.spec.ts b/src/app/pages/page-creation-team/page-creation-team.component.spec.ts new file mode 100644 index 0000000..5386127 --- /dev/null +++ b/src/app/pages/page-creation-team/page-creation-team.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PageCreationTeamComponent } from './page-creation-team.component'; + +describe('PageCreationTeamComponent', () => { + let component: PageCreationTeamComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ PageCreationTeamComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(PageCreationTeamComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/page-creation-team/page-creation-team.component.ts b/src/app/pages/page-creation-team/page-creation-team.component.ts new file mode 100644 index 0000000..9326242 --- /dev/null +++ b/src/app/pages/page-creation-team/page-creation-team.component.ts @@ -0,0 +1,72 @@ +import { Component, OnInit } from '@angular/core'; +import { + FormBuilder, + FormControl, + FormGroup, + Validators, +} from '@angular/forms'; +import { Router } from '@angular/router'; +import { Team } from 'src/app/models/team'; +import { AuthService } from '../../services/auth.service'; + +@Component({ + selector: 'app-page-creation-team', + templateUrl: './page-creation-team.component.html', + styleUrls: ['./page-creation-team.component.scss'], +}) +export class PageCreationTeamComponent implements OnInit { + public teamForm: FormGroup; + constructor( + private authService: AuthService, + private router: Router, + private fb: FormBuilder + ) { + this.teamForm = new FormGroup({}); + } + + ngOnInit(): void { + // *********************************penser a changer group car déprécié******************************** + this.teamForm = new FormGroup({ + nameFc : new FormControl('', [Validators.required]) + }); + } + + public onSubmit(): void { + console.log('value : ', this.teamForm.value); + console.log('form : ', this.teamForm); + const nameValue = this.teamForm.value['nameFc']; + + const team: Team = { + nom : nameValue, + }; + + + + if (team.nom !== '' ) { + this.authService.creationTeam(team).subscribe((resp) => { + this.router.navigate(['compte']); + }); + } else { + // affichage erreur + } + } + + ConfirmedValidator(controlName: string, matchingControlName: string) { + return (formGroup: FormGroup) => { + const control = formGroup.controls[controlName]; + const matchingControl = formGroup.controls[matchingControlName]; + if ( + matchingControl.errors && + !matchingControl.errors['confirmedValidator'] + ) { + return; + } + if (control.value !== matchingControl.value) { + matchingControl.setErrors({ confirmedValidator: true }); + } else { + matchingControl.setErrors(null); + } + }; + } +} + diff --git a/src/app/pages/page-signup/page-signup.component.ts b/src/app/pages/page-signup/page-signup.component.ts index 4a5243a..210033c 100644 --- a/src/app/pages/page-signup/page-signup.component.ts +++ b/src/app/pages/page-signup/page-signup.component.ts @@ -25,7 +25,7 @@ export class PageSignupComponent implements OnInit { } ngOnInit(): void { - // *********************************pensser a changer group car déprécié******************************** + // *********************************penser a changer group car déprécié******************************** this.signupForm = this.fb.group( { firstNameFc: new FormControl('', [Validators.required]), @@ -64,21 +64,22 @@ export class PageSignupComponent implements OnInit { const teamNameValue = this.signupForm.value['teamNameFc']; const profilValue = this.signupForm.value['profilFc']; const passwordConfirmValue = this.signupForm.value['passwordConfirmFc']; + const teamValue = ''; const membre: Membre = { - firstName: firstNameValue, - lastName: lastNameValue, + nom: firstNameValue, + prenom: lastNameValue, email: emailValue, password: passwordValue, dateNaissance: dateNaissanceValue, - teamName: teamNameValue, profil: profilValue, passwordConfirm: passwordConfirmValue, + roleList: ["ROLE_PARENT"] }; if (membre.email !== '' && membre.password !== '') { this.authService.signup(membre).subscribe((resp) => { - this.router.navigate(['account/signin']); + this.router.navigate(['accueil']); }); } else { // affichage erreur diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 918bfd9..debe9a4 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -3,6 +3,7 @@ import { Injectable } from '@angular/core'; import { map, Observable } from 'rxjs'; import { environment } from 'src/environments/environment'; import { Membre } from '../models/membre'; +import { Team } from '../models/team'; @Injectable({ providedIn: 'root', @@ -20,9 +21,10 @@ export class AuthService { signup(membre: Membre): Observable { console.log(membre); - return this.http.post(`${this.apiUrl}/creation-compte`, membre); + return this.http.post(`${this.apiUrl}/membres/sign-up`, membre); } + signin(email: string, password: string): Observable { const body = { email: email, @@ -55,4 +57,18 @@ export class AuthService { return this.http.post(`${this.apiUrl}/forgot-psw`, body); } + + creationTeam(team: Team): Observable { + console.log(team); + + return this.http.post(`${this.apiUrl}/creation-compte`, team); + } + + + addMember(membre: Membre): Observable { + console.log(membre); + + return this.http.post(`${this.apiUrl}/tableau-de-bord`, membre); + } + } diff --git a/src/environments/environment.ts b/src/environments/environment.ts index ecf1531..90149fd 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -4,7 +4,7 @@ export const environment = { production: false, - apiUrl: 'http://localhost:3306', + apiUrl: 'http://localhost:8088', tokenKey: 'TOKEN-ORGANIZEE', };