creation-team incomplet
This commit is contained in:
parent
559be4fbd9
commit
a344348b7a
@ -4,6 +4,7 @@ import { PageAccountComponent } from './pages/page-account/page-account.componen
|
|||||||
import { PageAccueilComponent } from './pages/page-accueil/page-accueil.component';
|
import { PageAccueilComponent } from './pages/page-accueil/page-accueil.component';
|
||||||
import { PageAddMemberComponent } from './pages/page-add-member/page-add-member.component';
|
import { PageAddMemberComponent } from './pages/page-add-member/page-add-member.component';
|
||||||
import { PageAgendaComponent } from './pages/page-agenda/page-agenda.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 { PageDashboardComponent } from './pages/page-dashboard/page-dashboard.component';
|
||||||
import { PageDeleteMemberComponent } from './pages/page-delete-member/page-delete-member.component';
|
import { PageDeleteMemberComponent } from './pages/page-delete-member/page-delete-member.component';
|
||||||
import { PageForgotPasswordComponent } from './pages/page-forgot-password/page-forgot-password.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: 'creation-compte', component: PageSignupComponent },
|
||||||
{ path: 'to-do-list', component: PageToDoListComponent },
|
{ path: 'to-do-list', component: PageToDoListComponent },
|
||||||
{ path: 'modifier-membre', component: PageUpdateMemberComponent },
|
{ path: 'modifier-membre', component: PageUpdateMemberComponent },
|
||||||
|
{ path: 'creation-team', component : PageCreationTeamComponent},
|
||||||
{ path: '**', component: PageNotFoundComponent },
|
{ path: '**', component: PageNotFoundComponent },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ import { PaginationComponent } from './components/pagination/pagination.componen
|
|||||||
import { CreneauComponent } from './components/creneau/creneau.component';
|
import { CreneauComponent } from './components/creneau/creneau.component';
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
|
import { PageCreationTeamComponent } from './pages/page-creation-team/page-creation-team.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@ -65,6 +66,7 @@ import { HttpClientModule } from '@angular/common/http';
|
|||||||
FicheContactComponent,
|
FicheContactComponent,
|
||||||
PaginationComponent,
|
PaginationComponent,
|
||||||
CreneauComponent,
|
CreneauComponent,
|
||||||
|
PageCreationTeamComponent,
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
export interface Membre {
|
export interface Membre {
|
||||||
firstName: string;
|
nom: string;
|
||||||
lastName: string;
|
prenom: string;
|
||||||
email: string;
|
email: string;
|
||||||
password: string;
|
password: string;
|
||||||
dateNaissance: Date;
|
dateNaissance: Date;
|
||||||
teamName: string;
|
|
||||||
profil: boolean;
|
profil: boolean;
|
||||||
|
roleList: string[];
|
||||||
passwordConfirm: string;
|
passwordConfirm: string;
|
||||||
}
|
}
|
||||||
|
3
src/app/models/team.ts
Normal file
3
src/app/models/team.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export interface Team {
|
||||||
|
nom : string;
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
<app-header></app-header>
|
||||||
|
<app-side-bar></app-side-bar>
|
||||||
|
<div class="signup-form text-center">
|
||||||
|
<main class="form-signup">
|
||||||
|
<form (ngSubmit)="onSubmit()" [formGroup]="teamForm">
|
||||||
|
<h1>Créer votre team!</h1>
|
||||||
|
<div class="form-floating">
|
||||||
|
<input type="text"
|
||||||
|
class="form-control"
|
||||||
|
id="floatingInputName"
|
||||||
|
placeholder=""
|
||||||
|
name="name"
|
||||||
|
formControlName="nameFc"
|
||||||
|
[ngClass]="{'is-valid' : teamForm.controls['nameFc'].touched && teamForm.controls['nameFc'].valid,
|
||||||
|
'is-invalid': teamForm.controls['nameFc'].touched && !teamForm.controls['nameFc'].valid}">
|
||||||
|
<label for="floatingInputName">Nom</label>
|
||||||
|
</div>
|
||||||
|
<button class="w-100 btn btn-lg btn-success"
|
||||||
|
type="submit"
|
||||||
|
[disabled]="teamForm.invalid">Je crée ma team</button>
|
||||||
|
<p>
|
||||||
|
Value : {{ teamForm.value | json }}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Form valid : {{ teamForm.valid }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
|
</div>
|
@ -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;
|
||||||
|
}
|
@ -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<PageCreationTeamComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ PageCreationTeamComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(PageCreationTeamComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@ -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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -25,7 +25,7 @@ export class PageSignupComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
// *********************************pensser a changer group car déprécié********************************
|
// *********************************penser a changer group car déprécié********************************
|
||||||
this.signupForm = this.fb.group(
|
this.signupForm = this.fb.group(
|
||||||
{
|
{
|
||||||
firstNameFc: new FormControl('', [Validators.required]),
|
firstNameFc: new FormControl('', [Validators.required]),
|
||||||
@ -64,21 +64,22 @@ export class PageSignupComponent implements OnInit {
|
|||||||
const teamNameValue = this.signupForm.value['teamNameFc'];
|
const teamNameValue = this.signupForm.value['teamNameFc'];
|
||||||
const profilValue = this.signupForm.value['profilFc'];
|
const profilValue = this.signupForm.value['profilFc'];
|
||||||
const passwordConfirmValue = this.signupForm.value['passwordConfirmFc'];
|
const passwordConfirmValue = this.signupForm.value['passwordConfirmFc'];
|
||||||
|
const teamValue = '';
|
||||||
|
|
||||||
const membre: Membre = {
|
const membre: Membre = {
|
||||||
firstName: firstNameValue,
|
nom: firstNameValue,
|
||||||
lastName: lastNameValue,
|
prenom: lastNameValue,
|
||||||
email: emailValue,
|
email: emailValue,
|
||||||
password: passwordValue,
|
password: passwordValue,
|
||||||
dateNaissance: dateNaissanceValue,
|
dateNaissance: dateNaissanceValue,
|
||||||
teamName: teamNameValue,
|
|
||||||
profil: profilValue,
|
profil: profilValue,
|
||||||
passwordConfirm: passwordConfirmValue,
|
passwordConfirm: passwordConfirmValue,
|
||||||
|
roleList: ["ROLE_PARENT"]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (membre.email !== '' && membre.password !== '') {
|
if (membre.email !== '' && membre.password !== '') {
|
||||||
this.authService.signup(membre).subscribe((resp) => {
|
this.authService.signup(membre).subscribe((resp) => {
|
||||||
this.router.navigate(['account/signin']);
|
this.router.navigate(['accueil']);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// affichage erreur
|
// affichage erreur
|
||||||
|
@ -3,6 +3,7 @@ import { Injectable } from '@angular/core';
|
|||||||
import { map, Observable } from 'rxjs';
|
import { map, Observable } from 'rxjs';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
import { Membre } from '../models/membre';
|
import { Membre } from '../models/membre';
|
||||||
|
import { Team } from '../models/team';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@ -20,9 +21,10 @@ export class AuthService {
|
|||||||
signup(membre: Membre): Observable<any> {
|
signup(membre: Membre): Observable<any> {
|
||||||
console.log(membre);
|
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<any> {
|
signin(email: string, password: string): Observable<any> {
|
||||||
const body = {
|
const body = {
|
||||||
email: email,
|
email: email,
|
||||||
@ -55,4 +57,18 @@ export class AuthService {
|
|||||||
|
|
||||||
return this.http.post(`${this.apiUrl}/forgot-psw`, body);
|
return this.http.post(`${this.apiUrl}/forgot-psw`, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
creationTeam(team: Team): Observable<any> {
|
||||||
|
console.log(team);
|
||||||
|
|
||||||
|
return this.http.post(`${this.apiUrl}/creation-compte`, team);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
addMember(membre: Membre): Observable<any> {
|
||||||
|
console.log(membre);
|
||||||
|
|
||||||
|
return this.http.post(`${this.apiUrl}/tableau-de-bord`, membre);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: false,
|
production: false,
|
||||||
apiUrl: 'http://localhost:3306',
|
apiUrl: 'http://localhost:8088',
|
||||||
tokenKey: 'TOKEN-ORGANIZEE',
|
tokenKey: 'TOKEN-ORGANIZEE',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user