<?php

use App\Http\Controllers\HitungController;
use App\Http\Controllers\PenjualanController;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\ProdukController;
use App\Http\Controllers\UserController;
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::middleware(['auth', 'level'])->group(
    function () {
        Route::get('/', [HomeController::class, 'show'])->name('home')->middleware('auth');
        Route::get('/home', [HomeController::class, 'show'])->name('home')->middleware('auth');

        Route::get('/produk/cetak', [ProdukController::class, 'cetak'])->name('produk.cetak');
        Route::resource('/produk', ProdukController::class);
        Route::get('/penjualan/cetak', [PenjualanController::class, 'cetak'])->name('penjualan.cetak');
        Route::resource('/penjualan', PenjualanController::class);

        Route::get('hitung', [HitungController::class, 'index'])->name('hitung.index');
        Route::post('hitung', [HitungController::class, 'detail'])->name('hitung.detail');
        Route::get('hitung/detail', [HitungController::class, 'detail'])->name('hitung.detail');
        Route::get('hitung/cetakDetail', [HitungController::class, 'cetakdetail'])->name('hitung.cetakDetail');
        Route::get('hitung/cetak', [HitungController::class, 'cetak'])->name('hitung.cetak');
        Route::get('hitung/hasil', [HitungController::class, 'hasil'])->name('hitung.hasil');
        Route::get('hitung/hasil/cetak', [HitungController::class, 'hasilCetak'])->name('hitung.hasil.cetak');
        Route::get('hitung/hasilHitung', [HitungController::class, 'hasilHitung'])->name('hitung.hasilHitung');
        Route::get('/user/profil', [UserController::class, 'profil'])->name('user.profil');
        Route::post('/user/profil', [UserController::class, 'profilUpdate'])->name('user.profil.update');
        Route::get('/user/password', [UserController::class, 'password'])->name('user.password');
        Route::post('/user/password', [UserController::class, 'passwordUpdate'])->name('user.password.update');
        Route::get('/user/logout', [UserController::class, 'logout'])->name('user.logout');

        Route::get('/user/cetak', [UserController::class, 'cetak'])->name('user.cetak');
        Route::resource('user', UserController::class);
    }
);
Route::get('/login', [UserController::class, 'loginForm'])->name('login');
Route::post('/login', [UserController::class, 'loginAction'])->name('login.action');

Route::get('/register', [UserController::class, 'register'])->name('user.register');
Route::post('/register', [UserController::class, 'registerForm'])->name('user.registerForm');
