<?php

use App\Http\Controllers\Admin\AdminCarController;
use App\Http\Controllers\Admin\AdminCarOrderController;
use Illuminate\Support\Facades\Route;

// Admin Car Dealership Routes
Route::middleware(['isadmin', '2fa'])->prefix('admin')->group(function () {

    // Car Management
    Route::prefix('dashboard/cars')->name('admin.cars.')->group(function () {
        Route::get('/', [AdminCarController::class, 'index'])->name('index');
        Route::get('/create', [AdminCarController::class, 'create'])->name('create');
        Route::post('/', [AdminCarController::class, 'store'])->name('store');
        Route::get('/{car}', [AdminCarController::class, 'show'])->name('show');
        Route::get('/{car}/edit', [AdminCarController::class, 'edit'])->name('edit');
        Route::put('/{car}', [AdminCarController::class, 'update'])->name('update');
        Route::delete('/{car}', [AdminCarController::class, 'destroy'])->name('destroy');
        Route::post('/{car}/toggle-status', [AdminCarController::class, 'toggleStatus'])->name('toggle-status');
        Route::delete('/photos/{photo}', [AdminCarController::class, 'deletePhoto'])->name('delete-photo');
    });

    // Car Order Management
    Route::prefix('dashboard/car-orders')->name('admin.car-orders.')->group(function () {
        Route::get('/', [AdminCarOrderController::class, 'index'])->name('index');
        Route::get('/{order}', [AdminCarOrderController::class, 'show'])->name('show');
        Route::put('/{order}/status', [AdminCarOrderController::class, 'updateStatus'])->name('update-status');
        Route::post('/{order}/tracking', [AdminCarOrderController::class, 'addTrackingUpdate'])->name('add-tracking');
        Route::post('/{order}/verify-payment', [AdminCarOrderController::class, 'verifyPayment'])->name('verify-payment');
        Route::post('/{order}/cancel', [AdminCarOrderController::class, 'cancel'])->name('cancel');
        Route::post('/{order}/refund', [AdminCarOrderController::class, 'refund'])->name('refund');
        Route::delete('/{order}', [AdminCarOrderController::class, 'destroy'])->name('destroy');
    });
});
