<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Resources\RoleResource;
use App\Models\Role;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

/**
 * @group Roles
 *
 * Endpoints for managing roles.
 */
class RolesController extends Controller
{
    /**
     * List all roles
     *
     * Get a list of all available roles for team members.
     *
     * @authenticated
     *
     * @response 200 {
     *   "data": [
     *     {
     *       "id": 1,
     *       "name": "Frontend Dev",
     *       "description": "Frontend Developer - specializes in UI/UX and client-side development"
     *     }
     *   ]
     * }
     */
    public function index(Request $request): JsonResponse
    {
        $roles = Role::orderBy('name')->get(['id', 'name', 'description']);

        return $this->wrapResource(RoleResource::collection($roles));
    }
}
