<?php

use App\Http\Controllers\InventoryController;
use App\Http\Controllers\Admin\AdminAuthController;
use App\Http\Controllers\Admin\AdminProductController;
use App\Http\Controllers\Admin\AdminReportController;
use App\Http\Controllers\Admin\AdminStockMovementController;
use Illuminate\Support\Facades\Route;

// Mengarahkan halaman utama website ke controller inventory kita
Route::get('/', [InventoryController::class, 'index'])->name('inventory.index');

// Admin routes (simple session-based admin auth)
Route::prefix('admin')->group(function () {
	Route::get('login', [AdminAuthController::class, 'showLogin'])->name('admin.login');
	Route::post('login', [AdminAuthController::class, 'login'])->name('admin.login.post');
	Route::post('logout', [AdminAuthController::class, 'logout'])->name('admin.logout');

	Route::middleware([\App\Http\Middleware\AdminAuth::class])->group(function () {
		Route::get('/', [AdminProductController::class, 'dashboard'])->name('admin.dashboard');
		Route::get('products', [AdminProductController::class, 'index'])->name('admin.products.index');
		Route::get('products/create', [AdminProductController::class, 'create'])->name('admin.products.create');
		Route::post('products', [AdminProductController::class, 'store'])->name('admin.products.store');
		Route::get('products/{product}/edit', [AdminProductController::class, 'edit'])->name('admin.products.edit');
		Route::post('products/{product}/update', [AdminProductController::class, 'update'])->name('admin.products.update');
		Route::post('products/{product}/delete', [AdminProductController::class, 'destroy'])->name('admin.products.delete');
		Route::get('reports/inventory', [AdminReportController::class, 'inventory'])->name('admin.reports.inventory');
		Route::get('stock-movements', [AdminStockMovementController::class, 'index'])->name('admin.stock-movements.index');
	});
});