<?php

use Bitrix\Main\Routing\RoutingConfigurator;
use Mibazarow\Bxstore\Controller\Web\CatalogController;
use Mibazarow\Bxstore\Controller\Web\PageController;
use Mibazarow\Bxstore\Controller\Web\PersonalController;
use Mibazarow\Bxstore\Controller\Web\SearchController;

return (function (RoutingConfigurator $routes) {
    // Каталог объявлений
    $routes->any('/bulletins/', [CatalogController::class, 'listAction']);
    $routes->any('/bulletins/{sectionCode}/', [CatalogController::class, 'sectionAction'])
        ->where('sectionCode', '[\w\d\-]+');
    $routes->any('/bulletins/{sectionCode}/{elementId}/', [CatalogController::class, 'elementAction'])
        ->where('sectionCode', '[\w\d\-]+')
        ->where('elementId', '\d+');

    // Статичные страницы
    $routes->any('/about/', [PageController::class, 'aboutAction']);
    $routes->any('/about/legal/', [PageController::class, 'legalAction']);
    $routes->any('/about/policy/', [PageController::class, 'policyAction']);
    $routes->any('/about/rules/', [PageController::class, 'rulesAction']);

    // Персональный раздел
    $routes->any('/personal/', [PersonalController::class, 'indexAction']);
    $routes->any('/personal/add_bulletin/', [PersonalController::class, 'addBulletinAction']);
    $routes->any('/personal/auth/', [PersonalController::class, 'authAction']);
    $routes->any('/personal/auth/registration.php', [PersonalController::class, 'registrationAction']);
    $routes->any('/personal/auth/fogotpassword.php', [PersonalController::class, 'forgotPasswordAction']);
    $routes->any('/personal/my_bulletins/', [PersonalController::class, 'myBulletinsAction']);
    $routes->any('/personal/my_messenger/', [PersonalController::class, 'myMessengerAction']);
    $routes->any('/personal/my_wishlist/', [PersonalController::class, 'myWishlistAction']);

    // Поиск
    $routes->any('/search/', [SearchController::class, 'indexAction']);

    return $routes;
});
