<?php

declare(strict_types=1);

namespace App\Filament\Resources\DberpSalesOrders\Concerns;

use App\Business\Sales\SalesOrderOverviewService;
use App\Models\DberpSalesOrder;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\View as SchemaView;

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