<?php

use Illuminate\Support\Facades\Route;
use Modules\Main\Http\Controllers\MainController;

//Company
Route::get('/company/create', Modules\Main\Http\Controllers\Company\CreateCompanyFormController::class)->name('company.form.create');
Route::post('/company/create', Modules\Main\Http\Controllers\Company\CreateCompanyController::class)->name('company.create');
//Route::post('/company/status/update', Modules\Main\Http\Controllers\Company\ConfirmCompanyController::class)->name('company.status.update');

Route::middleware(['auth'])->group(function ()
{

    Route::get('/main', [MainController::class, 'index']);

    Route::get('/company/confirmer', function ()
    {
        return view(view: 'company.post_confirmer');
    });

    Route::middleware(['auth'])->group(function ()
    {
        Route::get('/company/details/{company?}', [Modules\Main\Http\Controllers\Company\DetailsController::class, 'index'])->name('company.details');
        Route::post('/company/{company}/details/', [Modules\Main\Http\Controllers\Company\DetailsController::class, 'store'])->name('company.details.store');
        
        Route::post('/companies/admins/store/', Modules\Main\Http\Controllers\Company\CreateAdminController::class)->name('company.admin.store');
        
        Route::get('/agents/table', [Modules\Main\Http\Controllers\Company\AgentsTableController::class, 'index'])->name('company.agents.table');
        //Route::post('/company/agents/store/', Modules\Main\Http\Controllers\Company\CreateAgentController::class)->name('company.agents.store');
        Route::post('/companies/agents/store/', Modules\Main\Http\Controllers\Company\CreateAgentController::class)->name('company.agents.store');
        Route::post('/company/agents/{agent}/password/reset/', Modules\Main\Http\Controllers\Company\ResetAgentPasswordController::class)->name('company.agent.password.reset');
        Route::get('/company/agents/{agent}/delete', Modules\Main\Http\Controllers\Company\DeleteAgentController::class)->name('company.agents.delete')->withTrashed();
        Route::get('/company/agents/{agent}/restore', Modules\Main\Http\Controllers\Company\RestoreAgentController::class)->name('company.agents.restore')->withTrashed();

    });

    Route::middleware(['hasAccess'])->group(function ()
    {
        /** Routes that need to be protected - Маршруты которые нужно защитить */
    });
});