Skip to content
Snippets Groups Projects
create-team-form.component.ts 921 B
Newer Older
import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {CreateTeam} from 'src/app/models/create-team';
import {TeamService} from 'src/app/services/team.service';
Tomas Madeja's avatar
Tomas Madeja committed

@Component({
  selector: 'app-create-team-form',
  templateUrl: './create-team-form.component.html',
  styleUrls: ['./create-team-form.component.css']
})
export class CreateTeamFormComponent implements OnInit {
Tomas Madeja's avatar
Tomas Madeja committed
  @Output() formSubmitEvent: EventEmitter<any> = new EventEmitter();

  model: CreateTeam = {name: ""};

  submitted = false;

  confirmed = false;

  constructor(
    private teamService: TeamService
Tomas Madeja's avatar
Tomas Madeja committed

  ngOnInit(): void {
  }

  onSubmit(): void {
Tomas Madeja's avatar
Tomas Madeja committed
    this.submitted = true;
    this.confirmSubmission();
  resetForm(): void {
Tomas Madeja's avatar
Tomas Madeja committed
    this.model = {name: ""};
  }

  confirmSubmission(): void {
Tomas Madeja's avatar
Tomas Madeja committed
    this.confirmed = true;
    this.teamService.createTeam(this.model);
    this.formSubmitEvent.emit(null);
  }

}