<?php

namespace App\Filament\Admin\Widgets;

use App\Enums\OrderStatus;
use App\Models\Order;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget as BaseWidget;

class RushOrdersTable extends BaseWidget
{
    public function table(Table $table): Table
    {
        return $table
            ->query(
                Order::query()
                    ->where('status', '!=', OrderStatus::SHIPPED)
                    ->where('status', '!=', OrderStatus::INVOICED)
                    ->where('rush', true)
                    ->orderByDesc('due_date')
            )
            ->columns([
                TextColumn::make('customer.company_name'),
                TextColumn::make('customer_po')
                    ->color('code')
                    ->weight('bold'),
                TextColumn::make('status')
                    ->badge(),
            ])
            ->defaultPaginationPageOption(5);
    }
}
