<?php

namespace App\Modules\Dashboard\Controllers;

use App\Core\BaseApiController;
use App\Modules\Dashboard\Services\DashboardService;
use CodeIgniter\HTTP\ResponseInterface;

/**
 * Dashboard Controller
 *
 * API endpoints for monitoring attendance system.
 */
class DashboardController extends BaseApiController
{
    protected DashboardService $dashboardService;

    public function __construct()
    {
        $this->dashboardService = new DashboardService();
    }

    /**
     * GET /api/dashboard/summary
     *
     * @return ResponseInterface
     */
    public function summary(): ResponseInterface
    {
        $data = $this->dashboardService->getSummary();
        return $this->successResponse($data, 'Dashboard summary');
    }

    /**
     * GET /api/dashboard/realtime
     *
     * @return ResponseInterface
     */
    public function realtime(): ResponseInterface
    {
        $data = $this->dashboardService->getRealtimeCheckins(20);
        return $this->successResponse($data, 'Last 20 check-ins');
    }

    /**
     * GET /api/dashboard/devices
     *
     * @return ResponseInterface
     */
    public function devices(): ResponseInterface
    {
        $data = $this->dashboardService->getDevices();
        return $this->successResponse($data, 'Device monitoring');
    }
}
