diff --git a/angular/src/app/account/account.component.html b/angular/src/app/account/account.component.html index 67e00d1..2240c42 100644 --- a/angular/src/app/account/account.component.html +++ b/angular/src/app/account/account.component.html @@ -5,39 +5,71 @@

Ajouter vos informations

- -
-
-
- -
- - -
- -
- -
- +
+ + +
+
+
+ +
+ + +
+ +
+ + +
+ +
+
-
-
-
- - @ - -
-
- - @edu.igensia.com -
-
- Adresse - -
- + + + +
+ + + +
+
+ + + +
+ + +
+ + @edu.igensia.com +
+ + + +
+ Adresse + +
+ + + + + +
diff --git a/angular/src/app/account/account.component.ts b/angular/src/app/account/account.component.ts index efb49a6..da5bb06 100644 --- a/angular/src/app/account/account.component.ts +++ b/angular/src/app/account/account.component.ts @@ -1,4 +1,5 @@ import { Component } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; @Component({ selector: 'app-account', @@ -8,44 +9,39 @@ import { Component } from '@angular/core'; }) export class AccountComponent { - info: Info = new Info(); - infos: Array = []; - newInfo: boolean = false; - - constructor() {} - ngOnInit(): void {} + infoForm: FormGroup; + infos: any[] = []; + + constructor(private fb: FormBuilder) { + this.infoForm = this.fb.group({ + gender: ['', Validators.required], + nameLast: ['', [Validators.required, Validators.minLength(3)]], + nameFirst: ['', [Validators.required, Validators.minLength(3)]], + email: ['', [Validators.required, Validators.pattern(/^[a-zA-Z0-9._%+-]+$/)]], + address: ['', [Validators.required, Validators.minLength(10)]], + }); + } addInfo() { - if (this.info.gender && this.info.nameFirst && this.info.nameLast && this.info.email && this.info.address) { - this.info.date = new Date(); - this.info.nameFirst = this.info.nameFirst.charAt(0).toUpperCase() + this.info.nameFirst.slice(1).toLowerCase() - this.infos.push({ - gender: this.info.gender, - nameFirst: this.info.nameFirst, - nameLast: this.info.nameLast.toUpperCase(), - email: this.info.email.toLowerCase() + '@edu.igensia.com', - address: this.info.address, - date: this.info.date - }) - this.info.nameFirst = ''; - this.info.nameLast = ''; - this.info.email = ''; - this.info.address = ''; - this.info.gender = ''; + if (this.infoForm.valid) { + const formData = this.infoForm.value; + + // Ajouter @edu.igensia.com automatiquement + const email = formData.email.toLowerCase(); + const fullEmail = `${email}@edu.igensia.com`; + const nameLast = formData.nameLast.toUpperCase(); + const nameFirst = formData.nameFirst.charAt(0).toUpperCase() + formData.nameFirst.slice(1).toLowerCase(); + + const newInfo = { + ...formData, + nameLast: nameLast, // Mettre l'email complet + nameFirst: nameFirst, // Mettre l'email complet + email: fullEmail, // Mettre l'email complet + date: new Date() // Ajoute la date actuelle + }; + + this.infos.push(newInfo); + this.infoForm.reset(); // Réinitialise le formulaire après l'ajout } } - - updateGender() { - // console.log("Le genre sélectionné est :", this.info.gender); - } - -} - -export class Info { - gender: string = ''; - nameFirst: string = ''; - nameLast: string = ''; - email: string = ''; - address: string= ''; - date: Date | null = null; } diff --git a/angular/src/app/app.module.ts b/angular/src/app/app.module.ts index 679a4ef..a68d7b5 100644 --- a/angular/src/app/app.module.ts +++ b/angular/src/app/app.module.ts @@ -4,7 +4,7 @@ import { BrowserModule } from '@angular/platform-browser'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { AboutComponent } from './about/about.component'; -import { FormsModule } from '@angular/forms'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { ContactsComponent } from './contacts/contacts.component'; import { HomeComponent } from './home/home.component'; import { NavBarComponent } from './nav-bar/nav-bar.component'; @@ -22,7 +22,8 @@ import { AccountComponent } from './account/account.component'; imports: [ BrowserModule, AppRoutingModule, - FormsModule + FormsModule, + ReactiveFormsModule ], providers: [], bootstrap: [AppComponent] diff --git a/angular/src/styles.css b/angular/src/styles.css index c0224a9..1ba49e4 100644 --- a/angular/src/styles.css +++ b/angular/src/styles.css @@ -5,6 +5,11 @@ border-bottom: 2px solid #ffc107; } +.fs-40 { + padding-top: 2px !important; + padding-bottom: 2px !important; +} + .breakWord { word-break: break-word; word-wrap: break-word; diff --git a/formation_angular_session2_04032025.pptx b/formation_angular_session2_04032025.pptx new file mode 100644 index 0000000..6456d80 Binary files /dev/null and b/formation_angular_session2_04032025.pptx differ