<?php

namespace Controllers;

use Libs\ResponseLib;
use Psr\Http\Message\ServerRequestInterface;

class SuperAdminGetController
{
    public function __invoke(ServerRequestInterface $request)
    {
        $companyId = (int)($request->getAttribute('api_company_id') ?? 0);
        if ($companyId <= 0) {
            return ResponseLib::sendFail('Authenticated company not found', [], 'E_VALIDATE')->withStatus(401);
        }

        $isSuperAdmin = ($companyId === 1 || $companyId === 2);

        return ResponseLib::sendOk([
            'superadmin' => $isSuperAdmin,
            'company_id' => $companyId,
        ], 'S_SUPERADMIN');
    }
}
