import { Component, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { NanoDialogBaseComponent } from '../nano-base-dialog';

export interface DialogData {
  name: string;
}

@Component({
  selector: 'app-new-folder-dialog',
  templateUrl: './new-folder-dialog.component.html',
  styleUrls: ['./new-folder-dialog.component.scss'],
})
export class NewFolderDialogComponent extends NanoDialogBaseComponent<NewFolderDialogComponent> {
  constructor(
    public dialogRef: MatDialogRef<NewFolderDialogComponent>,
    @Inject(MAT_DIALOG_DATA) public data: DialogData
  ) {
    super(dialogRef);
  }

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

  onSubmit() {
    if (this.data.name.length > 0) {
      this.dialogRef.close(this.data.name.trim());
    }
  }
}
