Merge pull request #5 from AlineRinquin/sana

creation-team incomplet
This commit is contained in:
AlineRinquin 2022-01-21 09:45:40 +01:00 committed by GitHub
commit 0d8e6f63b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 177 additions and 0 deletions

View File

@ -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 },
];

View File

@ -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,

3
src/app/models/team.ts Normal file
View File

@ -0,0 +1,3 @@
export interface Team {
nom : string;
}

View File

@ -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>

View File

@ -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;
}

View File

@ -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();
});
});

View File

@ -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);
}
};
}
}

View File

@ -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',
@ -23,6 +24,7 @@ export class AuthService {
return this.http.post(`${this.apiUrl}/membres/sign-up`, membre);
}
signin(email: string, password: string): Observable<any> {
const body = {
email: email,
@ -56,6 +58,15 @@ export class AuthService {
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);