<?php
/**
 * Budget Module — Route Definitions
 *
 * Registers Couple Portal budget planner endpoints.
 * Loaded within routes/couple.php.
 *
 * Available variable: $router (App\Core\Router instance)
 *
 * @package Inveetaire
 * @ref     RC-017
 */

$router->group('/budget', function ($router) {
    // Dashboard summary
    $router->get('', 'App\\Modules\\Budget\\BudgetController@index');
    
    // Settings (Total Budget updating)
    $router->get('/settings', 'App\\Modules\\Budget\\BudgetController@settings');
    $router->post('/settings', 'App\\Modules\\Budget\\BudgetController@updateSettings', [
        'App\\Middleware\\CsrfMiddleware'
    ]);

    // Category Detail Redirect
    $router->get('/category/{category_id}', 'App\\Modules\\Budget\\BudgetController@categoryDetail');

    // Categories Management
    $router->get('/categories', 'App\\Modules\\Budget\\BudgetController@categories');
    $router->post('/categories/create', 'App\\Modules\\Budget\\BudgetController@createCategory', [
        'App\\Middleware\\CsrfMiddleware'
    ]);
    $router->post('/categories/rename/{id}', 'App\\Modules\\Budget\\BudgetController@renameCategory', [
        'App\\Middleware\\CsrfMiddleware'
    ]);
    $router->post('/categories/delete/{id}', 'App\\Modules\\Budget\\BudgetController@deleteCategory', [
        'App\\Middleware\\CsrfMiddleware'
    ]);
    $router->post('/categories/reorder', 'App\\Modules\\Budget\\BudgetController@reorderCategories', [
        'App\\Middleware\\CsrfMiddleware'
    ]);

    // Expenses CRUD
    $router->get('/expenses', 'App\\Modules\\Budget\\BudgetController@expenses');
    $router->get('/expenses/create', 'App\\Modules\\Budget\\BudgetController@createExpense');
    $router->post('/expenses/create', 'App\\Modules\\Budget\\BudgetController@storeExpense', [
        'App\\Middleware\\CsrfMiddleware'
    ]);
    $router->get('/expenses/edit/{id}', 'App\\Modules\\Budget\\BudgetController@editExpense');
    $router->post('/expenses/edit/{id}', 'App\\Modules\\Budget\\BudgetController@updateExpense', [
        'App\\Middleware\\CsrfMiddleware'
    ]);
    $router->post('/expenses/delete/{id}', 'App\\Modules\\Budget\\BudgetController@deleteExpense', [
        'App\\Middleware\\CsrfMiddleware'
    ]);
    $router->get('/expenses/{id}', 'App\\Modules\\Budget\\BudgetController@showExpense');

    // Payments Tracking
    $router->post('/expenses/{id}/payments', 'App\\Modules\\Budget\\BudgetController@storePayment', [
        'App\\Middleware\\CsrfMiddleware'
    ]);
    $router->post('/payments/delete/{id}', 'App\\Modules\\Budget\\BudgetController@deletePayment', [
        'App\\Middleware\\CsrfMiddleware'
    ]);
    $router->get('/payments', 'App\\Modules\\Budget\\BudgetController@payments');
});
