<?php

use Illuminate\Support\Facades\Route;
use App\Models\Lobby;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

// old routes
/*
Route::get('/', function () {
    return view('start');
});

Route::get('/ll-test', function () {
    return view('TEST.sub');
});

Route::get('/join/{meetingID}', function () {
    return view('join');
});

Route::get('/meeting/{meetingID}/{participantID}', 'GuestController@meeting');
*/

// client
// =============================================================================================
Route::middleware('ensureNoValidClientSession')->group(function() {
    Route::get('/join', 'GuestController@join');
    Route::post('/join', 'GuestController@processJoin');
    Route::get('/client/checkin', 'GuestController@checkin');
    Route::post('/client/checkin', 'GuestController@processCheckin');
});
Route::middleware('ensureValidClientSession')->group(function() {
    Route::get('/get-client-checkin-token/{uid}', 'GuestController@getCheckinToken');
    Route::get('/client/dashboard', 'GuestController@dashboard');
});
// =============================================================================================

// pro
// =============================================================================================
Route::middleware('ensureNoValidProSession')->group(function() {
    Route::get('/login', 'AppSessionController@proLogIn')->name('login');
    Route::post('/login', 'AppSessionController@login')->name('process-login');
});

// request password
Route::get('request_password_reset', 'AppSessionController@showRequestPasswordReset')->name('request_password_reset');
Route::post('request_password_reset', 'AppSessionController@processRequestPasswordReset')->name('process_request_password_reset');
Route::get('self_reset_password', 'AppSessionController@showSelfResetPassword')->name('self_reset_password');
Route::post('self_reset_password', 'AppSessionController@processSelfResetPassword')->name('process_self_reset_password');


Route::post('/resend_sms_auth_token', 'AppSessionController@resendSmsAuthToken')->name('post-resend_sms_auth_token');
Route::get('/pro/logout', 'AppSessionController@processProLogOut')->name('pro-logout');

Route::middleware('pro.auth')->group(function() {
    Route::get('/confirm_sms_auth_token', 'AppSessionController@confirmSmsAuthToken')->name('confirm_sms_auth_token');
    Route::get('/set_password', 'AppSessionController@setPassword')->name('set_password');
    Route::get('/set_security_questions', 'AppSessionController@setSecurityQuestions')->name('set_security_questions');
    Route::post('/confirm_sms_auth_token', 'AppSessionController@postConfirmSmsAuthToken')->name('post-confirm_sms_auth_token');
    Route::post('/set_password', 'AppSessionController@postSetPassword')->name('post-set_password');
    Route::post('/set_security_questions', 'AppSessionController@postSetSecurityQuestions')->name('post-set_security_questions');
    Route::get('/', 'ProController@dashboard')->name('pro-dashboard-root');
    Route::get('/dashboard', 'ProController@dashboard')->name('pro-dashboard');
    Route::get('/pro/meet/{uid?}', 'ProController@meet');
    Route::get('/pro/get-opentok-session-key/{uid}', 'ProController@getOpentokSessionKey');
    Route::get('/note/{note_uid}', 'NoteController@renderNote')->name('render-note');
    Route::get('/select_section_template_form/{note_uid}', 'NoteController@selectSectionTemplateForm')->name('select_section_template_form');
    Route::get('/section_create_form/{note_uid}/{section_template_uid}', 'NoteController@sectionCreateForm')->name('section_create_form');
    Route::get('/section_update_form/{section_uid}', 'NoteController@sectionUpdateForm')->name('section_update_form');
    @include 'generated.php';
});

Route::post('/post-to-api', 'AppSessionController@postToAPI')->name('post-to-api');
Route::post('/post-to-api-ajax', 'AppSessionController@postToAPIAjax')->name('post-to-api-ajax');
Route::post("/process_form_submit", 'NoteController@processFormSubmit')->name('process_form_submit');
if (env('APP_ENV') === 'production') {
    URL::forceScheme('https');
}
// =============================================================================================
