<?php

namespace App\Filament\Resources\PricelistFiles\Schemas;

use App\Models\Supplier;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Schemas\Components\Grid;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;

class PricelistFileForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                Section::make('Árlista fájl adatai')
                    ->schema([
                        Grid::make(2)
                            ->schema([
                                Select::make('supplier_id')
                                    ->label('Beszállító')
                                    ->options(Supplier::query()->pluck('name', 'id'))
                                    ->required()
                                    ->searchable(),
                                DatePicker::make('available_date')
                                    ->label('Életbelépés dátuma')
                                    ->required()
                                    ->native(false)
                                    ->displayFormat('Y.m.d'),
                            ]),
                        Textarea::make('note')
                            ->label('Megjegyzés')
                            ->rows(3),
                        FileUpload::make('filename')
                            ->label('Fájl kiválasztása')
                            ->required()
                            ->acceptedFileTypes(['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv'])
                            ->disk('public')
                            ->directory('pricelist-uploads')
                            ->preserveFilenames(),
                    ])
            ]);
    }
}
