<?php

defined( 'ABSPATH' ) || exit;

use HelpGent\App\Http\Controllers\Admin\EmailThrottleController;
use HelpGent\App\Http\Controllers\Admin\PageController;
use HelpGent\App\Http\Controllers\Admin\SettingsController;
use HelpGent\App\Http\Controllers\Admin\UserController;
use HelpGent\App\Http\Controllers\Admin\FormController;
use HelpGent\App\Http\Controllers\NoticeController;
use HelpGent\App\Http\Controllers\ChatMessageController;
use HelpGent\App\Http\Controllers\ChatMemberController;
use HelpGent\WpMVC\Routing\Route;

Route::group(
    'admin', function () {
        Route::get( 'settings', [SettingsController::class, 'index'] );
        Route::post( 'settings', [SettingsController::class, 'update'] );
        Route::get( 'page', [PageController::class, 'index'] );
        Route::get( 'page-with-homepage', [PageController::class, 'index_with_homepage'] );
        Route::get( 'email-throttle', [EmailThrottleController::class, 'index'] );
        Route::post( 'email-throttle/reset', [EmailThrottleController::class, 'reset'] );
        Route::post( 'close-old-pro-removed-notice', [NoticeController::class, 'close_old_pro_removed_notice'] );

        Route::group(
            'users', function() {
                Route::get( '/', [UserController::class, 'users'] );
                Route::post( 'export', [UserController::class, 'export_users'] );
            }
        );

        Route::group(
            'chat-message', function() {
                Route::get( 'unread-count', [ ChatMessageController::class, 'admin_chat_unread_count' ] );
                Route::get( 'reviews', [ ChatMessageController::class, 'reviews' ] );
            },
        );

        Route::group(
            'form', function() {                
                Route::delete( 'remove-last-access-lock', [ FormController::class, 'remove_last_access_lock' ] );
                Route::post( 'take-over-access-lock', [ FormController::class, 'take_over_access_lock' ] );
                Route::delete( 'remove-all-access-lock', [ FormController::class, 'remove_current_user_all_access_lock' ] );
            },
        );
    }, ['admin']
);

Route::group(
    'chat-message', function() {
        Route::get( 'response-ids', [ ChatMemberController::class, 'get_member_response_ids' ] );
    },
    ['user']
);