<?php

use App\Domains\Admin\Controllers\ManagedTenantContactGetController;
use App\Domains\Admin\Controllers\ManagedTenantContactUpdateController;
use App\Domains\Admin\Controllers\ManagedTenantGdprGetController;
use App\Domains\Admin\Controllers\ManagedTenantGdprUpdateController;
use App\Domains\Admin\Controllers\ManagedTenantImpressGetController;
use App\Domains\Admin\Controllers\ManagedTenantImpressUpdateController;
use App\Domains\Admin\Controllers\ManagedTenantPaymentGetController;
use App\Domains\Admin\Controllers\ManagedTenantPaymentUpdateController;
use App\Domains\Admin\Controllers\ManagedTenantTaxGetController;
use App\Domains\Admin\Controllers\ManagedTenantTaxUpdateController;
use App\Domains\Admin\Controllers\TenantContactGetController;
use App\Domains\Admin\Controllers\TenantContactUpdateController;
use App\Domains\Admin\Controllers\TenantCreateController;
use App\Domains\Admin\Controllers\TenantGdprGetController;
use App\Domains\Admin\Controllers\TenantGdprUpdateController;
use App\Domains\Admin\Controllers\TenantGeneralGetController;
use App\Domains\Admin\Controllers\TenantGeneralUpdateController;
use App\Domains\Admin\Controllers\TenantImpressGetController;
use App\Domains\Admin\Controllers\TenantImpressUpdateController;
use App\Domains\Admin\Controllers\TenantListApiController;
use App\Domains\Admin\Controllers\TenantPaymentGetController;
use App\Domains\Admin\Controllers\TenantPaymentMethodsGetController;
use App\Domains\Admin\Controllers\TenantPaymentMethodsUpdateController;
use App\Domains\Admin\Controllers\TenantPaymentUpdateController;
use App\Domains\Admin\Controllers\TenantTaxGetController;
use App\Domains\Admin\Controllers\TenantTaxUpdateController;
use App\Domains\Admin\Controllers\UserDetailGetController;
use App\Domains\Admin\Controllers\UserListApiController;
use App\Domains\Admin\Controllers\UserResetPasswordController;
use App\Domains\Admin\Controllers\UserToggleActiveController;
use App\Domains\Admin\Controllers\UserUpdateController;
use App\Middleware\AdminRoleMiddleware;
use App\Middleware\IdentifyTenant;
use App\Middleware\LvOnlyMiddleware;
use Illuminate\Support\Facades\Route;

Route::middleware([IdentifyTenant::class, 'auth', AdminRoleMiddleware::class])->group(function () {
    Route::prefix('api/v1/admin/tenant')->group(function () {
        Route::get('/contact', TenantContactGetController::class);
        Route::post('/contact', TenantContactUpdateController::class);
        Route::get('/payment', TenantPaymentGetController::class);
        Route::post('/payment', TenantPaymentUpdateController::class);
        Route::get('/payment-methods', TenantPaymentMethodsGetController::class);
        Route::post('/payment-methods/{id}', TenantPaymentMethodsUpdateController::class);
        Route::get('/impress', TenantImpressGetController::class);
        Route::post('/impress', TenantImpressUpdateController::class);
        Route::get('/gdpr', TenantGdprGetController::class);
        Route::post('/gdpr', TenantGdprUpdateController::class);
        Route::get('/tax', TenantTaxGetController::class);
        Route::post('/tax', TenantTaxUpdateController::class);
    });

    Route::prefix('api/v1/admin/users')->group(function () {
        Route::get('/list', UserListApiController::class);
        Route::get('/{id}', UserDetailGetController::class);
        Route::post('/{id}', UserUpdateController::class);
        Route::post('/{id}/toggle-active', UserToggleActiveController::class);
        Route::post('/{id}/reset-password', UserResetPasswordController::class);
    });

    Route::middleware(LvOnlyMiddleware::class)->group(function () {
        Route::prefix('api/v1/admin/tenants')->group(function () {
            Route::get('/list', TenantListApiController::class);
            Route::post('/create', TenantCreateController::class);
            Route::prefix('/{slug}')->group(function () {
                Route::get('/general', TenantGeneralGetController::class);
                Route::post('/general', TenantGeneralUpdateController::class);
                Route::get('/contact', ManagedTenantContactGetController::class);
                Route::post('/contact', ManagedTenantContactUpdateController::class);
                Route::get('/payment', ManagedTenantPaymentGetController::class);
                Route::post('/payment', ManagedTenantPaymentUpdateController::class);
                Route::get('/impress', ManagedTenantImpressGetController::class);
                Route::post('/impress', ManagedTenantImpressUpdateController::class);
                Route::get('/gdpr', ManagedTenantGdprGetController::class);
                Route::post('/gdpr', ManagedTenantGdprUpdateController::class);
                Route::get('/tax', ManagedTenantTaxGetController::class);
                Route::post('/tax', ManagedTenantTaxUpdateController::class);
            });
        });
    });
});
