<?php

declare(strict_types=1);

use App\Core\Middleware\AuthMiddleware;
use App\Core\Middleware\CsrfMiddleware;
use App\Controllers\QuotationController;
use App\Controllers\SalesInvoiceController;
use App\Controllers\SalesReturnController;
use App\Modules\Sales\Presentation\Controllers\PosController;
use App\Modules\Sales\Presentation\Controllers\SalesDashboardController;
use App\Modules\Sales\Presentation\Controllers\SalesReceiptsController;
use App\Modules\Sales\Presentation\Controllers\SalesViewController;

$router->get('/sales', static function (): void { (new SalesDashboardController())->index(); }, [new AuthMiddleware()]);
$router->get('/sales/view', static function (): void { (new SalesViewController())->show(); }, [new AuthMiddleware()]);

$router->get('/sales/invoices', static function (): void { (new SalesInvoiceController())->index(); }, [new AuthMiddleware()]);
$router->get('/sales/invoices/form', static function (): void { (new SalesInvoiceController())->form(); }, [new AuthMiddleware()]);
$router->post('/sales/invoices/form', static function (): void { (new SalesInvoiceController())->form(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/sales/invoices/view', static function (): void { (new SalesInvoiceController())->view(); }, [new AuthMiddleware()]);
$router->post('/sales/invoices/delete-draft', static function (): void { (new SalesInvoiceController())->deleteDraft(); }, [new AuthMiddleware(), new CsrfMiddleware()]);

$router->get('/sales/returns', static function (): void { (new SalesReturnController())->index(); }, [new AuthMiddleware()]);
$router->get('/sales/returns/form', static function (): void { (new SalesReturnController())->form(); }, [new AuthMiddleware()]);
$router->post('/sales/returns/form', static function (): void { (new SalesReturnController())->form(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/sales/returns/view', static function (): void { (new SalesReturnController())->view(); }, [new AuthMiddleware()]);
$router->post('/sales/returns/view', static function (): void { (new SalesReturnController())->view(); }, [new AuthMiddleware(), new CsrfMiddleware()]);

$router->get('/sales/receipts', static function (): void { (new SalesReceiptsController())->index(); }, [new AuthMiddleware()]);
$router->get('/sales/receipts/form', static function (): void { (new SalesReceiptsController())->form(); }, [new AuthMiddleware()]);
$router->post('/sales/receipts/form', static function (): void { (new SalesReceiptsController())->form(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/sales/receipts/view', static function (): void { (new SalesReceiptsController())->view(); }, [new AuthMiddleware()]);

$router->get('/sales/quotations', static function (): void { (new QuotationController())->index(); }, [new AuthMiddleware()]);
$router->get('/sales/quotations/form', static function (): void { (new QuotationController())->form(); }, [new AuthMiddleware()]);
$router->post('/sales/quotations/form', static function (): void { (new QuotationController())->form(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/sales/quotations/view', static function (): void { (new QuotationController())->view(); }, [new AuthMiddleware()]);
$router->get('/sales/quotations/convert', static function (): void { (new QuotationController())->convert(); }, [new AuthMiddleware()]);
$router->post('/sales/quotations/convert', static function (): void { (new QuotationController())->convert(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/sales/quotations/email', static function (): void { (new QuotationController())->email(); }, [new AuthMiddleware()]);
$router->post('/sales/quotations/email', static function (): void { (new QuotationController())->email(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/sales/quotations/whatsapp', static function (): void { (new QuotationController())->whatsapp(); }, [new AuthMiddleware()]);
$router->post('/sales/quotations/whatsapp', static function (): void { (new QuotationController())->whatsapp(); }, [new AuthMiddleware(), new CsrfMiddleware()]);

$router->get('/sales/pos', static function (): void { (new PosController())->index(); }, [new AuthMiddleware()]);
$router->post('/sales/pos', static function (): void { (new PosController())->index(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/pos', static function (): void { (new PosController())->index(); }, [new AuthMiddleware()]);
$router->post('/pos', static function (): void { (new PosController())->index(); }, [new AuthMiddleware(), new CsrfMiddleware()]);
$router->get('/pos/suspended', static function (): void { (new PosController())->suspended(); }, [new AuthMiddleware()]);
