import { Component, Inject, OnInit } from '@angular/core';
import { FormControl, Validators } from '@angular/forms';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { NanoDialogBase } from '../nano-base-dialog';
import { DialogData } from '../new-group-dialog/new-group-dialog.component';

@Component({
  selector: 'app-rename-group-dialog',
  templateUrl: './rename-group-dialog.component.html',
  styleUrls: ['./rename-group-dialog.component.scss']
})
export class RenameGroupDialogComponent extends NanoDialogBase<RenameGroupDialogComponent> implements OnInit {

  groupNameControl = new FormControl('', [Validators.required]);

  constructor(
    public dialogRef: MatDialogRef<RenameGroupDialogComponent>,
    @Inject(MAT_DIALOG_DATA) public data: DialogData) {
      super(dialogRef);
      this.groupNameControl.setValue(data.name);
    }

  onNoClick(): void {
    this.dialogRef.close();
  }

  ngOnInit(): void {
  }

  onSubmit(){
    this.dialogRef.close(this.groupNameControl.value);
  }

}
