<?php

use App\Http\Controllers\Auth\AuthenticatedUserSessionController;
use App\Http\Controllers\BusinessSourceController;
use App\Http\Controllers\ClientController;
use App\Http\Controllers\ClientKYCDocTemplateController;
use App\Http\Controllers\ClientKYCFieldController;
use App\Http\Controllers\CompanySettingsController;
use App\Http\Controllers\ProductController;
use App\Http\Controllers\ServiceController;
use App\Http\Controllers\UserController;
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 within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return redirect()->route('login');
});
Route::middleware([
    'auth:sanctum',
    config('jetstream.auth_session'),
    'verified'
])->group(function () {

    Route::get('/account-setup', [CompanySettingsController::class, 'superAdmin'])->middleware('super-admin');
    Route::post('/account-setup', [CompanySettingsController::class, 'superAdminUpdates'])->middleware('super-admin');

    /**Show all your Routes here that are governed by the above three Middlewares**/
    Route::get('/activate-hints/{id}', [AuthenticatedUserSessionController::class, 'showHints'])->name('libs.hints.show');
    Route::post('/activate-hints/{id}', [AuthenticatedUserSessionController::class, 'updateHints'])->name('libs.hints.update');

    Route::get('/activate-clock/{id}', [AuthenticatedUserSessionController::class, 'showClock'])->name('libs.clock.show');
    Route::post('/activate-clock/{id}', [AuthenticatedUserSessionController::class, 'updateClock'])->name('libs.clock.update');


    Route::get('/activate-notifications/{id}', [AuthenticatedUserSessionController::class, 'showNotification'])->name('libs.notification.show');
    Route::post('/activate-notifications/{id}', [AuthenticatedUserSessionController::class, 'updateNotification'])->name('libs.notification.update');

    Route::get('add-business-source', [BusinessSourceController::class, 'create'])->middleware('settings-header');
    Route::post('add-business-source', [BusinessSourceController::class, 'store'])->name('businessSource.store');

    Route::get('/add-user-account', [UserController::class, 'showNewUser'])->middleware(['settings-header']);
    Route::post('/add-user-account', [UserController::class, 'storeNewUser'])->middleware(['settings-header'])->name('user.create');
    Route::get('/add-new-product', [ProductController::class, 'showAddNewProduct'])->middleware(['settings-header']);
    Route::post('/add-new-product', [ProductController::class, 'storeAddNewProduct'])->middleware(['settings-header'])->name('product.create');
    Route::get('/add-new-service', [ServiceController::class, 'showAddNewService'])->middleware(['settings-header']);
    Route::post('/add-new-service', [ServiceController::class, 'storeAddNewService'])->middleware(['settings-header'])->name('service.create');

    Route::get('/add-client/{docId?}/{module?}', [ClientController::class, 'create'])->middleware(['dash-header']);
    Route::post('/add-client/{docId?}/{module?}', [ClientController::class, 'store'])->middleware('dash-header')->name('client.store');

    Route::get('/company-info', [CompanySettingsController::class, 'index'])->middleware('settings-header');
    Route::post('/company-info', [CompanySettingsController::class, 'update'])->middleware('settings-header')->name('update-details');

    Route::get('client/{id}', [ClientController::class, 'show']);
    Route::post('client', [ClientController::class, 'show'])->name('search-client');
    Route::get('clients', [ClientController::class, 'index']);

    Route::get('edit-client-details/{id}', [ClientController::class, 'showEditClientDetails']);
    Route::post('edit-client-details/{id}', [ClientController::class, 'storeEditClientDetails'])->name('client.storeEditClientDetails');

    Route::get('/edit-user-account/{id}', [UserController::class, 'showUpdateUserAccountDetails'])->middleware(['settings-header']);
    Route::post('/edit-user-account/{id}', [UserController::class, 'storeUpdateUserAccountDetails'])->middleware(['settings-header'])->name('user.storeUpdateUserAccountDetails');

    Route::get('/edit-user-modules/{id}', [UserController::class, 'showUpdatedUserModules'])->middleware(['settings-header']);
    Route::post('/edit-user-modules/{id}', [UserController::class, 'storeUpdatedUserModules'])->middleware(['settings-header'])->name('user.storeUpdatedUserModules');

    Route::get('/edit-user-creates/{id}', [UserController::class, 'showUpdatedUserCreates'])->middleware(['settings-header']);
    Route::post('/edit-user-creates/{id}', [UserController::class, 'storeUpdatedUserCreates'])->middleware(['settings-header'])->name('user.storeUpdatedUserCreates');

    Route::get('/edit-user-views/{id}', [UserController::class, 'showUpdatedUserViews'])->middleware(['settings-header']);
    Route::post('/edit-user-views/{id}', [UserController::class, 'storeUpdatedUserViews'])->middleware(['settings-header'])->name('user.storeUpdatedUserViews');

    Route::get('/edit-user-edits/{id}', [UserController::class, 'showUpdatedUserEdits'])->middleware(['settings-header']);
    Route::post('/edit-user-edits/{id}', [UserController::class, 'storeUpdatedUserEdits'])->middleware(['settings-header']);

    Route::get('/edit-user-deletes/{id}', [UserController::class, 'showUpdatedUserDeletes'])->middleware(['settings-header']);
    Route::post('/edit-user-deletes/{id}', [UserController::class, 'storeUpdatedUserDeletes'])->middleware(['settings-header']);

    Route::get('/edit-user-passwords', [UserController::class, 'showEditPassword']);
    Route::post('/edit-user-passwords', [UserController::class, 'storeEditPassword'])->name('user.storeEditPassword');

    Route::get('manage-user/{id}', [UserController::class, 'manageUserAccount'])->middleware('settings-header');

    Route::get('setup-business-leeds', [BusinessSourceController::class, 'index'])->middleware('settings-header');
    Route::put('setup-business-leeds/{id}', [BusinessSourceController::class, 'edit'])->middleware('settings-header');

    Route::get('/premium-calculators', [AuthenticatedUserSessionController::class, 'showCalculator'])->name('libs.calculator.show');

    //LETTER S ROUTES
    Route::get('/search-client', [ClientController::class, 'search']);

    Route::get('/setup-client-kyc-fields', [ClientKYCFieldController::class, 'index'])->middleware('settings-header');
    Route::post('/setup-client-kyc-fields/{id}', [ClientKYCFieldController::class, 'update'])->middleware('settings-header')->name('ClientKYCField.update');

    Route::get('/setup-client-kyc-docs', [ClientKYCDocTemplateController::class, 'index'])->middleware('settings-header');
    Route::get('/setup-products', [ProductController::class, 'index'])->middleware('settings-header');
    Route::get('/setup-services', [ServiceController::class, 'index'])->middleware('settings-header');

    Route::get('/search-client', [ClientController::class, 'search']);
    Route::get('/search-client-id', [ClientController::class, 'searchedClientId']);
    Route::post('/search-client-id', [ClientController::class, 'searchedClientId']);
    Route::get('/search-client-finance', [ClientController::class, 'searchClientFinance']);
    Route::get('/search-client-by-name/{name}', [ClientController::class, 'searchClientByName']);
    Route::get('/search-client-by-name-add-id/{name}', [ClientController::class, 'searchClientByNameAddId']);
    Route::get('/search-client-by-name-add-id-two/{name}', [ClientController::class, 'searchClientByNameAddIdTwo']);

    //LETTER U ROUTES
    Route::get('/upload-client-files/{id}', [ClientKYCDocTemplateController::class, 'showUploadClientFiles']);
    Route::post('/upload-client-files/{id}', [ClientKYCDocTemplateController::class, 'storeUploadClientFiles'])->name('storeUploadClientFiles.store');

    Route::get('/user-accounts', [UserController::class, 'showUsers']);
    Route::put('/user-accounts/{id}', [UserController::class, 'restoreUserAccount']);
    Route::get('/user-account-block/{id}', [UserController::class, 'showBlockUser']);
    Route::post('/user-account-block/{id}', [UserController::class, 'updateBlockUser']);

    require 'modules.php';
    require 'emails.php';
    require 'hr.php';
    require 'user.php';
    require 'prospects.php';
    require 'payments.php';
    require 'finance.php';
    require 'audit.php';
    require 'inventory.php';
    require 'inventory-old.php';
});
