<?php

use App\Http\Controllers\Auth\AuthenticatedSessionController;
use App\Http\Controllers\Auth\NewPasswordController;
use App\Http\Controllers\Auth\PasswordResetLinkController;
use App\Http\Controllers\Auth\RegisteredUserController;
use App\Http\Controllers\AuthorisedPartnerController;
use App\Http\Controllers\CoursewareCategoryController;
use App\Http\Controllers\CoursewarePartnerController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\GetSkillsadminController;
use App\Http\Controllers\PromoterController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/

Route::prefix('demo')->middleware(['auth', 'approved'])->name('demo.')->group(function () {
    Route::controller(GetSkillsadminController::class)->group(function () {
        Route::get('/',                 'dashboard_1')->name('home');
        Route::get('/index',            'dashboard_1')->name('index');
        Route::get('/index-2',          'dashboard_2')->name('index-2');
        Route::get('/schedule',         'schedule')->name('schedule');
        Route::get('/instructors',      'instructors')->name('instructors');
        Route::get('/message',          'message')->name('message');
        Route::get('/activity',         'activity')->name('activity');
        Route::get('/profile',          'profile')->name('profile');
        Route::get('/courses',          'courses')->name('courses');
        Route::get('/course-details-1', 'course_details_1')->name('course-details-1');
        Route::get('/course-details-2', 'course_details_2')->name('course-details-2');
        Route::get('/instructor-dashboard','instructor_dashboard')->name('instructor-dashboard');
        Route::get('/instructor-courses','instructor_courses')->name('instructor-courses');
        Route::get('/instructor-schedule','instructor_schedule')->name('instructor-schedule');
        Route::get('/instructor-students','instructor_students')->name('instructor-students');
        Route::get('/instructor-resources','instructor_resources')->name('instructor-resources');
        Route::get('/instructor-transactions','instructor_transactions')->name('instructor-transactions');
        Route::get('/instructor-liveclass','instructor_liveclass')->name('instructor-liveclass');
        Route::get('/app-profile',      'app_profile')->name('app-profile');
        Route::match(['get','post'],'/post-details',     'post_details')->name('post-details');
        Route::get('/email-compose',    'email_compose')->name('email-compose');
        Route::get('/email-inbox',      'email_inbox')->name('email-inbox');
        Route::get('/email-read',       'email_read')->name('email-read');
        Route::get('/app-calender',     'app_calender')->name('app-calender');
        Route::get('/ecom-product-grid','ecom_product_grid')->name('ecom-product-grid');
        Route::get('/ecom-product-list','ecom_product_list')->name('ecom-product-list');
        Route::get('/ecom-product-detail','ecom_product_detail')->name('ecom-product-detail');
        Route::get('/ecom-product-order','ecom_product_order')->name('ecom-product-order');
        Route::get('/ecom-checkout',    'ecom_checkout')->name('ecom-checkout');
        Route::get('/ecom-invoice',     'ecom_invoice')->name('ecom-invoice');
        Route::get('/ecom-customers',   'ecom_customers')->name('ecom-customers');
        Route::get('/chart-flot',       'chart_flot')->name('chart-flot');
        Route::get('/chart-morris',     'chart_morris')->name('chart-morris');
        Route::get('/chart-chartjs',    'chart_chartjs')->name('chart-chartjs');
        Route::get('/chart-chartist',   'chart_chartist')->name('chart-chartist');
        Route::get('/chart-sparkline',  'chart_sparkline')->name('chart-sparkline');
        Route::get('/chart-peity',      'chart_peity')->name('chart-peity');
        Route::get('/ui-accordion',     'ui_accordion')->name('ui-accordion');
        Route::get('/ui-alert',         'ui_alert')->name('ui-alert');
        Route::get('/ui-badge',         'ui_badge')->name('ui-badge');
        Route::get('/ui-button',        'ui_button')->name('ui-button');
        Route::get('/ui-modal',         'ui_modal')->name('ui-modal');
        Route::get('/ui-button-group',  'ui_button_group')->name('ui-button-group');
        Route::get('/ui-list-group',    'ui_list_group')->name('ui-list-group');
        Route::get('/ui-card',          'ui_card')->name('ui-card');
        Route::get('/ui-carousel',      'ui_carousel')->name('ui-carousel');
        Route::get('/ui-dropdown',      'ui_dropdown')->name('ui-dropdown');
        Route::get('/ui-popover',       'ui_popover')->name('ui-popover');
        Route::get('/ui-progressbar',   'ui_progressbar')->name('ui-progressbar');
        Route::get('/ui-tab',           'ui_tab')->name('ui-tab');
        Route::get('/ui-typography',    'ui_typography')->name('ui-typography');
        Route::get('/ui-pagination',    'ui_pagination')->name('ui-pagination');
        Route::get('/ui-grid',          'ui_grid')->name('ui-grid');
        Route::get('/uc-select2',       'uc_select2')->name('uc-select2');
        Route::get('/uc-nestable',      'uc_nestable')->name('uc-nestable');
        Route::get('/uc-noui-slider',   'uc_noui_slider')->name('uc-noui-slider');
        Route::get('/uc-sweetalert',    'uc_sweetalert')->name('uc-sweetalert');
        Route::get('/uc-toastr',        'uc_toastr')->name('uc-toastr');
        Route::get('/map-jqvmap',       'map_jqvmap')->name('map-jqvmap');
        Route::get('/uc-lightgallery',  'uc_lightgallery')->name('uc-lightgallery');
        Route::get('/widget-basic',     'widget_basic')->name('widget-basic');
        Route::get('/form-element',     'form_element')->name('form-element');
        Route::get('/form-wizard',      'form_wizard')->name('form-wizard');
        Route::get('/form-ckeditor',    'form_ckeditor')->name('form-ckeditor');
        Route::get('/form-pickers',     'form_pickers')->name('form-pickers');
        Route::get('/form-validation',  'form_validation')->name('form-validation');
        Route::get('/table-bootstrap-basic', 'table_bootstrap_basic')->name('table-bootstrap-basic');
        Route::get('/table-datatable-basic', 'table_datatable_basic')->name('table-datatable-basic');
        Route::get('/page-login',       'page_login')->name('page-login');
        Route::get('/page-register',    'page_register')->name('page-register');
        Route::get('/page-error-400',   'page_error_400')->name('page-error-400');
        Route::get('/page-error-403',   'page_error_403')->name('page-error-403');
        Route::get('/page-error-404',   'page_error_404')->name('page-error-404');
        Route::get('/page-error-500',   'page_error_500')->name('page-error-500');
        Route::get('/page-error-503',   'page_error_503')->name('page-error-503');
        Route::get('/page-forgot-password', 'page_forgot_password')->name('page-forgot-password');
        Route::get('/page-lock-screen', 'page_lock_screen')->name('page-lock-screen');
        Route::get('/empty-page',       'page_empty')->name('empty-page');
    });
});

