<?php

namespace BookStack\View\ViewBlocks;

use BookStack\Activity\ActivityQueries;
use BookStack\Entities\Models\Bookshelf;
use BookStack\View\SimpleViewBlock;

class ShelvesShowActivity extends SimpleViewBlock
{
    protected static string $id = 'builtin_shelves-show-activity';
    protected static string $view = 'shelves.parts.show-sidebar-section-activity';
    protected static string $labelTranslationKey = 'entities.recent_activity';

    public function __construct(
        protected ActivityQueries $activityQueries,
    ) {
    }

    public function getViewData(array $viewData): array
    {
        /** @var Bookshelf $shelf */
        $shelf = $viewData['shelf'];

        return [
            'activity' => $this->activityQueries->entityActivity($shelf, 20, 1),
        ];
    }
}
