<?php

namespace App\Domains\Admin\Controllers;

use App\Scopes\CommonController;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class TenantListApiController extends CommonController
{
    public function __invoke(Request $request): JsonResponse
    {
        $tenants = $this->adminTenants->getActiveTenants();

        $mapped = $tenants->map(function ($tenant) {
            return [
                'name' => $tenant->name,
                'slug' => $tenant->slug,
                'url' => $tenant->url,
                'is_active_local_group' => $tenant->is_active_local_group,
            ];
        });

        return response()->json(['tenants' => $mapped]);
    }
}
