<?php

declare(strict_types=1);

use Illuminate\Support\Facades\Route;
use ImovelZapAi\Analytics\Presentation\Http\Controllers\Api\AnalyticsController;

Route::middleware([
    'auth:sanctum',
    'tenant.resolve',
    'tenant.required',
    'tenant.active',
    'role:Admin|Gestor|Corretor',
])->prefix('analytics')->group(function (): void {
    Route::get('kpis', [AnalyticsController::class, 'kpis']);
    Route::get('funnel', [AnalyticsController::class, 'funnel']);
    Route::get('rankings', [AnalyticsController::class, 'rankings']);
    Route::get('dashboard', [AnalyticsController::class, 'dashboard']);
    Route::get('alerts', [AnalyticsController::class, 'alerts']);
    Route::get('widgets', [AnalyticsController::class, 'widgets']);
    Route::put('widgets', [AnalyticsController::class, 'updateWidgets']);
    Route::get('export', [AnalyticsController::class, 'export']);

    Route::middleware('role:Admin|Gestor')->group(function (): void {
        Route::post('alerts/{alertId}/ack', [AnalyticsController::class, 'ackAlert']);
    });
});
