<?php

declare(strict_types=1);

use App\Core\Middleware\AuthMiddleware;
use App\Core\Middleware\CsrfMiddleware;
use App\Core\Middleware\PermissionMiddleware;
use App\Controllers\AuditLogController;
use App\Controllers\BackupController;
use App\Controllers\BulkImportController;
use App\Controllers\CommunicationSettingsController;
use App\Controllers\CompanyProfileController;
use App\Controllers\LabelDefinitionController;
use App\Controllers\PrintSettingsController;
use App\Controllers\RoleController;
use App\Controllers\UserController;
use App\Modules\Admin\Presentation\Controllers\WipeDataController;

$router->get('/admin/users', static function (): void { (new UserController())->handle(); }, [new AuthMiddleware(), new PermissionMiddleware('users.view')]);
$router->post('/admin/users', static function (): void { (new UserController())->handle(); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('users.create')]);
$router->get('/admin/roles', static function (): void { (new RoleController())->handle(); }, [new AuthMiddleware(), new PermissionMiddleware('roles.view')]);
$router->post('/admin/roles', static function (): void { (new RoleController())->handle(); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('roles.edit')]);

$router->get('/admin/audit-logs', static function (): void { (new AuditLogController())->handle(); }, [new AuthMiddleware(), new PermissionMiddleware('admin.logs.view')]);

$router->get('/admin/import-data', static function (): void { (new BulkImportController())->index(); }, [new AuthMiddleware(), new PermissionMiddleware('admin.import_data')]);
$router->get('/admin/import-data/template', static function (): void { (new BulkImportController())->template(); }, [new AuthMiddleware(), new PermissionMiddleware('admin.import_data')]);
$router->post('/admin/import-data/upload', static function (): void { (new BulkImportController())->upload(); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.import_data')]);
$router->post('/admin/import-data/execute', static function (): void { (new BulkImportController())->execute(); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.import_data')]);
$router->post('/admin/import-data/clear-logs', static function (): void { (new BulkImportController())->clearLogs(); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.import_data')]);
$router->get('/admin/backups', static function (): void { (new BackupController())->handleIndex(); }, [new AuthMiddleware(), new PermissionMiddleware('admin.backup.create')]);
$router->post('/admin/backups', static function (): void { (new BackupController())->handleIndex(); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.backup.create')]);
$router->get('/admin/backups/restore', static function (): void { (new BackupController())->handleRestore(); }, [new AuthMiddleware(), new PermissionMiddleware('admin.backup.restore')]);
$router->post('/admin/backups/restore', static function (): void { (new BackupController())->handleRestore(); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.backup.restore')]);
$router->get('/admin/wipe-data', static function (): void { (new WipeDataController())->handle(); }, [new AuthMiddleware(), new PermissionMiddleware('admin.data.wipe')]);
$router->post('/admin/wipe-data', static function (): void { (new WipeDataController())->handle(); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.data.wipe')]);
$router->get('/admin/company-profile', static function (): void { (new CompanyProfileController())->handle(); }, [new AuthMiddleware(), new PermissionMiddleware('admin.company.edit')]);
$router->post('/admin/company-profile', static function (): void { (new CompanyProfileController())->handle(); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.company.edit')]);
$router->get('/admin/communication-settings', static function (): void { (new CommunicationSettingsController())->handle(); }, [new AuthMiddleware(), new PermissionMiddleware('admin.comms.edit')]);
$router->post('/admin/communication-settings', static function (): void { (new CommunicationSettingsController())->handle(); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.comms.edit')]);
$router->get('/admin/label-definitions', static function (): void { (new LabelDefinitionController())->handle(); }, [new AuthMiddleware(), new PermissionMiddleware('admin.label_definitions.edit')]);
$router->post('/admin/label-definitions', static function (): void { (new LabelDefinitionController())->handle(); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.label_definitions.edit')]);
$router->get('/admin/print-settings', static function (): void { (new PrintSettingsController())->index(); }, [new AuthMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->get('/admin/print-settings/general', static function (): void { (new PrintSettingsController())->general(); }, [new AuthMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->post('/admin/print-settings/general', static function (): void { (new PrintSettingsController())->general(); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->get('/admin/print-settings/quotation', static function (): void { (new PrintSettingsController())->document('quotation'); }, [new AuthMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->post('/admin/print-settings/quotation', static function (): void { (new PrintSettingsController())->document('quotation'); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->get('/admin/print-settings/sales-invoice', static function (): void { (new PrintSettingsController())->document('sales_invoice'); }, [new AuthMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->post('/admin/print-settings/sales-invoice', static function (): void { (new PrintSettingsController())->document('sales_invoice'); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->get('/admin/print-settings/purchase-invoice', static function (): void { (new PrintSettingsController())->document('purchase_invoice'); }, [new AuthMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->post('/admin/print-settings/purchase-invoice', static function (): void { (new PrintSettingsController())->document('purchase_invoice'); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->get('/admin/print-settings/sales-return', static function (): void { (new PrintSettingsController())->document('sales_return'); }, [new AuthMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->post('/admin/print-settings/sales-return', static function (): void { (new PrintSettingsController())->document('sales_return'); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->get('/admin/print-settings/purchase-return', static function (): void { (new PrintSettingsController())->document('purchase_return'); }, [new AuthMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->post('/admin/print-settings/purchase-return', static function (): void { (new PrintSettingsController())->document('purchase_return'); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->get('/admin/print-settings/customer-receipt', static function (): void { (new PrintSettingsController())->document('customer_receipt'); }, [new AuthMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->post('/admin/print-settings/customer-receipt', static function (): void { (new PrintSettingsController())->document('customer_receipt'); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->get('/admin/print-settings/cash-payment', static function (): void { (new PrintSettingsController())->document('cash_payment'); }, [new AuthMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->post('/admin/print-settings/cash-payment', static function (): void { (new PrintSettingsController())->document('cash_payment'); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->get('/admin/print-settings/supplier-payment', static function (): void { (new PrintSettingsController())->document('supplier_payment'); }, [new AuthMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->post('/admin/print-settings/supplier-payment', static function (): void { (new PrintSettingsController())->document('supplier_payment'); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->get('/admin/print-settings/party-statement', static function (): void { (new PrintSettingsController())->document('party_statement'); }, [new AuthMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
$router->post('/admin/print-settings/party-statement', static function (): void { (new PrintSettingsController())->document('party_statement'); }, [new AuthMiddleware(), new CsrfMiddleware(), new PermissionMiddleware('admin.print_settings.edit')]);
