<?php

declare(strict_types=1);

namespace App\Filament\Resources\DberpPurchaseOrders\Concerns;

use App\Business\Purchase\PurchaseOrderOverviewService;
use App\Models\DberpPurchaseOrder;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\View as SchemaView;

trait ProvidesDberpPurchaseOrderOverviewFormSections
{
    /**
     * @return list<Section>
     */
    protected static function purchaseOrderOverviewFormSections(): array
    {
        return [
            Section::make(__('dberp.sections.purchase_order_business_overview'))
                ->description(__('dberp.hints.purchase_order_business_overview'))
                ->visible(fn (?DberpPurchaseOrder $record): bool => $record instanceof DberpPurchaseOrder)
                ->schema([
                    SchemaView::make('components.dberp.purchase-order.business-overview')
                        ->viewData(fn (?DberpPurchaseOrder $record): array => app(PurchaseOrderOverviewService::class)->viewDataForOrder($record))
                        ->columnSpanFull(),
                ])
                ->columns(1)
                ->columnSpanFull(),
        ];
    }
}
