<?php

/**
 * SMS Configuration Module Routes
 * 
 * All routes are protected by middleware requiring Super Manager role.
 * These routes should be included in your main routes/web.php file.
 * 
 * Usage:
 * Include this file in your routes/web.php:
 *   require __DIR__ . '/sms.php';
 * 
 * Or copy the route group below into your existing routes/web.php
 */

use App\Http\Controllers\SmsConfigurationController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| SMS Configuration Routes
|--------------------------------------------------------------------------
|
| These routes handle the SMS configuration management interface.
| All routes are protected by auth and role middleware to ensure
| only Super Managers can access SMS configuration features.
|
*/

Route::middleware(['auth', 'role:Super Manager'])
    ->prefix('config/sms')
    ->name('config.sms.')
    ->group(function () {
        
        /**
         * SMS Dashboard
         * Main entry point showing configuration status and statistics
         */
        Route::get('/', [SmsConfigurationController::class, 'index'])
            ->name('index');
        
        /**
         * Create Configuration
         * Show form to create new SMS configuration
         */
        Route::get('/create', [SmsConfigurationController::class, 'create'])
            ->name('create');
        
        /**
         * Store Configuration
         * Save new SMS configuration
         */
        Route::post('/', [SmsConfigurationController::class, 'store'])
            ->name('store');
        
        /**
         * Edit Configuration
         * Show form to edit existing SMS configuration
         */
        Route::get('/edit', [SmsConfigurationController::class, 'edit'])
            ->name('edit');
        
        /**
         * Update Configuration
         * Update existing SMS configuration
         */
        Route::put('/', [SmsConfigurationController::class, 'update'])
            ->name('update');
        
        /**
         * Delete Configuration
         * Remove SMS configuration (soft delete)
         */
        Route::delete('/', [SmsConfigurationController::class, 'destroy'])
            ->name('destroy');
        
        /**
         * Test Connection
         * Send test SMS to verify configuration
         */
        Route::post('/test', [SmsConfigurationController::class, 'testConnection'])
            ->name('test');
        
        /**
         * View Logs
         * Display SMS log history
         */
        Route::get('/logs', [SmsConfigurationController::class, 'logs'])
            ->name('logs');
        
        /**
         * Get Log Details (AJAX)
         * Get detailed information about a specific SMS log
         */
        Route::get('/logs/{log}', [SmsConfigurationController::class, 'getLogDetails'])
            ->name('logs.show');
        
        /**
         * View Documentation
         * Display integration documentation for developers
         */
        Route::get('/documentation', [SmsConfigurationController::class, 'documentation'])
            ->name('documentation');

        /**
         * Get Statistics (AJAX)
         * Returns SMS statistics as JSON for dashboard widgets
         */
        Route::get('/statistics', [SmsConfigurationController::class, 'statisticsJson'])
            ->name('statistics');
    });
