import { Component, Inject, OnInit } from '@angular/core';
import { FormControl, Validators } from '@angular/forms';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { Subject } from 'rxjs';
import { RoomService } from '../../server-services/room.service';
import { NanoDialogBase } from '../nano-base-dialog';

export interface DialogData {
  name: string;
}

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

  roomNameControl = new FormControl('', [Validators.required, Validators.maxLength(35)]);

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

  ngOnInit(): void {
  }

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