import {Component, EventEmitter, OnInit, Output} from '@angular/core'; import {FormControl, FormGroup, Validators} from "@angular/forms"; import {TaskService} from "../../../Services/task.service"; @Component({ selector: 'app-rightpanel', templateUrl: './rightpanel.component.html', styleUrls: ['./rightpanel.component.scss'] }) export class RightpanelComponent implements OnInit{ manageTaskGroup!: FormGroup; errorWarning: string = ""; @Output() loading: EventEmitter = new EventEmitter(); constructor(private taskService: TaskService) { } ngOnInit(): void { this.manageTaskGroup = new FormGroup({ title: new FormControl('', Validators.required), type: new FormControl('', Validators.required), description: new FormControl('', Validators.required), date: new FormControl('', Validators.required) }) } onSubmit(): void{ if(this.manageTaskGroup.status === "VALID"){ this.errorWarning = "" this.loading.emit(true) this.taskService.generateTask(this.manageTaskGroup.value) this.manageTaskGroup.reset() }else{ this.errorWarning = "Nav korekti aizpildīti ievadlauki!" } } }