add member avec role ok account récupère les membre en focntion de la team
This commit is contained in:
parent
7784870446
commit
466a146174
@ -1,6 +1,6 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { MembreService } from 'src/app/services/membre.service';
|
import { MembreService } from 'src/app/services/membre.service';
|
||||||
import { TeamService } from 'src/app/services/team.service';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-page-account',
|
selector: 'app-page-account',
|
||||||
@ -10,14 +10,15 @@ import { TeamService } from 'src/app/services/team.service';
|
|||||||
export class PageAccountComponent implements OnInit {
|
export class PageAccountComponent implements OnInit {
|
||||||
public listMembres: any[];
|
public listMembres: any[];
|
||||||
|
|
||||||
constructor(private teamService: TeamService, private membreService: MembreService) {
|
constructor(private membreService: MembreService) {
|
||||||
this.listMembres = [];
|
this.listMembres = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.membreService.getMembres().subscribe((membres: any[]) => {
|
this.membreService.getMembresByTeamId()?.subscribe((membres: any[]) => {
|
||||||
|
console.log(membres);
|
||||||
this.listMembres = membres;
|
this.listMembres = membres;
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,20 @@
|
|||||||
!addMemberForm.controls['emailFc'].valid
|
!addMemberForm.controls['emailFc'].valid
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
<label for="floatingInputemail">VOTRE EMAIL</label>
|
<label for="floatingInputemail">Votre Email</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-floating">
|
||||||
|
<select
|
||||||
|
class="form-control"
|
||||||
|
id="floatingInputRole"
|
||||||
|
placeholder=""
|
||||||
|
name="Role"
|
||||||
|
formControlName="roleFc"
|
||||||
|
>
|
||||||
|
<option value="ROLE_PARENT">Adulte</option>
|
||||||
|
<option value="ROLE_ENFANT">Enfant</option>
|
||||||
|
</select>
|
||||||
|
<label value="ROLE_PARENT">Sélectionner un profil</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
<input
|
<input
|
||||||
|
@ -29,6 +29,7 @@ export class PageAddMemberComponent implements OnInit {
|
|||||||
firstNameFc: new FormControl('', [Validators.required]),
|
firstNameFc: new FormControl('', [Validators.required]),
|
||||||
lastNameFc: new FormControl('', [Validators.required]),
|
lastNameFc: new FormControl('', [Validators.required]),
|
||||||
dateNaissanceFc: new FormControl('', [Validators.required]),
|
dateNaissanceFc: new FormControl('', [Validators.required]),
|
||||||
|
roleFc: new FormControl('', []),
|
||||||
couleurFc: new FormControl('', []),
|
couleurFc: new FormControl('', []),
|
||||||
emailFc: new FormControl('', [
|
emailFc: new FormControl('', [
|
||||||
Validators.email,
|
Validators.email,
|
||||||
@ -56,6 +57,7 @@ export class PageAddMemberComponent implements OnInit {
|
|||||||
const firstNameValue = this.addMemberForm.value['firstNameFc'];
|
const firstNameValue = this.addMemberForm.value['firstNameFc'];
|
||||||
const lastNameValue = this.addMemberForm.value['lastNameFc'];
|
const lastNameValue = this.addMemberForm.value['lastNameFc'];
|
||||||
const emailValue = this.addMemberForm.value['emailFc'];
|
const emailValue = this.addMemberForm.value['emailFc'];
|
||||||
|
const roleValue = this.addMemberForm.value['roleFc'];
|
||||||
const passwordValue = this.addMemberForm.value['passwordFc'];
|
const passwordValue = this.addMemberForm.value['passwordFc'];
|
||||||
const dateNaissanceValue = this.addMemberForm.value['dateNaissanceFc'];
|
const dateNaissanceValue = this.addMemberForm.value['dateNaissanceFc'];
|
||||||
const couleurValue = this.addMemberForm.value['couleurFc'];
|
const couleurValue = this.addMemberForm.value['couleurFc'];
|
||||||
@ -70,12 +72,12 @@ export class PageAddMemberComponent implements OnInit {
|
|||||||
couleur: couleurValue,
|
couleur: couleurValue,
|
||||||
dateNaissance: dateNaissanceValue,
|
dateNaissance: dateNaissanceValue,
|
||||||
passwordConfirm: passwordConfirmValue,
|
passwordConfirm: passwordConfirmValue,
|
||||||
roleList: ["ROLE_PARENT"]
|
roleList: [roleValue]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if (membre.email !== '' && membre.password !== '') {
|
if (membre.email !== '' && membre.password !== '') {
|
||||||
this.membreService.addMembre(membre).subscribe((resp) => {
|
this.membreService.addMembre(membre)?.subscribe((resp) => {
|
||||||
this.router.navigate(['compte']);
|
this.router.navigate(['compte']);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -7,6 +7,7 @@ import {
|
|||||||
} from '@angular/forms';
|
} from '@angular/forms';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { Team } from 'src/app/models/team';
|
import { Team } from 'src/app/models/team';
|
||||||
|
import { MembreService } from 'src/app/services/membre.service';
|
||||||
import { TeamService } from 'src/app/services/team.service';
|
import { TeamService } from 'src/app/services/team.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -18,6 +19,7 @@ export class PageCreationTeamComponent implements OnInit {
|
|||||||
public teamForm: FormGroup;
|
public teamForm: FormGroup;
|
||||||
constructor(
|
constructor(
|
||||||
private teamService: TeamService,
|
private teamService: TeamService,
|
||||||
|
private membreService: MembreService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private fb: FormBuilder
|
private fb: FormBuilder
|
||||||
) {
|
) {
|
||||||
@ -39,9 +41,6 @@ export class PageCreationTeamComponent implements OnInit {
|
|||||||
const team: Team = {
|
const team: Team = {
|
||||||
nom : nameValue,
|
nom : nameValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (team.nom !== '' ) {
|
if (team.nom !== '' ) {
|
||||||
this.teamService.addTeam(team).subscribe((resp) => {
|
this.teamService.addTeam(team).subscribe((resp) => {
|
||||||
this.router.navigate(['compte']);
|
this.router.navigate(['compte']);
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
import { Observable } from 'rxjs';
|
import { 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 { TokenService } from './token.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -11,7 +13,7 @@ export class MembreService {
|
|||||||
apiUrl: string;
|
apiUrl: string;
|
||||||
tokenKey: string;
|
tokenKey: string;
|
||||||
|
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient, private tokenService: TokenService, private router: Router) {
|
||||||
this.apiUrl = environment.apiUrl;
|
this.apiUrl = environment.apiUrl;
|
||||||
this.tokenKey = environment.tokenKey;
|
this.tokenKey = environment.tokenKey;
|
||||||
}
|
}
|
||||||
@ -20,13 +22,27 @@ export class MembreService {
|
|||||||
return this.http.get(`${this.apiUrl}/membres/all`);
|
return this.http.get(`${this.apiUrl}/membres/all`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getMembresByTeamId(): Observable<any> | void{
|
||||||
|
const teamId = this.tokenService.getCurrentTeamId();
|
||||||
|
if (teamId){
|
||||||
|
return this.http.get(`${this.apiUrl}/membres/team/${teamId}`);
|
||||||
|
}else {
|
||||||
|
this.router.navigate(['accueil']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
getMembreId(id: any): Observable<any> {
|
getMembreId(id: any): Observable<any> {
|
||||||
return this.http.get(`${this.apiUrl}/membres/` + id);
|
return this.http.get(`${this.apiUrl}/membres/` + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
addMembre(membre: Membre): Observable<any> {
|
addMembre(membre: Membre): Observable<any> | void{
|
||||||
console.log(membre);
|
const teamId = this.tokenService.getCurrentTeamId();
|
||||||
return this.http.post(`${this.apiUrl}/membres/sign-up`, membre);
|
if (teamId){
|
||||||
|
return this.http.post(`${this.apiUrl}/membres/add/${teamId}`, membre);
|
||||||
|
}else {
|
||||||
|
this.router.navigate(['accueil']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteMembre(membre: Membre): Observable<any> {
|
deleteMembre(membre: Membre): Observable<any> {
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
import { Team } from '../models/team';
|
import { Team } from '../models/team';
|
||||||
|
import { TokenService } from './token.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -12,7 +14,7 @@ export class TeamService {
|
|||||||
tokenKey: string;
|
tokenKey: string;
|
||||||
|
|
||||||
|
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient, private tokenService: TokenService, private router: Router) {
|
||||||
this.apiUrl = environment.apiUrl;
|
this.apiUrl = environment.apiUrl;
|
||||||
this.tokenKey = environment.tokenKey;
|
this.tokenKey = environment.tokenKey;
|
||||||
}
|
}
|
||||||
@ -20,8 +22,13 @@ export class TeamService {
|
|||||||
return this.http.get(`${this.apiUrl}/teams/all`);
|
return this.http.get(`${this.apiUrl}/teams/all`);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTeamById(id: any): Observable<any> {
|
getTeamById(): Observable<any> | void {
|
||||||
return this.http.get(`${this.apiUrl}/teams/1` + id);
|
const teamId = this.tokenService.getCurrentTeamId();
|
||||||
|
if (teamId){
|
||||||
|
return this.http.get(`${this.apiUrl}/teams/${teamId}`);
|
||||||
|
} else {
|
||||||
|
this.router.navigate(['accueil']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addTeam(team: Team): Observable<any> {
|
addTeam(team: Team): Observable<any> {
|
||||||
|
Loading…
Reference in New Issue
Block a user