<?php

use App\Modules\CRM\Controllers\LeadController;
use Illuminate\Support\Facades\Route;

Route::middleware(['auth:sanctum', 'tenant', 'feature:crm'])->group(function (): void {
    Route::middleware('company.permission:crm.view')->group(function (): void {
        Route::get('/crm/summary', [LeadController::class, 'summary']);
        Route::get('/crm/leads', [LeadController::class, 'index']);
    });

    Route::middleware('company.permission:crm.manage')->group(function (): void {
        Route::post('/crm/leads', [LeadController::class, 'store']);
        Route::patch('/crm/leads/{lead}', [LeadController::class, 'update']);
        Route::post('/crm/leads/{lead}/activities', [LeadController::class, 'storeActivity']);
        Route::post('/crm/leads/{lead}/convert', [LeadController::class, 'convertToCustomer']);
    });
});
