docs: add JSDoc comments to EmailRequestComponent functions

This commit is contained in:
Chneemann 2025-05-07 10:54:39 +02:00
parent 14bb6c520c
commit 044ad477f2

View file

@ -22,16 +22,30 @@ export class EmailRequestComponent implements OnInit {
form: FormGroup = new FormGroup({}); form: FormGroup = new FormGroup({});
/**
* Initializes the EmailRequestComponent with FormBuilder, AuthService, and ErrorService.
*/
constructor( constructor(
private errorService: ErrorService, private fb: FormBuilder,
private authService: AuthService, private authService: AuthService,
private fb: FormBuilder private errorService: ErrorService
) {} ) {}
/**
* Lifecycle hook that initializes the component.
* Initializes the form on component load.
*/
ngOnInit(): void { ngOnInit(): void {
this.createForm(); 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<void> { async onSubmit(): Promise<void> {
if (this.form.valid) { if (this.form.valid) {
const body = this.createFormRequestBody(); const body = this.createFormRequestBody();
@ -48,18 +62,29 @@ export class EmailRequestComponent implements OnInit {
} }
} }
/**
* Initializes the reactive form with validators.
*/
private createForm(): void { private createForm(): void {
this.form = this.fb.group({ this.form = this.fb.group({
email: ['', [Validators.required, emailFormatValidator()]], email: ['', [Validators.required, emailFormatValidator()]],
}); });
} }
/**
* Constructs the request payload from the form values.
*
* @returns An object containing the normalized email address.
*/
private createFormRequestBody(): { email: string } { private createFormRequestBody(): { email: string } {
return { return {
email: this.form.value.email.toLowerCase(), email: this.form.value.email.toLowerCase(),
}; };
} }
/**
* Emits an event indicating that the form was successfully submitted.
*/
private emitFormSubmitted(): void { private emitFormSubmitted(): void {
this.submittedChange.emit(true); this.submittedChange.emit(true);
} }