<?php
use App\Http\Controllers\Superadmin\ContractTemplateController;
use App\Http\Controllers\Superadmin\DashboardController;
use App\Http\Controllers\Superadmin\SectionRuleController;
use App\Http\Controllers\Superadmin\TemplateVariableController;
use App\Http\Controllers\Superadmin\UserController;
use Illuminate\Support\Facades\Route;


Route::prefix('superadmin')
    ->name('superadmin.')
    ->group(function () {
        // Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
    
        Route::prefix('template-variables')->name('template-variables.')->middleware(['auth', 'role:super_admin'])->group(function () {
            Route::get('/', [TemplateVariableController::class, 'index'])->name('index');
            Route::get('/create', [TemplateVariableController::class, 'create'])->name('create');
            Route::get('/{id}', [TemplateVariableController::class, 'show'])->name('show');
            Route::get('/{id}/edit', [TemplateVariableController::class, 'edit'])->name('edit');
            
            Route::post('/', [TemplateVariableController::class, 'store'])->name('store');
            Route::put('/{id}', [TemplateVariableController::class, 'update'])->name('update');
            Route::delete('/{id}', [TemplateVariableController::class, 'destroy'])->name('destroy');
        });

        Route::prefix('contract-template')->name('contract-template.')->middleware(['auth', 'role:super_admin|editor'])->group(function () {
            Route::get('/', [ContractTemplateController::class, 'index'])->name('index');
            Route::get('/create', [ContractTemplateController::class, 'create'])->name('create');
            Route::get('/{id}', [ContractTemplateController::class, 'show'])->name('show');
            Route::get('/{id}/edit', [ContractTemplateController::class, 'edit'])->name('edit');
            
            Route::post('/', [ContractTemplateController::class, 'store'])->name('store');
            Route::put('/{id}', [ContractTemplateController::class, 'update'])->name('update');
            Route::delete('/{id}', [ContractTemplateController::class, 'destroy'])->name('destroy');
        });

        Route::prefix('users')->name('users.')->middleware(['auth', 'role:super_admin|editor'])->group(function () {
            Route::get('/', [UserController::class, 'index'])->name('index');
            Route::get('/create', [UserController::class, 'create'])->name('create');
            Route::get('/{id}', [UserController::class, 'show'])->name('show');
            Route::get('/{id}/edit', [UserController::class, 'edit'])->name('edit');

            Route::post('/', [UserController::class, 'store'])->name('store');
            Route::put('/{id}', [UserController::class, 'update'])->name('update');
            Route::delete('/{id}', [UserController::class, 'destroy'])->name('destroy');
        });

        Route::prefix('section-rules')->name('section-rules.')->middleware(['auth', 'role:super_admin'])->group(function () {
            Route::get('/', [SectionRuleController::class, 'index'])->name('index');
            Route::get('/create', [SectionRuleController::class, 'create'])->name('create');
            Route::get('/{id}', [SectionRuleController::class, 'show'])->name('show');
            Route::get('/{id}/edit', [SectionRuleController::class, 'edit'])->name('edit');

            Route::post('/', [SectionRuleController::class, 'store'])->name('store');
            Route::put('/{id}', [SectionRuleController::class, 'update'])->name('update');
            Route::delete('/{id}', [SectionRuleController::class, 'destroy'])->name('destroy');
        });
    });