signup : crée une nouvelle team et un nouveau membre mais ne fait pas le lien entre les deux/ suppression : page création team
This commit is contained in:
parent
4b90b0e1b2
commit
50d5794668
9 changed files with 14 additions and 188 deletions
|
@ -5,7 +5,6 @@ import { PageAccueilComponent } from './pages/page-accueil/page-accueil.componen
|
|||
import { PageAddMemberComponent } from './pages/page-add-member/page-add-member.component';
|
||||
import { PageAgendaComponent } from './pages/page-agenda/page-agenda.component';
|
||||
import { PageAjoutContactComponent } from './pages/page-ajout-contact/page-ajout-contact.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';
|
||||
|
@ -40,7 +39,6 @@ const routes: Routes = [
|
|||
{ path: 'to-do-list', canActivate: [AuthGuard], component: PageToDoListComponent },
|
||||
{ path: 'modifier-membre/:id', canActivate: [AuthGuard], component: PageUpdateMemberComponent },
|
||||
{ path: 'ajouter-contact', canActivate: [AuthGuard], component: PageAjoutContactComponent },
|
||||
{ path: 'creation-team', canActivate: [AuthGuard], component: PageCreationTeamComponent },
|
||||
{ path: 'footer', component: FooterComponent},
|
||||
{ path: 'ajout-evenement', canActivate: [AuthGuard], component: PageAjoutEvenementsComponent },
|
||||
{ path: '**', component: PageNotFoundComponent },
|
||||
|
|
|
@ -31,7 +31,6 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|||
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||
import { PageAjoutContactComponent } from './pages/page-ajout-contact/page-ajout-contact.component';
|
||||
import { PageModifierContactComponent } from './pages/page-modifier-contact/page-modifier-contact.component';
|
||||
import { PageCreationTeamComponent } from './pages/page-creation-team/page-creation-team.component';
|
||||
import { AutofocusFixModule } from 'ngx-autofocus-fix';
|
||||
import { FooterComponent } from './components/footer/footer.component';
|
||||
import { DayPilot, DayPilotModule } from "@daypilot/daypilot-lite-angular";
|
||||
|
@ -74,7 +73,6 @@ registerLocaleData(localeFr)
|
|||
CreneauComponent,
|
||||
PageAjoutContactComponent,
|
||||
PageModifierContactComponent,
|
||||
PageCreationTeamComponent,
|
||||
FooterComponent,
|
||||
CardAvatarComponent,
|
||||
DeconnexionComponent,
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
<app-header></app-header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-auto">
|
||||
<app-side-bar></app-side-bar>
|
||||
</div>
|
||||
<div class="col team-form text-center">
|
||||
<h1>Créer votre team</h1>
|
||||
<main class="form-team">
|
||||
<form (ngSubmit)="onSubmit()" [formGroup]="teamForm">
|
||||
<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>
|
||||
</form>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
|
@ -1,41 +0,0 @@
|
|||
.team-form{
|
||||
margin-top: 20px;
|
||||
align-content: center;
|
||||
|
||||
}
|
||||
|
||||
button{
|
||||
margin-top: 10px;
|
||||
}
|
||||
.login-form {
|
||||
height: 100vh;
|
||||
padding-top: 40px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.form-team {
|
||||
width: 100%;
|
||||
max-width: 500px;
|
||||
padding: 15px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.form-team .checkbox {
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.form-team .form-floating:focus-within {
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.form-team input[type="email"] {
|
||||
margin-bottom: -1px;
|
||||
border-bottom-right-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
.form-team input[type="password"] {
|
||||
margin-bottom: 10px;
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
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();
|
||||
});
|
||||
});
|
|
@ -1,71 +0,0 @@
|
|||
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 { MembreService } from 'src/app/services/membre.service';
|
||||
import { TeamService } from 'src/app/services/team.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 teamService: TeamService,
|
||||
private membreService: MembreService,
|
||||
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.teamService.addTeam(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);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Membre } from 'src/app/models/membre';
|
||||
import { MembreService } from 'src/app/services/membre.service';
|
||||
import { TokenService } from 'src/app/services/token.service';
|
||||
|
||||
|
@ -45,7 +44,7 @@ export class PageDeleteMemberComponent implements OnInit {
|
|||
|
||||
}
|
||||
|
||||
/** Suppresion d'un membre au clik */
|
||||
/********************** Suppresion d'un membre au click ********************/
|
||||
onClickDelete(): void {
|
||||
console.log(this.membreInfos);
|
||||
this.membreService.deleteMembre(this.membreInfos.id).subscribe((resp) => {
|
||||
|
|
|
@ -6,6 +6,8 @@ import {
|
|||
Validators,
|
||||
} from '@angular/forms';
|
||||
import { Router, RouterLink } from '@angular/router';
|
||||
import { Team } from 'src/app/models/team';
|
||||
import { TeamService } from 'src/app/services/team.service';
|
||||
import { Membre } from '../../models/membre';
|
||||
import { AuthService } from '../../services/auth.service';
|
||||
|
||||
|
@ -19,6 +21,7 @@ export class PageSignupComponent implements OnInit {
|
|||
|
||||
constructor(
|
||||
private authService: AuthService,
|
||||
private teamService: TeamService,
|
||||
private router: Router,
|
||||
private fb: FormBuilder
|
||||
) {
|
||||
|
@ -29,6 +32,7 @@ export class PageSignupComponent implements OnInit {
|
|||
// *********************************pensser a changer group car déprécié********************************
|
||||
this.signupForm = this.fb.group(
|
||||
{
|
||||
teamNameFc: new FormControl('', [Validators.required]),
|
||||
firstNameFc: new FormControl('', [Validators.required]),
|
||||
lastNameFc: new FormControl('', [Validators.required]),
|
||||
dateNaissanceFc: new FormControl('', [Validators.required]),
|
||||
|
@ -55,6 +59,7 @@ export class PageSignupComponent implements OnInit {
|
|||
}
|
||||
|
||||
public onSubmit(): void {
|
||||
const teamNameValue = this.signupForm.value['teamNameFc'];
|
||||
const idValue = this.signupForm.value[''];
|
||||
const prenomValue = this.signupForm.value['firstNameFc'];
|
||||
const nomValue = this.signupForm.value['lastNameFc'];
|
||||
|
@ -65,6 +70,10 @@ export class PageSignupComponent implements OnInit {
|
|||
const couleurValue = this.signupForm.value['couleurFc'];
|
||||
const roleValue = ['ROLE_PARENT'];
|
||||
|
||||
const team: Team = {
|
||||
nom : teamNameValue,
|
||||
};
|
||||
|
||||
const membre: Membre = {
|
||||
id: idValue,
|
||||
nom: nomValue,
|
||||
|
@ -77,7 +86,10 @@ export class PageSignupComponent implements OnInit {
|
|||
roleList: roleValue,
|
||||
};
|
||||
|
||||
if (membre.email !== '' && membre.password !== '') {
|
||||
if (membre.email !== '' && membre.password !== '' && team.nom!== '') {
|
||||
this.teamService.addTeam(team).subscribe((resp) => {
|
||||
return resp
|
||||
});
|
||||
this.authService.signup(membre).subscribe((resp) => {
|
||||
this.router.navigate(['accueil']);
|
||||
});
|
||||
|
|
|
@ -22,9 +22,7 @@ export class AuthService {
|
|||
//methode pour s'inscrire - on passe l'objet en entier
|
||||
signup(membre: Membre): Observable<any> {
|
||||
console.log(membre);
|
||||
|
||||
return this.http.post(`${this.apiUrl}/membres/sign-up`, membre);
|
||||
|
||||
}
|
||||
|
||||
//methode pour se connecter - on passe id et pwd
|
||||
|
@ -60,8 +58,6 @@ export class AuthService {
|
|||
return this.http.post(`${this.apiUrl}/teams/add`, team);
|
||||
}
|
||||
|
||||
|
||||
|
||||
addMember(membre: Membre): Observable<any> {
|
||||
console.log(membre);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue