<?php

declare(strict_types=1);

namespace App\Filament\Resources\DberpCustomers\Concerns;

use App\Business\MasterData\CustomerBusinessOverviewService;
use App\Models\DberpCustomer;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\View as SchemaView;

trait ProvidesDberpCustomerBusinessOverviewFormSections
{
    /**
     * @return list<Section>
     */
    protected static function customerBusinessOverviewFormSections(): array
    {
        return [
            Section::make(__('dberp.sections.customer_business_overview'))
                ->description(__('dberp.hints.customer_business_overview'))
                ->visible(fn (?DberpCustomer $record): bool => $record instanceof DberpCustomer)
                ->schema([
                    SchemaView::make('components.dberp.customer.business-overview')
                        ->viewData(fn (?DberpCustomer $record): array => app(CustomerBusinessOverviewService::class)->viewDataForCustomer($record))
                        ->columnSpanFull(),
                ])
                ->columns(1)
                ->columnSpanFull(),
        ];
    }
}
