<?php

namespace App\Http\Controllers;
// use App\Http\Controllers\AuthController;
// use App\Http\Controllers\ProfileController;
use App\Http\Controllers\Admin\DashboardController;
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::get('/', [AuthController::class, 'index'])->name('auth');

Route::post('/signin', [AuthController::class, 'signin']);
Route::post('/register', [AuthController::class, 'register']);
// Route::get('/admin/dashboard', [DashboardController::class, 'index'])->middleware('auth');

Route::get('/dashboard', function () {
    return view('dashboard');
})->middleware(['auth', 'verified'])->name('dashboard');

Route::middleware('auth')->group(function () {
    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
    Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
    Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
});

require __DIR__ . '/auth.php';
Route::middleware(['auth'])->group(function () {
    Route::resource('admin/dashboard', Admin\DashboardController::class);
    Route::resource('admin/category', Admin\CategoryController::class);
    Route::get('admin/subcategory/{id}', [Admin\SubcategoryController::class, 'index'])->name('subcategory.index');
    Route::post('admin/subcategory/create', [Admin\SubcategoryController::class, 'create'])->name('store.subcategory');
    Route::post('admin/subcategory/{id}', [Admin\SubcategoryController::class, 'update'])->name('edit.subcategory');
    Route::post('admin/subcategory/delete/{id}', [Admin\SubcategoryController::class, 'delete'])->name('delete.subcategory');
    // Route::resource('admin/item', Admin\ItemController::class);
    Route::get('admin/item/{idk}/{ids}', [Admin\ItemController::class, 'index'])->name('item.index');
    Route::post('admin/item/create/{ids}', [Admin\ItemController::class, 'create'])->name('item.create');
    Route::post('admin/item/{id}', [Admin\ItemController::class, 'update'])->name('item.update');
    Route::post('admin/item/delete/{id}', [Admin\ItemController::class, 'delete'])->name('delete.item');
    Route::post('admin/category/{id}', [Admin\CategoryController::class, 'update']);
    Route::post('admin/category/delete/{id}', [Admin\CategoryController::class, 'delete'])->name('delete.category');
    // Route::resource('admin/component', Admin\ComponentController::class);
    Route::get('admin/component/{idk}/{ids}/{idb}', [Admin\ComponentController::class, 'index'])->name('component.index');
    Route::post('admin/component/create/{idb}', [Admin\ComponentController::class, 'store'])->name('create.component');
    Route::post('admin/component/{idc}', [Admin\ComponentController::class, 'update'])->name('update.component');
    Route::post('admin/component/delete/{idc}', [Admin\ComponentController::class, 'delete'])->name('delete.component');
    Route::resource('admin/check', Admin\CheckController::class);
    Route::get('admin/compare', [Admin\CompareController::class, 'index'])->name('compare.index');
    Route::post('admin/compare', [Admin\CompareController::class, 'compare'])->name('compare.item');
    Route::resource('admin/history', Admin\HistoryController::class);
    Route::get('admin/user', [Admin\UserController::class, 'index']);
});
