import { Component, inject } from '@angular/core';
import { DatePipe, DecimalPipe } from '@angular/common';
import { MatButtonModule } from '@angular/material/button';
import { MatDialogRef, MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
import { MatDividerModule } from '@angular/material/divider';
import { MatIconModule } from '@angular/material/icon';

import { Jump } from '@models';

@Component({
    selector: 'app-jump-view-dialog',
    templateUrl: 'jump-view.dialog.html',
    imports: [DatePipe, DecimalPipe, MatButtonModule, MatDialogModule, MatDividerModule, MatIconModule],
})
export class JumpViewDialogComponent {
    dialogRef = inject<MatDialogRef<JumpViewDialogComponent>>(MatDialogRef);
    jump = inject<Jump>(MAT_DIALOG_DATA);

    closeDialog(): void {
        // close the dialog without result
        this.dialogRef.close();
    }

    formatDuration(duration: number): string {
        const start = new Date(0);
        start.setSeconds(duration);
        return start.toISOString().substring(14, 19);
    }
}
