import { Component, Inject, Input, OnDestroy, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { DriveFile } from 'src/app/components/resource-page/drive-window/drive-layout/drive-file';
import { AccountAvatarRecord } from '../../server-services/query-records/account-records';
import { RouterHandler } from '../../services/router-handler.service';
import { NanoDialogBaseComponent } from '../nano-base-dialog';

export interface DialogData {
  file: DriveFile;
}

@Component({
  selector: 'app-file-properties-dialog',
  templateUrl: './file-properties-dialog.component.html',
  styleUrls: ['./file-properties-dialog.component.scss'],
})
export class FilePropertiesDialogComponent
  extends NanoDialogBaseComponent<FilePropertiesDialogComponent>
  implements OnInit, OnDestroy
{
  // public lastModified: Date = null;

  constructor(
    public dialogRef: MatDialogRef<FilePropertiesDialogComponent>,
    @Inject(MAT_DIALOG_DATA) public data: DialogData,

    private routerHandler: RouterHandler
  ) {
    super(dialogRef);
  }

  onCancel = () => {
    this.dialogRef.close();
  };

  ngOnDestroy(): void {
    this.routerHandler.unsubscribeAll(this.onCancel);
  }

  ngOnInit(): void {
    // this is the same as the parsed file.createdAt
    // this.lastModified = new Date(this.data.file?.mtime * 1000);
  }
}
