<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ApiDocumentationController extends Controller
{
    /**
     * Display API documentation
     */
    public function index()
    {
        $user = auth()->user();

        // Admins au acces automat la API docs
        if (!$user->isAdmin()) {
            // Verifică dacă utilizator has API access
            if (!$user->plan || !$user->plan->api_enabled) {
                return redirect()->route('dashboard')
                    ->with('error', 'Your current plan does not include API access.');
            }
        }

        return view('api-docs.index', [
            'plan' => $user->plan ?? null,
            'baseUrl' => url('/api/v1'),
        ]);
    }
}
