<?php

use App\Http\Controllers\Api\DashboardController;
use App\Http\Controllers\Api\DataSettingController;
use App\Http\Controllers\Api\GlobalSettingsController;
use App\Http\Controllers\Api\GoogleSheetController;
use App\Http\Controllers\Api\ImportDatasourceController;
use App\Http\Controllers\Api\MenusController;
use App\Http\Controllers\Api\PbgTaskController;
use App\Http\Controllers\Api\RequestAssignmentController;
use App\Http\Controllers\Api\RolesController;
use App\Http\Controllers\Api\ScrapingController;
use App\Http\Controllers\Api\UsersController;
use App\Http\Controllers\Settings\SyncronizeController;
use Illuminate\Support\Facades\Route;

Route::post('/login', [UsersController::class, 'login'])->name('api.user.login');
Route::group(['middleware' => 'auth:sanctum'], function (){
    // users
    Route::get('/users', [UsersController::class, 'index'])->name('users');
    Route::post('/logout', [UsersController::class, 'logout'])->name('api.user.logout');
    
    // global settings
    Route::apiResource('global-settings', GlobalSettingsController::class);

    // import datasource
    // Route::apiResource('import-datasource',ImportDatasourceController::class);
    Route::controller(ImportDatasourceController::class)->group(function (){
        Route::get('/import-datasource/check-datasource', 'checkImportDatasource')
        ->name('import-datasource.check');
        Route::get('/import-datasource', 'index')->name('import-datasource.index');
    });

    // request assignments
    Route::apiResource('request-assignments',RequestAssignmentController::class);

    // all dashboards
    Route::controller(DashboardController::class)->group(function(){
        Route::get('/business-documents','businnessDocument');
        Route::get('/non-business-documents','nonBusinnessDocument');
        Route::get('/all-task-documents', 'allTaskDocuments');
        Route::get('/pbg-task-documents', 'pbgTaskDocuments');
        Route::get('/verification-documents','verificationDocuments');
        Route::get('/non-verification-documents','nonVerificationDocuments');
    });

    // scraping
    Route::apiResource('/scraping', ScrapingController::class);

    // data-settings
    Route::apiResource('/api-data-settings', DataSettingController::class);

    Route::apiResource('/api-pbg-task', PbgTaskController::class);

    // sync pbg google sheet
    Route::get('/sync-pbg-task-google-sheet', [PbgTaskController::class, 'syncPbgFromGoogleSheet'])->name('pbg-task.sync-google-sheet');
    Route::apiResource('/api-google-sheet', GoogleSheetController::class);
    Route::get('/sync-task', [SyncronizeController::class, 'syncPbgTask'])->name('api.task');
    Route::get('/get-user-token', [SyncronizeController::class, 'getUserToken'])->name('api.task.token');
    Route::get('/get-index-integration-retribution/{uuid}', [SyncronizeController::class, 'syncIndexIntegration'])->name('api.task.inntegration');
    Route::get('/sync-task-submit/{uuid}', [SyncronizeController::class, 'syncTaskDetailSubmit'])->name('api.task.submit');

    // menus api
    Route::apiResource('api-menus', MenusController::class);

    // roles api
    Route::apiResource('api-roles', RolesController::class);
});


