<?php

namespace App\Filament\Resources\CompraResource\Pages;

use App\Filament\Resources\CompraResource;
use App\Exports\PlantillaCompraExport;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use Maatwebsite\Excel\Facades\Excel;

class ListCompras extends ListRecords
{
    protected static string $resource = CompraResource::class;

    protected function getHeaderActions(): array
    {
        return [
            Actions\Action::make('descargar_plantilla')
                ->label('Descargar Plantilla Excel')
                ->icon('heroicon-o-document-arrow-down')
                ->color('info')
                ->action(function () {
                    return Excel::download(
                        new PlantillaCompraExport(),
                        'plantilla_compras.xlsx'
                    );
                }),
            Actions\CreateAction::make(),
        ];
    }
}
