<?php

declare(strict_types=1);

namespace App\Modules\Admin\Presentation\Controllers;

use App\Core\DB;
use App\Core\Response;
use App\Modules\Admin\Application\Services\DashboardMetricsService;

final class DashboardController
{
    public function __construct(private ?DashboardMetricsService $metrics = null)
    {
        $this->metrics ??= new DashboardMetricsService();
    }

    public function index(): void
    {
        $data = $this->metrics->gather(DB::pdo());

        Response::view('pages/dashboard', $data + [
            'page_title' => 'لوحة التحكم',
            'breadcrumbs' => [['label' => 'لوحة التحكم']],
        ]);
    }
}
