<?php

declare(strict_types=1);

use Illuminate\Support\Facades\Route;
use ImovelZapAi\Publishing\Presentation\Http\Controllers\Web\PropertyPublicationController;
use ImovelZapAi\Publishing\Presentation\Http\Controllers\Web\PropertyXmlExportController;
use ImovelZapAi\Publishing\Presentation\Http\Controllers\Web\PublicationCenterController;
use ImovelZapAi\Publishing\Presentation\Http\Controllers\Web\TenantPublishingConfigurationController;

Route::middleware(['auth', 'tenant.resolve', 'tenant.required', 'tenant.active', 'role:Admin|Gestor|Corretor'])
    ->group(function (): void {
        Route::get('publicacao', [PublicationCenterController::class, 'index'])
            ->name('publishing.center');

        Route::get('publicacao/configuracao', [TenantPublishingConfigurationController::class, 'edit'])
            ->name('publishing.config.edit');

        Route::put('publicacao/configuracao', [TenantPublishingConfigurationController::class, 'update'])
            ->name('publishing.config.update');

        Route::get('imoveis/{property}/exportacao.xml', [PropertyXmlExportController::class, 'show'])
            ->name('publishing.xml.export');

        Route::post('imoveis/{property}/publicacoes/{publisher}/publicar', [PropertyPublicationController::class, 'publish'])
            ->name('publishing.channels.publish');

        Route::post('imoveis/{property}/publicacoes/sincronizar', [PropertyPublicationController::class, 'sync'])
            ->name('publishing.channels.sync');
    });
