<?php

namespace App\Filament\Resources\CustomOrderResource\Pages;

use App\Filament\Resources\CustomOrderResource;
use App\Filament\Resources\SalesOrderResource;
use Filament\Actions\Action;
use Filament\Resources\Pages\ListRecords;
use Filament\Support\Icons\Heroicon;

class ListCustomOrders extends ListRecords
{
    protected static string $resource = CustomOrderResource::class;

    /**
     * Custom items are only ever created on a sales order, so the header
     * points at that flow rather than offering a create button that would
     * have nowhere to put the customer or the deadline.
     */
    protected function getHeaderActions(): array
    {
        return [
            Action::make('newSalesOrder')
                ->label('New sales order')
                ->icon(Heroicon::OutlinedPlus)
                ->url(fn (): string => SalesOrderResource::getUrl('create'))
                ->visible(fn (): bool => SalesOrderResource::canCreate()),
        ];
    }
}
