import { Component, EventEmitter, inject, Output, output } from '@angular/core'; import { FormControl, FormGroup, ReactiveFormsModule, Validators, } from '@angular/forms'; import { AuthService } from '../../shared/services/auth.service'; @Component({ selector: 'app-change-password', imports: [ReactiveFormsModule], templateUrl: './change-password.component.html', }) export class ChangePasswordComponent { @Output() done = new EventEmitter(); private auth = inject(AuthService); form = new FormGroup({ password: new FormControl('', [ Validators.required, Validators.minLength(6), ]), }); submit() { if (this.form.invalid) { this.form.markAllAsTouched(); return; } this.auth .changePassword(this.form.controls.password.value!) .then((success) => { if (success) { this.done.emit(); } }); } }