From 044ad477f2a02d8d7f6ceb776e5e253abf289c07 Mon Sep 17 00:00:00 2001 From: Chneemann Date: Wed, 7 May 2025 10:54:39 +0200 Subject: [PATCH] docs: add JSDoc comments to EmailRequestComponent functions --- .../email-request/email-request.component.ts | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/components/auth/forgot-password/email-request/email-request.component.ts b/frontend/src/app/components/auth/forgot-password/email-request/email-request.component.ts index 8f2297f..a608396 100644 --- a/frontend/src/app/components/auth/forgot-password/email-request/email-request.component.ts +++ b/frontend/src/app/components/auth/forgot-password/email-request/email-request.component.ts @@ -22,16 +22,30 @@ export class EmailRequestComponent implements OnInit { form: FormGroup = new FormGroup({}); + /** + * Initializes the EmailRequestComponent with FormBuilder, AuthService, and ErrorService. + */ constructor( - private errorService: ErrorService, + private fb: FormBuilder, private authService: AuthService, - private fb: FormBuilder + private errorService: ErrorService ) {} + /** + * Lifecycle hook that initializes the component. + * Initializes the form on component load. + */ ngOnInit(): void { this.createForm(); } + /** + * Handles the form submission process. + * Validates the form, sends a forgot-password request, + * and emits a submission event on success. + * + * @returns A Promise that resolves when the process is complete. + */ async onSubmit(): Promise { if (this.form.valid) { const body = this.createFormRequestBody(); @@ -48,18 +62,29 @@ export class EmailRequestComponent implements OnInit { } } + /** + * Initializes the reactive form with validators. + */ private createForm(): void { this.form = this.fb.group({ email: ['', [Validators.required, emailFormatValidator()]], }); } + /** + * Constructs the request payload from the form values. + * + * @returns An object containing the normalized email address. + */ private createFormRequestBody(): { email: string } { return { email: this.form.value.email.toLowerCase(), }; } + /** + * Emits an event indicating that the form was successfully submitted. + */ private emitFormSubmitted(): void { this.submittedChange.emit(true); }