import { Component , OnInit , Inject } from '@angular/core' ; import { FormBuilder , Validators , FormGroup } from '@angular/forms' ; import { UserService } from '@app/core/user/user.service' ; import { ErrorHandlerService } from '@app/core/error-handler.service' ; import { MAT_DIALOG_DATA , MatDialogRef } from '@angular/material' ; @ Component ( { selector : 'app-requests' , templateUrl : './requests.component.html' , styleUrls : [ './requests.component.scss' ] } ) export class RequestsComponent implements OnInit { reqForm : FormGroup ; constructor ( private fb , private userService , private errorHandler , public dialogRef , @ Inject ( MAT_DIALOG_DATA ) public data ) { } ngOnInit ( ) { this . reqForm = this . fb . group ( { is_bug : [ false , Validators . required ] , text : [ '' , Validators . required ] , name : [ 'Anonymous' , Validators . required ] } ) ; } submitRequest ( ) { this . userService . sendReq ( this . reqForm . value ) . subscribe ( ( data ) => { this . dialogRef . close ( ) ; this . errorHandler . subj_notification . next ( 'Request Sent!' ) ; } , ( error ) => { this . errorHandler . subj_notification . next ( error ) ; } ) ; } }