<?php

use CodeIgniter\Router\RouteCollection;

/**
 * @var RouteCollection $routes
 */
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('DashboardController');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(false);

$routes->get('/', 'DashboardController::index', ['as' => 'home', 'filter' => ['session', 'role:admin,coach']]);
$routes->get('/dashboard', 'DashboardController::index', ['as' => 'dashboard', 'filter' => ['session', 'role:admin,coach']]);

$routes->get('/children', 'ChildrenController::index', ['as' => 'children.index', 'filter' => ['session', 'role:admin,coach']]);
$routes->get('/children/new', 'ChildrenController::new', ['as' => 'children.new', 'filter' => ['session', 'role:admin']]);
$routes->post('/children', 'ChildrenController::create', ['as' => 'children.create', 'filter' => ['session', 'role:admin']]);
$routes->get('/children/(:num)', 'ChildrenController::show/$1', ['as' => 'children.show', 'filter' => ['session', 'role:admin,coach']]);
$routes->get('/children/(:num)/edit', 'ChildrenController::edit/$1', ['as' => 'children.edit', 'filter' => ['session', 'role:admin']]);
$routes->post('/children/(:num)', 'ChildrenController::update/$1', ['as' => 'children.update', 'filter' => ['session', 'role:admin']]);

$routes->get('/coaches', 'CoachesController::index', ['as' => 'coaches.index', 'filter' => ['session', 'role:admin,coach']]);
$routes->get('/coaches/new', 'CoachesController::new', ['as' => 'coaches.new', 'filter' => ['session', 'role:admin']]);
$routes->post('/coaches', 'CoachesController::create', ['as' => 'coaches.create', 'filter' => ['session', 'role:admin']]);
$routes->get('/coaches/(:num)', 'CoachesController::show/$1', ['as' => 'coaches.show', 'filter' => ['session', 'role:admin,coach']]);
$routes->get('/coaches/(:num)/edit', 'CoachesController::edit/$1', ['as' => 'coaches.edit', 'filter' => ['session', 'role:admin']]);
$routes->post('/coaches/(:num)', 'CoachesController::update/$1', ['as' => 'coaches.update', 'filter' => ['session', 'role:admin']]);

$routes->get('/groups', 'GroupsController::index', ['as' => 'groups.index', 'filter' => ['session', 'role:admin,coach']]);
$routes->get('/groups/new', 'GroupsController::new', ['as' => 'groups.new', 'filter' => ['session', 'role:admin']]);
$routes->post('/groups', 'GroupsController::create', ['as' => 'groups.create', 'filter' => ['session', 'role:admin']]);
$routes->get('/groups/(:num)/edit', 'GroupsController::edit/$1', ['as' => 'groups.edit', 'filter' => ['session', 'role:admin']]);
$routes->post('/groups/(:num)', 'GroupsController::update/$1', ['as' => 'groups.update', 'filter' => ['session', 'role:admin']]);

$routes->get('/evaluations', 'EvaluationsController::index', ['as' => 'evaluations.index', 'filter' => ['session', 'role:admin,coach']]);
$routes->get('/quick-checks', 'EvaluationsController::quickChecks', ['as' => 'quickChecks.index', 'filter' => ['session', 'role:admin,coach']]);
$routes->get('/children/(:num)/evaluations/(:segment)/new', 'EvaluationsController::new/$1/$2', ['as' => 'evaluations.new', 'filter' => ['session', 'role:admin,coach']]);
$routes->post('/children/(:num)/evaluations/(:segment)', 'EvaluationsController::create/$1/$2', ['as' => 'evaluations.create', 'filter' => ['session', 'role:admin,coach']]);
$routes->get('/evaluations/(:num)', 'EvaluationsController::show/$1', ['as' => 'evaluations.show', 'filter' => ['session', 'role:admin,coach']]);

$routes->get('/attendance', 'AttendanceController::index', ['as' => 'attendance.index', 'filter' => ['session', 'role:admin,coach']]);
$routes->get('/attendance/new', 'AttendanceController::new', ['as' => 'attendance.new', 'filter' => ['session', 'role:admin,coach']]);
$routes->post('/attendance', 'AttendanceController::create', ['as' => 'attendance.create', 'filter' => ['session', 'role:admin,coach']]);
$routes->get('/attendance/(:num)', 'AttendanceController::show/$1', ['as' => 'attendance.show', 'filter' => ['session', 'role:admin,coach']]);
$routes->post('/attendance/(:num)/check-in', 'AttendanceController::saveCheckIn/$1', ['as' => 'attendance.checkIn', 'filter' => ['session', 'role:admin,coach']]);

$routes->get('/journey', 'JourneyController::index', ['as' => 'journey.index', 'filter' => ['session', 'role:admin,coach']]);

$routes->get('/alerts', 'AlertsController::index', ['as' => 'alerts.index', 'filter' => ['session', 'role:admin,coach']]);
$routes->post('/alerts/notifications/(:num)/read', 'AlertsController::markRead/$1', ['as' => 'alerts.read', 'filter' => ['session', 'role:admin,coach']]);

$routes->get('/reports', 'ReportsController::index', ['as' => 'reports.index', 'filter' => ['session', 'role:admin,coach']]);
$routes->get('/reports/export/(:segment)', 'ReportsController::export/$1', ['as' => 'reports.export', 'filter' => ['session', 'role:admin,coach']]);

$routes->get('/levels', 'LevelsController::index', ['as' => 'levels.index', 'filter' => ['session', 'role:admin,coach']]);
$routes->get('/levels/new', 'LevelsController::new', ['as' => 'levels.new', 'filter' => ['session', 'role:admin']]);
$routes->post('/levels', 'LevelsController::create', ['as' => 'levels.create', 'filter' => ['session', 'role:admin']]);
$routes->get('/levels/(:num)/edit', 'LevelsController::edit/$1', ['as' => 'levels.edit', 'filter' => ['session', 'role:admin']]);
$routes->post('/levels/(:num)', 'LevelsController::update/$1', ['as' => 'levels.update', 'filter' => ['session', 'role:admin']]);

service('auth')->routes($routes, ['except' => ['register']]);
