<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Buyer\OrderController;
use App\Http\Controllers\Buyer\FavoriteController;
use App\Http\Controllers\Buyer\BuyerDashboardController;
use App\Http\Controllers\Buyer\AddressController; // <-- ADD IMPORT

Route::prefix('dashboard/buyer')->group(function () {
    Route::get('/', [BuyerDashboardController::class, 'index'])->name('dashboard.buyer');
    
    Route::get('/orders', [OrderController::class, 'index'])->name('buyer.orders.index');
    Route::put('/orders/{order}', [OrderController::class, 'updateStatus'])->name('buyer.orders.update');
    Route::post('/orders/{order}/request-refund', [OrderController::class, 'requestRefund'])->name('buyer.orders.refund');
    
    Route::get('/favorites', [FavoriteController::class, 'index'])->name('buyer.favorites.index');
    Route::post('/favorites/{product}/toggle', [FavoriteController::class, 'toggle'])->name('buyer.favorites.toggle');

    // --- NEW: ADDRESS BOOK ROUTES ---
    Route::get('/addresses', [AddressController::class, 'index'])->name('buyer.addresses.index');
    Route::post('/addresses', [AddressController::class, 'store'])->name('buyer.addresses.store');
    Route::put('/addresses/{address}', [AddressController::class, 'update'])->name('buyer.addresses.update');
    Route::delete('/addresses/{address}', [AddressController::class, 'destroy'])->name('buyer.addresses.destroy');
    Route::post('/addresses/{address}/default', [AddressController::class, 'setDefault'])->name('buyer.addresses.default');
});