<?php

declare(strict_types=1);

namespace App\Filament\Resources\DberpProducts\Concerns;

use App\Business\MasterData\ProductBusinessOverviewService;
use App\Models\DberpProduct;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\View as SchemaView;

trait ProvidesDberpProductBusinessOverviewSections
{
    /**
     * @return list<Section>
     */
    protected static function productBusinessOverviewSections(): array
    {
        return [
            Section::make(__('dberp.sections.product_inventory_business_overview'))
                ->description(__('dberp.hints.product_inventory_business_overview'))
                ->visible(fn (?DberpProduct $record): bool => $record instanceof DberpProduct)
                ->schema([
                    SchemaView::make('components.dberp.product.business-overview')
                        ->viewData(fn (?DberpProduct $record): array => app(ProductBusinessOverviewService::class)->viewDataForProduct($record))
                        ->columnSpanFull(),
                ])
                ->columns(1)
                ->columnSpanFull(),
        ];
    }
}
