import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core'; import {FormGroup, FormBuilder, Validators, AbstractControl} from '@angular/forms'; import { Member } from '@overflow/commons-typescript/model/member'; @Component({ selector: 'of-member-signin', templateUrl: './member-signin.component.html', }) export class MemberSigninComponent implements OnInit { @Input() member: Member; @Input() signinError: string; @Output() resetPassword = new EventEmitter(); @Output() signup = new EventEmitter(); @Output() signin = new EventEmitter<{email: string, password: string}>(); errorMessage: string | null; email: AbstractControl; password: AbstractControl; signinForm: FormGroup; constructor( private formBuilder: FormBuilder, ) { } ngOnInit() { this.initForm(); } initForm() { this.signinForm = this.formBuilder.group({ 'email': [ '', [ Validators.required, Validators.email ] ], 'password': [ '', [ Validators.required ] ], }); this.email = this.signinForm.controls['email']; this.password = this.signinForm.controls['password']; } signinFormSubmit() { const formValue = Object.assign({}, this.signinForm.value); this.signin.emit(formValue); } onResetPassword() { this.resetPassword.emit(); } onSignup() { this.signup.emit(); } }