<?php

namespace App\Filament\Resources\PaymentOrder\PaymentOrders\PaymentOrders;

use Filament\Schemas\Schema;
use Filament\Schemas\Components\Fieldset;
use Filament\Actions\EditAction;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use App\Filament\Resources\PaymentOrder\PaymentOrders\Pages\ListPaymentOrders;
use App\Filament\Resources\PaymentOrder\PaymentOrders\Pages\CreatePaymentOrder;
use App\Filament\Resources\PaymentOrder\PaymentOrders\Pages\EditPaymentOrder;
use App\Filament\Resources\PaymentOrder\PaymentOrderResource\Pages;
use App\Modules\PaymentOrder\Models\PaymentOrder;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;

class PaymentOrderResource extends Resource
{
    protected static ?string $model = PaymentOrder::class;

    protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-receipt-percent';

    public static function form(Schema $schema): Schema
    {
        return $schema
            ->components([
                Fieldset::make(__('Töleg'))
                    ->schema([
                        TextInput::make('number')
                            ->integer()
                            ->required(),

                        TextInput::make('money_amount')
                            ->required()
                            ->label('Pul mocberi'),

                        TextInput::make('bank_code')
                            ->required()
                            ->label('Bank topary'),

                        TextInput::make('payment_reason_number')
                            ->integer()
                            ->required()
                            ->label('Toleg maksady nomeri'),

                        Textarea::make('payment_reason_description')
                            ->label('Toleg maksady')
                            ->autosize(),
                    ]),

                Fieldset::make('Toleyji')
                    ->schema([
                        TextInput::make('t_name')
                            ->label('ady familyasy'),

                        TextInput::make('t_ssb')
                            ->label('ŞSB'),

                        TextInput::make('t_bab')
                            ->label('BAB'),

                        TextInput::make('t_bank')
                            ->label('Banky'),

                        TextInput::make('t_hb_1')
                            ->label('H/b 1'),

                        TextInput::make('t_hb_2')
                            ->label('H/b 2'),
                    ]),

                Fieldset::make('Alyjy')
                    ->schema([
                        TextInput::make('a_name')
                            ->label('ady familyasy'),

                        TextInput::make('a_ssb')
                            ->label('ŞSB'),

                        TextInput::make('a_bab')
                            ->label('BAB'),

                        TextInput::make('a_bank')
                            ->label('Banky'),

                        TextInput::make('a_hb_1')
                            ->label('H/b 1'),

                        TextInput::make('a_hb_2')
                            ->label('H/b 2'),
                    ]),
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('number'),
            ])
            ->filters([
                //
            ])
            ->recordActions([
                EditAction::make(),
            ])
            ->toolbarActions([
                BulkActionGroup::make([
                    DeleteBulkAction::make(),
                ]),
            ]);
    }

    public static function getRelations(): array
    {
        return [
            //
        ];
    }

    public static function getPages(): array
    {
        return [
            'index' => ListPaymentOrders::route('/'),
            'create' => CreatePaymentOrder::route('/create'),
            'edit' => EditPaymentOrder::route('/{record}/edit'),
        ];
    }
}
