<?php

declare(strict_types=1);

use Illuminate\Support\Facades\Route;
use ImovelZapAi\Conversations\Infrastructure\Http\Controllers\Web\HandoffQueueController;
use ImovelZapAi\Conversations\Infrastructure\Http\Controllers\Web\PeopleController;
use ImovelZapAi\Conversations\Infrastructure\Http\Controllers\Web\WhatsAppSettingsController;

Route::middleware(['auth', 'tenant.resolve', 'tenant.required', 'tenant.active', 'role:Admin|Gestor|Corretor'])
    ->group(function (): void {
        Route::get('whatsapp', [WhatsAppSettingsController::class, 'index'])->name('whatsapp.settings');
        Route::post('whatsapp/conectar', [WhatsAppSettingsController::class, 'connect'])->name('whatsapp.connect');
        Route::post('whatsapp/desconectar', [WhatsAppSettingsController::class, 'disconnect'])->name('whatsapp.disconnect');
        Route::post('whatsapp/automacao', [WhatsAppSettingsController::class, 'updateAutomation'])->name('whatsapp.automation');
        Route::get('whatsapp/status', [WhatsAppSettingsController::class, 'status'])->name('whatsapp.status');

        Route::get('pessoas/caixa', [PeopleController::class, 'inbox'])->name('people.inbox');
        Route::get('pessoas', [PeopleController::class, 'index'])->name('people.index');
        Route::get('pessoas/{contact}', [PeopleController::class, 'show'])->name('people.show');
        Route::post('pessoas/{contact}/responder', [PeopleController::class, 'reply'])->name('people.reply');
        Route::post('pessoas/{contact}/sugerir-resposta', [PeopleController::class, 'suggestReply'])->name('people.suggest-reply');
        Route::post('pessoas/{contact}/notas', [PeopleController::class, 'storeNote'])->name('people.notes.store');
        Route::delete('pessoas/{contact}/notas/{note}', [PeopleController::class, 'destroyNote'])->name('people.notes.destroy');
        Route::post('pessoas/handoff/{handoff}/assumir', [PeopleController::class, 'claim'])->name('people.claim');
        Route::post('pessoas/interesse/{interest}/estagio', [PeopleController::class, 'closeInterest'])->name('people.interest.stage');

        Route::get('atendimento/fila', [HandoffQueueController::class, 'index'])->name('handoff.queue');
        Route::post('atendimento/fila/{handoff}/assumir', [PeopleController::class, 'claim'])->name('handoff.claim');
    });
