<?php

use CodeIgniter\Router\RouteCollection;

/**
 * @var RouteCollection $routes
 */
// $routes->get('/', 'Home::index');

$routes->get('/', 'User\Dashboard::index');
$routes->get('/login', 'Auth::login');
$routes->post('/login', 'Auth::prosesLogin');
$routes->get('/logout', 'Auth::logout');
$routes->get('/register', 'Auth::register');
$routes->post('/register', 'Auth::prosesRegister');


$routes->group('admin', ['filter' => 'admin'], function ($routes) {

    $routes->get('dashboard', 'Admin\Dashboard::index');

    // Crud Users
    $routes->get('users', 'Admin\Users::index');
    $routes->post('users/store', 'Admin\Users::store');
    $routes->post('users/update/(:num)', 'Admin\Users::update/$1');
    $routes->get('users/delete/(:num)', 'Admin\Users::delete/$1');


    // data bencana
    $routes->get('data', 'Admin\Data::index');
    $routes->post('data/store', 'Admin\Data::store');
    $routes->post('data/update/(:num)', 'Admin\Data::update/$1');
    $routes->get('data/delete/(:num)', 'Admin\Data::delete/$1');

    // kemiringan lereng
    $routes->get('kemiringan', 'Admin\KemiringanLereng::index');
    $routes->post('kemiringan/store', 'Admin\KemiringanLereng::store');
    $routes->post('kemiringan/update/(:num)', 'Admin\KemiringanLereng::update/$1');
    $routes->get('kemiringan/delete/(:num)', 'Admin\KemiringanLereng::delete/$1');


    // penggunaan lahan
    $routes->get('penggunaan-lahan', 'Admin\PenggunaanLahan::index');
    $routes->post('penggunaan-lahan/store', 'Admin\PenggunaanLahan::store');
    $routes->post('penggunaan-lahan/update/(:num)', 'Admin\PenggunaanLahan::update/$1');
    $routes->get('penggunaan-lahan/delete/(:num)', 'Admin\PenggunaanLahan::delete/$1');

    // jenis tanah
    $routes->get('jenis-tanah', 'Admin\JenisTanah::index');
    $routes->post('jenis-tanah/store', 'Admin\JenisTanah::store');
    $routes->post('jenis-tanah/update/(:num)', 'Admin\JenisTanah::update/$1');
    $routes->get('jenis-tanah/delete/(:num)', 'Admin\JenisTanah::delete/$1');

    // geologi
    $routes->get('geologi', 'Admin\Geologi::index');
    $routes->post('geologi/store', 'Admin\Geologi::store');
    $routes->post('geologi/update/(:num)', 'Admin\Geologi::update/$1');
    $routes->get('geologi/delete/(:num)', 'Admin\Geologi::delete/$1');

    // strategi mitigasi
    $routes->get('strategi-mitigasi', 'Admin\StrategiMitigasi::index');
    $routes->post('strategi-mitigasi/store', 'Admin\StrategiMitigasi::store');
    $routes->post('strategi-mitigasi/update/(:num)', 'Admin\StrategiMitigasi::update/$1');
    $routes->get('strategi-mitigasi/delete/(:num)', 'Admin\StrategiMitigasi::delete/$1');

    // peta kerawanan
    $routes->get('peta-kerawanan', 'Admin\PetaKerawanan::index');
    $routes->post('peta-kerawanan/store', 'Admin\PetaKerawanan::store');
    $routes->get('peta-kerawanan/detail/(:num)', 'Admin\PetaKerawanan::detail/$1');
    $routes->get('peta-kerawanan/delete/(:num)', 'Admin\PetaKerawanan::delete/$1');
    $routes->get('peta-kerawanan/buat-peta', 'Admin\PetaKerawanan::buatPeta');
    $routes->post('peta-kerawanan/simpan-peta', 'Admin\PetaKerawanan::simpanPeta');

    // Wilayah
    $routes->get('wilayah', 'Admin\Wilayah::index');
    $routes->post('wilayah/store', 'Admin\Wilayah::store');
    $routes->post('wilayah/update/(:num)', 'Admin\Wilayah::update/$1');
    $routes->get('wilayah/delete/(:num)', 'Admin\Wilayah::delete/$1');

    // peta mitigasi
    $routes->get('wilayahmitigasi', 'Admin\WilayahMitigasi::index');
    $routes->post('wilayahmitigasi/store', 'Admin\WilayahMitigasi::store');
    $routes->post('wilayahmitigasi/update/(:num)', 'Admin\WilayahMitigasi::update/$1');
    $routes->get('wilayahmitigasi/delete/(:num)', 'Admin\WilayahMitigasi::delete/$1');
    $routes->get('wilayahmitigasi/print', 'Admin\WilayahMitigasi::print');

    // Lokasi Kejadian Banjir
    $routes->get('lokasi-kejadian-banjir', 'Admin\LokasiKejadianBanjir::index');
    $routes->post('lokasi-kejadian-banjir/store', 'Admin\LokasiKejadianBanjir::store');
    $routes->post('lokasi-kejadian-banjir/update/(:num)', 'Admin\LokasiKejadianBanjir::update/$1');
    $routes->post('lokasi-kejadian-banjir/delete/(:num)', 'Admin\LokasiKejadianBanjir::delete/$1');
});

$routes->group('user', function ($routes) {

    $routes->get('dashboard', 'User\Dashboard::index');

    $routes->get('peta', 'User\Peta::index');

    $routes->post('simpan_polygon', 'User\Peta::simpan_polygon');

    $routes->get('data', 'User\Data::index');

    $routes->get('mitigasi', 'User\Mitigasi::index');

    $routes->get('peta-mitigasi', 'Admin\PetaMitigasi::index');

    $routes->post('mitigasi/simpan_polygon', 'User\Mitigasi::simpan_polygon');

    $routes->get('informasi', 'User\Informasi::index');

    $routes->get('tentang', 'User\Tentang::index');

});