<?php

use CodeIgniter\Router\RouteCollection;

/**
 * @var RouteCollection $routes
 */
$routes->get('/', 'Home::index');
$routes->post('api/check-domain', 'Api::checkDomain');

$routes->get('login', 'Auth::login');
$routes->post('login/process', 'Auth::processLogin');
$routes->get('register', 'Auth::register');
$routes->post('register/process', 'Auth::processRegister');
$routes->get('logout', 'Auth::logout');

$routes->group('dashboard', ['filter' => 'auth'], static function ($routes) {
    $routes->get('/', 'Dashboard::index');
    $routes->get('manage/(:num)', 'Dashboard::manage/$1');
    $routes->post('save-ns', 'Dashboard::saveNs');
    $routes->post('add-record', 'Dashboard::addDnsRecord');
    $routes->get('delete-record/(:num)', 'Dashboard::deleteDnsRecord/$1');
});

$routes->group('admin', ['filter' => 'auth:admin'], static function ($routes) {
    $routes->get('dashboard', 'Admin::dashboard');
    $routes->get('users', 'Admin::users');
    $routes->get('users/toggle/(:num)', 'Admin::toggleUserStatus/$1');
    $routes->get('domains', 'Admin::domains');
    $routes->get('domains/delete/(:num)', 'Admin::deleteDomain/$1');

    $routes->get('settings', 'Admin::settings');
    $routes->post('settings/save', 'Admin::saveSettings');

    $routes->get('suffixes', 'Admin::suffixes');
    $routes->post('suffixes/add', 'Admin::addSuffix');
    $routes->get('suffixes/delete/(:num)', 'Admin::deleteSuffix/$1');
});

$routes->group('install', static function ($routes) {
    $routes->get('/', 'Install::index');
    $routes->get('step2', 'Install::step2');
    $routes->post('process2', 'Install::processStep2');
    $routes->get('step3', 'Install::step3');
    $routes->post('process3', 'Install::processStep3');
    $routes->get('success', 'Install::success');
});
