import { Component, OnInit } from "@angular/core"; import { FormGroup, FormControl, Validators, ReactiveFormsModule, } from "@angular/forms"; import { MatLabel, MatFormFieldModule } from "@angular/material/form-field"; import { TranslateModule, TranslatePipe, TranslateService, } from "@ngx-translate/core"; import { MatInputModule } from "@angular/material/input"; import { MatButtonModule } from "@angular/material/button"; import { AuthenticationService } from "../../services/authentication.service"; import { ListOfImagesComponent } from "../list-of-images/list-of-images.component"; import { ServiceComm } from "../../services/service-comm.service"; @Component({ selector: "app-user-profile", templateUrl: "./user-profile.component.html", styleUrls: ["./user-profile.component.css"], imports: [ ListOfImagesComponent, ReactiveFormsModule, MatLabel, MatFormFieldModule, MatInputModule, MatButtonModule, TranslateModule, ], }) export class UserProfileComponent implements OnInit { public userForm: FormGroup; constructor( private authenticationService: AuthenticationService, private translateService: TranslateService, private serviceComm: ServiceComm, ) {} ngOnInit() { this.serviceComm.forceTranslateTitle.subscribe((data) => { if (data === true) { this.updateTitle(); } }); this.updateTitle(); const currentUser = this.authenticationService.currentUserValue; this.userForm = new FormGroup( { login: new FormControl(currentUser.login, Validators.required), firstName: new FormControl(currentUser.firstName, [ Validators.required, Validators.minLength(3), ]), lastName: new FormControl(currentUser.lastName, [ Validators.required, Validators.minLength(3), ]), email: new FormControl(currentUser.email, [ Validators.required, Validators.email, ]), currentPassword: new FormControl( "", Validators.pattern("^[A-Za-z0-9_-]{8,15}$"), ), newPassword: new FormControl( "", Validators.pattern("^[A-Za-z0-9_-]{8,15}$"), ), }, { updateOn: "blur" }, ); } onSubmit(formData) { if (this.userForm.invalid) { return; } // const updatedUser = new User(); // updatedUser.firstName = formData.firstName; // updatedUser.lastName = formData.lastName; // updatedUser.email = formData.email; // this.authenticationService.update(updatedUser); } private calculTailleVoile() { let tailleVoile = new Map>(); tailleVoile.set("60", [175, 161, 147, 133, 124, 115, 107, 97, 89]); tailleVoile.set("61", [178, 163, 149, 135, 126, 116, 108, 98, 90]); tailleVoile.set("62", [180, 166, 151, 137, 127, 118, 109, 99, 91]); tailleVoile.set("63", [183, 168, 153, 138, 129, 119, 111, 100, 91]); tailleVoile.set("64", [185, 170, 155, 140, 130, 121, 112, 101, 92]); tailleVoile.set("65", [188, 173, 157, 142, 132, 122, 113, 102, 93]); tailleVoile.set("66", [190, 175, 159, 144, 134, 123, 114, 103, 94]); tailleVoile.set("67", [193, 177, 161, 146, 135, 125, 116, 104, 94]); tailleVoile.set("68", [195, 179, 164, 147, 137, 126, 117, 105, 95]); tailleVoile.set("69", [198, 182, 166, 149, 138, 128, 118, 106, 96]); tailleVoile.set("70", [200, 184, 168, 151, 140, 129, 119, 107, 96]); tailleVoile.set("71", [203, 186, 170, 153, 142, 130, 120, 107, 97]); tailleVoile.set("72", [205, 189, 172, 155, 143, 132, 121, 108, 98]); tailleVoile.set("73", [208, 191, 174, 156, 145, 133, 123, 109, 99]); tailleVoile.set("74", [210, 193, 176, 158, 146, 134, 124, 110, 99]); tailleVoile.set("75", [213, 196, 178, 160, 148, 136, 125, 111, 100]); tailleVoile.set("76", [215, 198, 180, 162, 150, 137, 126, 112, 101]); tailleVoile.set("77", [218, 200, 182, 163, 151, 139, 127, 113, 101]); tailleVoile.set("78", [220, 202, 184, 165, 153, 140, 128, 114, 102]); tailleVoile.set("79", [223, 205, 186, 167, 154, 141, 129, 115, 103]); tailleVoile.set("80", [225, 207, 188, 169, 156, 143, 131, 115, 103]); tailleVoile.set("81", [228, 209, 190, 170, 157, 144, 132, 116, 104]); tailleVoile.set("82", [230, 212, 192, 172, 159, 145, 133, 117, 104]); tailleVoile.set("83", [233, 214, 194, 174, 160, 146, 134, 118, 105]); tailleVoile.set("84", [235, 216, 196, 176, 162, 148, 135, 119, 106]); tailleVoile.set("85", [238, 219, 198, 177, 163, 149, 136, 120, 106]); tailleVoile.set("86", [240, 221, 201, 179, 165, 150, 137, 120, 107]); tailleVoile.set("87", [243, 223, 203, 181, 166, 152, 138, 121, 108]); tailleVoile.set("88", [245, 225, 205, 183, 168, 153, 139, 122, 108]); tailleVoile.set("89", [248, 228, 207, 184, 170, 154, 140, 123, 109]); tailleVoile.set("90", [250, 230, 209, 186, 171, 156, 141, 124, 109]); tailleVoile.set("91", [253, 232, 211, 188, 173, 157, 143, 124, 110]); tailleVoile.set("92", [255, 235, 213, 190, 174, 158, 144, 125, 110]); tailleVoile.set("93", [258, 237, 215, 191, 176, 159, 145, 126, 111]); tailleVoile.set("94", [260, 239, 217, 193, 177, 161, 146, 127, 112]); tailleVoile.set("95", [263, 242, 219, 195, 179, 162, 147, 128, 112]); tailleVoile.set("96", [265, 244, 221, 197, 180, 163, 148, 128, 113]); tailleVoile.set("97", [268, 246, 223, 198, 182, 164, 149, 129, 113]); tailleVoile.set("98", [270, 248, 225, 200, 183, 166, 150, 130, 114]); tailleVoile.set("99", [273, 251, 227, 202, 185, 167, 151, 131, 114]); tailleVoile.set("100", [275, 253, 229, 203, 186, 168, 152, 131, 115]); tailleVoile.set("101", [278, 255, 231, 205, 188, 169, 153, 132, 115]); tailleVoile.set("102", [280, 258, 233, 207, 189, 171, 154, 133, 116]); tailleVoile.set("103", [283, 260, 235, 209, 190, 172, 155, 134, 116]); tailleVoile.set("104", [285, 262, 237, 210, 192, 173, 156, 134, 117]); tailleVoile.set("105", [288, 265, 239, 212, 193, 174, 157, 135, 118]); tailleVoile.set("106", [290, 267, 241, 214, 195, 175, 158, 136, 118]); tailleVoile.set("107", [293, 269, 243, 215, 196, 177, 159, 136, 119]); tailleVoile.set("108", [295, 271, 245, 217, 198, 178, 160, 137, 119]); tailleVoile.set("109", [298, 274, 247, 219, 199, 179, 161, 138, 120]); tailleVoile.set("110", [300, 276, 249, 220, 201, 180, 162, 138, 120]); } private updateTitle() { this.translateService.get("UserProfile_Title").subscribe((data) => { this.serviceComm.updatedComponentTitle(data); }); } }