<?php

use App\Http\Controllers\Admin\ActivityLogController;
use App\Http\Controllers\Admin\AdminPanelController;
use App\Http\Controllers\Admin\ExtensionController;
use App\Http\Controllers\Admin\PositionController;
use App\Http\Controllers\Admin\PrefixController;
use App\Http\Controllers\Admin\RoleController;
use App\Http\Controllers\Admin\SectorController;
use App\Http\Controllers\Auth\AdminLoginController;
use App\Http\Controllers\Admin\UserController;
use App\Http\Controllers\Admin\AdminController;
use App\Http\Controllers\Admin\BusinessCardRequestController;
use App\Http\Controllers\Admin\IdCardRequestController;
use App\Http\Controllers\Admin\LocationController;
use App\Http\Controllers\EmployeeController;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\LocalizationController;
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('/', [EmployeeController::class, 'index']);
Route::post('/employee_search', [EmployeeController::class, 'search'])->name('employee_search');
Route::post('/business_id', [EmployeeController::class, 'store'])->name('business_id');
Route::get('/business_card/{employee}', [EmployeeController::class, 'businessCard'])->name('business_card');
Route::get('/id_card/{employee}', [EmployeeController::class, 'idCard'])->name('id_card');
Route::get('contact', [HomeController::class, 'contact']);

// DON'T Put it inside the '/admin' Prefix , Otherwise you'll never get the page due to assign.guard that will redirect you too many times
Route::get('admin/login', [AdminLoginController::class, 'showLoginForm']);
Route::post('admin/login', [AdminLoginController::class, 'login'])->name('admin.login');
Route::post('admin/logout', [AdminLoginController::class, 'logout'])->name('admin.logout');

// Change Language
Route::get('lang/{lang}', [LocalizationController::class , 'index'])->name('language');

Route::group(['prefix' => '/admin','middleware' => 'assign.guard:admin,admin/login'],function(){

    Route::get('dashboard', [AdminPanelController::class, 'index']);
    Route::resource('extensions', ExtensionController::class);
    Route::resource('sectors', SectorController::class);
    Route::resource('prefixes', PrefixController::class);
    Route::resource('positions', PositionController::class);
    Route::resource('locations', LocationController::class);
    Route::get('get_locations/{address}', [LocationController::class, 'fetch']);
    Route::resource('employees', UserController::class);
    Route::post('import_employees', [UserController::class, 'import'])->name('import_employees');

    Route::resource('roles', RoleController::class);
    Route::resource('admins', AdminController::class);

    Route::get('business_card_requests', [BusinessCardRequestController::class, 'index'])->name('business_card_requests');
    Route::post('business_card_requests/accept', [BusinessCardRequestController::class, 'accept'])->name('business_card_requests.accept');
    Route::post('business_card_requests/reject', [BusinessCardRequestController::class, 'reject'])->name('business_card_requests.reject');

    Route::get('id_card_requests', [IdCardRequestController::class, 'index'])->name('id_card_requests');
    Route::post('id_card_requests/accept', [IdCardRequestController::class, 'accept'])->name('id_card_requests.accept');
    Route::post('id_card_requests/reject', [IdCardRequestController::class, 'reject'])->name('id_card_requests.reject');

    Route::get('activity_logs', [ActivityLogController::class, 'index'])->name('activity_logs');

});

Auth::routes();

Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
