<?php

declare(strict_types=1);

use App\Core\Middleware\AuthMiddleware;
use App\Core\Middleware\CsrfMiddleware;
use App\Core\Middleware\PermissionMiddleware;
use App\Controllers\CategoryController;
use App\Controllers\ItemController;
use App\Controllers\ItemUnitController;
use App\Controllers\StockVoucherController;
use App\Controllers\UnitController;
use App\Controllers\WarehouseController;
use App\Controllers\InventoryBarcodePrintController;
use App\Modules\Inventory\Presentation\Controllers\OpeningStockController;
use App\Modules\Inventory\Presentation\Controllers\WarehouseDocsController;

$router->get('/inventory/items', static function (): void { (new ItemController())->handle('search'); }, [new AuthMiddleware()]);
$router->post('/inventory/items', static function (): void { (new ItemController())->handle('search'); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/inventory/items/create', static function (): void { (new ItemController())->handle('create'); }, [new AuthMiddleware()]);
$router->post('/inventory/items/create', static function (): void { (new ItemController())->handle('create'); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/inventory/categories', static function (): void { (new CategoryController())->handle(); }, [new AuthMiddleware()]);
$router->post('/inventory/categories', static function (): void { (new CategoryController())->handle(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/inventory/units', static function (): void { (new UnitController())->handle(); }, [new AuthMiddleware()]);
$router->post('/inventory/units', static function (): void { (new UnitController())->handle(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/inventory/warehouses', static function (): void { (new WarehouseController())->handle(); }, [new AuthMiddleware()]);
$router->post('/inventory/warehouses', static function (): void { (new WarehouseController())->handle(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/inventory/items/units', static function (): void { (new ItemUnitController())->handle(); }, [new AuthMiddleware()]);
$router->post('/inventory/items/units', static function (): void { (new ItemUnitController())->handle(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/inventory/opening-stock', static function (): void { (new OpeningStockController())->handle(); }, [new AuthMiddleware()]);
$router->post('/inventory/opening-stock', static function (): void { (new OpeningStockController())->handle(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/inventory/opening-stock/print', static function (): void { (new OpeningStockController())->print(); }, [new AuthMiddleware()]);
$router->get('/inventory/warehouse-docs', static function (): void { (new WarehouseDocsController())->index(); }, [new AuthMiddleware()]);
$router->get('/inventory/warehouse-docs/view', static function (): void { (new WarehouseDocsController())->view(); }, [new AuthMiddleware()]);
$router->get('/inventory/warehouse-docs/print', static function (): void { (new WarehouseDocsController())->print(); }, [new AuthMiddleware()]);
$router->get('/inventory/stock-voucher', static function (): void { (new StockVoucherController())->handle(); }, [new AuthMiddleware()]);
$router->get('/inventory/barcode-print', static function (): void { (new InventoryBarcodePrintController())->index(); }, [new AuthMiddleware(), new PermissionMiddleware('inventory.barcode.print')]);
$router->get('/inventory/barcode-print/print', static function (): void { (new InventoryBarcodePrintController())->print(); }, [new AuthMiddleware(), new PermissionMiddleware('inventory.barcode.print')]);
$router->post('/inventory/stock-voucher', static function (): void { (new StockVoucherController())->handle(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
