<?php

namespace App\Filament\Resources\RestoreRunResource\Pages;

use App\Filament\Resources\RestoreRunResource;
use Filament\Resources\Pages\ViewRecord;
use Illuminate\Database\Eloquent\Model;

class ViewRestoreRun extends ViewRecord
{
    protected static string $resource = RestoreRunResource::class;

    protected function resolveRecord(int|string $key): Model
    {
        return RestoreRunResource::resolveScopedRecordOrFail($key);
    }

    public function getSubheading(): ?string
    {
        return match (request()->string('recovery_posture_reason')->toString()) {
            'failed' => 'The dashboard opened this restore run because the latest executed restore failed.',
            'partial' => 'The dashboard opened this restore run because the latest executed restore completed partially.',
            'completed_with_follow_up' => 'The dashboard opened this restore run because skipped or non-applied work still needs follow-up.',
            'no_recent_issues_visible' => 'The dashboard opened this restore run because no recent restore issues are visible, but tenant-wide recovery is still not proven.',
            default => null,
        };
    }
}