Route::middleware('guest')->prefix('admin')->group(function () {
    Route::get('/', [AuthenticatedSessionController::class, 'create']);
    Route::get('/login', [AuthenticatedSessionController::class, 'create'])->name('admin.login');
    Route::post('/login', [AuthenticatedSessionController::class, 'store'])->name('admin.login.store');

    // Route::get('/register', [RegisteredUserController::class, 'create'])->name('admin.register');
    // Route::post('/register', [RegisteredUserController::class, 'store'])->name('admin.register.store');

    Route::get('/forgot-password', [PasswordResetLinkController::class, 'create'])->name('admin.password.request');
    Route::post('/forgot-password', [PasswordResetLinkController::class, 'store'])->name('admin.password.email');

    Route::get('/reset-password/{token}', [NewPasswordController::class, 'create'])->name('admin.password.reset');
    Route::post('/reset-password', [NewPasswordController::class, 'store'])->name('admin.password.update');
});

Route::middleware(['auth', 'approved'])->group(function () {
    Route::get('/', [DashboardController::class, 'index'])->name('dashboard');
    Route::post('/admin/logout', [AuthenticatedSessionController::class, 'destroy'])->name('admin.logout');

    Route::middleware('role:super_admin')->group(function () {
        Route::resource('courseware-categories', CoursewareCategoryController::class)->except(['show']);
        Route::get('promoters/{promoter}/authorised-partners', [PromoterController::class, 'authorisedPartners'])->name('promoters.authorised-partners');
        Route::resource('promoters', PromoterController::class);
        Route::patch('promoters/{promoter}/approve', [PromoterController::class, 'approve'])->name('promoters.approve');
        Route::patch('promoters/{promoter}/reject', [PromoterController::class, 'reject'])->name('promoters.reject');
    });

    Route::middleware('role:super_admin,promoter')->group(function () {
        Route::get('authorised-partners/{authorised_partner}/courseware-partners', [AuthorisedPartnerController::class, 'coursewarePartners'])->name('authorised-partners.courseware-partners');
        Route::resource('authorised-partners', AuthorisedPartnerController::class);
        Route::patch('authorised-partners/{authorised_partner}/approve', [AuthorisedPartnerController::class, 'approve'])->name('authorised-partners.approve');
        Route::patch('authorised-partners/{authorised_partner}/reject', [AuthorisedPartnerController::class, 'reject'])->name('authorised-partners.reject');
    });

    Route::middleware('role:super_admin,authorised_partner,promoter')->group(function () {
        Route::resource('courseware-partners', CoursewarePartnerController::class);
        Route::patch('courseware-partners/{courseware_partner}/approve', [CoursewarePartnerController::class, 'approve'])->name('courseware-partners.approve');
        Route::patch('courseware-partners/{courseware_partner}/reject', [CoursewarePartnerController::class, 'reject'])->name('courseware-partners.reject');
    });
});
