<?php

declare(strict_types=1);

use Illuminate\Support\Facades\Route;
use Maestro\Core\Modules\Customers\Http\Controllers\AddressController;
use Maestro\Core\Modules\Customers\Http\Controllers\ContactController;
use Maestro\Core\Modules\Customers\Http\Controllers\CustomerController;

Route::middleware(['web', 'auth:sanctum'])
    ->prefix('api/customers')
    ->group(function () {
        Route::get('/', [CustomerController::class, 'index']);
        Route::post('/', [CustomerController::class, 'store']);

        Route::get('/{customer}/contacts', [ContactController::class, 'index']);
        Route::post('/{customer}/contacts', [ContactController::class, 'store']);
        Route::patch('/{customer}/contacts/{contact}', [ContactController::class, 'update']);
        Route::delete('/{customer}/contacts/{contact}', [ContactController::class, 'destroy']);

        Route::get('/{customer}/addresses', [AddressController::class, 'index']);
        Route::post('/{customer}/addresses', [AddressController::class, 'store']);
        Route::patch('/{customer}/addresses/{address}', [AddressController::class, 'update']);
        Route::delete('/{customer}/addresses/{address}', [AddressController::class, 'destroy']);

        Route::get('/{customer}', [CustomerController::class, 'show']);
        Route::patch('/{customer}', [CustomerController::class, 'update']);
        Route::delete('/{customer}', [CustomerController::class, 'destroy']);
    });
