<?php

use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\UserController;
use App\Http\Controllers\OrderController;
use App\Http\Controllers\ProductController;
use App\Http\Controllers\CategoryController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\PromoController;
use App\Http\Controllers\ReportController;

/*
|--------------------------------------------------------------------------
| 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('/', function () {
    return view('auth.login');
});

Route::prefix('admin')->group(function () {
    // dashborad
    Route::get('/', [DashboardController::class, 'index']);

    // user
    Route::get('/user', [UserController::class, 'index']);
    Route::post('/saveUser', [UserController::class, 'store']);
    Route::put('/user/{id}', [UserController::class, 'update']);
    Route::delete('/user/{id}', [UserController::class, 'destroy']);

    // product
    Route::get('/product', [ProductController::class, 'index']);
    Route::post('/saveProduct', [ProductController::class, 'store']);
    Route::put('/product/{id}', [ProductController::class, 'update']);
    Route::delete('/product/{id}', [ProductController::class, 'destroy']);

    // category
    Route::get('/category', [CategoryController::class, 'index']);
    Route::post('/saveCategory', [CategoryController::class, 'store']);
    Route::put('/category/{id}', [CategoryController::class, 'update']);
    Route::delete('/category/{id}', [CategoryController::class, 'destroy']);

    // order
    Route::get('/order', [OrderController::class, 'index']);
    Route::post('/saveOrder', [OrderController::class, 'store']);
    Route::put('/order/{id}', [OrderController::class, 'update']);
    Route::delete('/order/{id}', [OrderController::class, 'destroy']);

    //  report
    Route::get('/report', [ReportController::class, 'index']);
    Route::get('/ceklaporan/{tglMulai}/{tglSelesai}/{status}', [ReportController::class, 'cekLaporan']);
    Route::get('/laporan/cetak/{tglMulai}/{tglSelesai}/{status}', [ReportController::class, 'cetak']);
});
Auth::routes();

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