<?php

namespace App\Filament\Admin\Resources\InvoiceResource\Pages;

use App\Enums\IconEnum;
use App\Enums\InvoiceStatus;
use App\Filament\Admin\Resources\InvoiceResource;
use Filament\Actions;
use Filament\Resources\Components\Tab;
use Filament\Resources\Pages\ListRecords;

class ListInvoices extends ListRecords
{
    protected static string $resource = InvoiceResource::class;

    public function getTabs(): array
    {
        return [
            'all' => Tab::make('All')
                ->icon(IconEnum::TAB_ALL->value),

            'unpaid' => Tab::make('Unpaid')
                ->query(fn ($query) => $query->where('status', InvoiceStatus::UNPAID))
                ->icon(InvoiceStatus::UNPAID->getIcon()),

            'paid' => Tab::make('Paid')
                ->query(fn ($query) => $query->where('status', InvoiceStatus::PAID))
                ->icon(InvoiceStatus::PAID->getIcon()),

            'void' => Tab::make('Void')
                ->query(fn ($query) => $query->where('status', InvoiceStatus::VOID))
                ->icon(InvoiceStatus::VOID->getIcon()),

        ];
    }

    protected function getHeaderActions(): array
    {
        return [
            Actions\CreateAction::make()
                ->icon(IconEnum::NEW->value),
        ];
    }
}
