Files
pyrofetes-frontend/src/app/components/profil-form/profil-form.ts
2025-11-28 09:34:03 +01:00

50 lines
1.7 KiB
TypeScript

import {Component, effect, input} from '@angular/core';
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms";
import {NzColDirective} from "ng-zorro-antd/grid";
import {NzFlexDirective} from "ng-zorro-antd/flex";
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
import {NzInputDirective} from "ng-zorro-antd/input";
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
import {GetUserDto} from "../../services/api";
@Component({
selector: 'app-profil-form',
imports: [
FormsModule,
NzColDirective,
NzFlexDirective,
NzFormControlComponent,
NzFormDirective,
NzFormItemComponent,
NzFormLabelComponent,
NzInputDirective,
ReactiveFormsModule,
NzSelectComponent,
NzOptionComponent
],
templateUrl: './profil-form.html',
styleUrl: './profil-form.css',
})
export class ProfilForm {
profilForm: FormGroup = new FormGroup({
name: new FormControl<string>(null, [Validators.required]),
email: new FormControl<string>(null, [Validators.required]),
fonction: new FormControl<string>(null, [Validators.required]),
password: new FormControl<string>(null, [Validators.required])
})
user = input<GetUserDto>();
constructor() {
effect(() => {
if (this.user()) {
this.profilForm.patchValue({
name: this.user().name,
email: this.user().email,
fonction: this.user().fonction,
password: this.user().password
});
}
});
}
}