<?php

namespace App\Filament\Resources;

use App\Filament\NavigationGroup;
use App\Filament\Resources\BrentPriceResource\Pages\ListBrentPrices;
use App\Models\BrentPrice;
use Filament\Resources\Resource;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;

class BrentPriceResource extends Resource
{
    protected static ?string $model = BrentPrice::class;

    protected static string|\UnitEnum|null $navigationGroup = NavigationGroup::Data;

    protected static ?string $navigationLabel = 'Brent Prices';

    protected static ?int $navigationSort = 2;

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('date')
                    ->date('d M Y')
                    ->sortable(),
                TextColumn::make('price_usd')
                    ->label('Price (USD/barrel)')
                    ->numeric(2)
                    ->sortable(),
            ])
            ->defaultSort('date', 'desc')
            ->recordActions([])
            ->filters([]);
    }

    public static function getPages(): array
    {
        return [
            'index' => ListBrentPrices::route('/'),
        ];
    }
}
