<?php

use CodeIgniter\Router\RouteCollection;

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

$routes->get('/', 'Invitation::index');
$routes->get('u/(:segment)', 'Invitation::guest/$1');
$routes->post('rsvp', 'Invitation::rsvp');
$routes->post('ucapan', 'Invitation::ucapan');
$routes->get('ucapan/latest', 'Invitation::latestWishes');
$routes->get('login', 'Auth::login');
$routes->post('login', 'Auth::attemptLogin');
$routes->get('logout', 'Auth::logout');

$routes->group('admin', ['filter' => 'admin'], static function (RouteCollection $routes) {
    $routes->get('/', 'Admin\Dashboard::index');
    $routes->get('dashboard', 'Admin\Dashboard::index');
    $routes->get('acara', 'Admin\Acara::index');
    $routes->post('acara', 'Admin\Acara::update');
    $routes->resource('tamu', ['controller' => 'Admin\Tamu', 'except' => 'show']);
    $routes->post('tamu/import', 'Admin\Tamu::import');
    $routes->get('tamu/export', 'Admin\Tamu::export');
    $routes->resource('galeri', ['controller' => 'Admin\Galeri', 'except' => 'show']);
    $routes->get('rsvp', 'Admin\Rsvp::index');
    $routes->get('ucapan', 'Admin\Ucapan::index');
    $routes->post('ucapan/approve/(:num)', 'Admin\Ucapan::approve/$1');
    $routes->delete('ucapan/(:num)', 'Admin\Ucapan::delete/$1');
});
