<?php

namespace App\Filament\Resources\SaleResource\Pages;

use App\Enums\SaleOrigin;
use App\Filament\Resources\SaleResource;
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;

class ViewSale extends ViewRecord
{
    protected static string $resource = SaleResource::class;

    protected function getHeaderActions(): array
    {
        $actions = [];

        // Cotización solo disponible para ventas de renovación
        if ($this->record->origin === SaleOrigin::Renovacion) {
            $actions[] = Actions\Action::make('download_quote')
                ->label('Descargar Cotización')
                ->icon('heroicon-o-arrow-down-tray')
                ->color('gray')
                ->url(fn () => route('quote.download', $this->record))
                ->openUrlInNewTab();
        }

        $actions[] = Actions\EditAction::make();

        return $actions;
    }
}
