<?php


use kernel\App;
use kernel\CgRouteCollector;
use Phroute\Phroute\RouteCollector;

App::$collector->group(["prefix" => "admin"], function (CgRouteCollector $router) {
    App::$collector->group(["before" => "auth"], function (RouteCollector $router) {
        App::$collector->group(["prefix" => "tg-bot"], function (CGRouteCollector $router) {
            App::$collector->get('/', [\app\modules\tgbot\controllers\TgbotController::class, 'actionIndex']);
            App::$collector->get('/page/{page_number}', [\app\modules\tag\controllers\TagController::class, 'actionIndex']);
            App::$collector->get('/create', [\app\modules\tgbot\controllers\TgbotController::class, 'actionCreate']);
            App::$collector->post("/", [\app\modules\tgbot\controllers\TgbotController::class, 'actionAdd']);
            App::$collector->get('/view/{id}', [\app\modules\tgbot\controllers\TgbotController::class, 'actionView']);
            App::$collector->any('/update/{id}', [\app\modules\tgbot\controllers\TgbotController::class, 'actionUpdate']);
            App::$collector->any("/edit/{id}", [\app\modules\tgbot\controllers\TgbotController::class, 'actionEdit']);
            App::$collector->get('/delete/{id}', [\app\modules\tgbot\controllers\TgbotController::class, 'actionDelete']);
        });
        App::$collector->group(["prefix" => "settings"], function (CGRouteCollector $router) {
            App::$collector->get('/tag', [\app\modules\tag\controllers\TagController::class, 'actionSettings']);
            App::$collector->post('/tag/update', [\app\modules\tag\controllers\TagController::class, 'actionSaveSettings']);
        });
    });
});

App::$collector->group(["prefix" => "api"], function (CgRouteCollector $router){
    App::$collector->group(['before' => 'bearer'], function (CgRouteCollector $router){
        $router->rest("tg-bot", [\app\modules\tgbot\controllers\TgBotRestController::class]);
        $router->post('/tg-bot/create-card', [\app\modules\tgbot\controllers\TgBotRestController::class, 'actionCreateCard']);
        $router->get('/tg-bot/get-by-dialog/{dialog_id}/{bot_id}', [\app\modules\tgbot\controllers\TgBotRestController::class, 'actionGetByDialog']);
    });
});