<?php

declare(strict_types=1);

namespace App\Filament\Resources\DberpSuppliers\Concerns;

use App\Business\MasterData\SupplierBusinessOverviewService;
use App\Models\DberpSupplier;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\View as SchemaView;

trait ProvidesDberpSupplierBusinessOverviewFormSections
{
    /**
     * @return list<Section>
     */
    protected static function supplierBusinessOverviewFormSections(): array
    {
        return [
            Section::make(__('dberp.sections.supplier_business_overview'))
                ->description(__('dberp.hints.supplier_business_overview'))
                ->visible(fn (?DberpSupplier $record): bool => $record instanceof DberpSupplier)
                ->schema([
                    SchemaView::make('components.dberp.supplier.business-overview')
                        ->viewData(fn (?DberpSupplier $record): array => app(SupplierBusinessOverviewService::class)->viewDataForSupplier($record))
                        ->columnSpanFull(),
                ])
                ->columns(1)
                ->columnSpanFull(),
        ];
    }
}
