<?php

use Illuminate\Support\Facades\Route;
use Wave\Http\Controllers\User\DashboardController;
use Wave\Http\Controllers\User\GeneralInformationController;
use Wave\Http\Controllers\User\BookKeepingController;

Route::post('login', '\Wave\Http\Controllers\API\AuthController@login');
Route::post('register', '\Wave\Http\Controllers\API\AuthController@register');
Route::post('register/get-roles', '\Wave\Http\Controllers\API\AuthController@getRoles');
Route::post('logout', '\Wave\Http\Controllers\API\AuthController@logout');
Route::post('refresh', '\Wave\Http\Controllers\API\AuthController@refresh');
Route::post('token', '\Wave\Http\Controllers\API\AuthController@token');
Route::get('get-terms-and-conditions', '\Wave\Http\Controllers\API\TermsAndConditionsController@index');
Route::get('get-privacy-policy', '\Wave\Http\Controllers\API\PrivacyPolicyController@index');
Route::post('/upload-file', '\Wave\Http\Controllers\API\FileController@storeFile');

Route::group(['prefix' => 'forgot-password'], function () {
    Route::post('/send-otp', '\Wave\Http\Controllers\API\ForgotPasswordController@sendOtp');
    Route::post('/submit-otp', '\Wave\Http\Controllers\API\ForgotPasswordController@submitOtp');
    Route::post('/reset-password', '\Wave\Http\Controllers\API\ForgotPasswordController@resetPassword');
});

Route::group(['middleware' => 'auth:api'], function () {
    Route::group(['prefix' => 'settings'], function () {
        Route::post('/change-password', '\Wave\Http\Controllers\API\SettingsController@changePassword');
        Route::get('/get-notification-settings', '\Wave\Http\Controllers\API\SettingsController@getNotificationSettings');
        Route::post('/toggle-notification-status', '\Wave\Http\Controllers\API\SettingsController@toggleNotificationStatus');
    });

    Route::group(['prefix' => 'chats'], function () {
        Route::post('/get-messages', '\Wave\Http\Controllers\API\ChatController@getChatMessages');
        Route::post('/send-message', '\Wave\Http\Controllers\API\ChatController@sendChat');
    });

    Route::group(['prefix' => 'users'], function(){
        Route::get('/list', [DashboardController::class, 'getUserList']);
        Route::get('/data/{user_id}', [DashboardController::class, 'getUserData']);
        Route::get('/role/list', [DashboardController::class, 'getCompanyUserRoles']);
        Route::post('/create', [DashboardController::class, 'createUser']);
        Route::post('/update', [DashboardController::class, 'updateUser']);
        Route::post('/delete', [DashboardController::class, 'deleteUser']);
        Route::get('/access/logs', [DashboardController::class, 'getCompanyUsersAccessLogs']);
        Route::get('/permission/group', [DashboardController::class, 'getPermissionGroup']);
        Route::get('/role/permission/{role_id}', [DashboardController::class, 'getPermissionOfRole']);
        Route::post('/role/add/permission', [DashboardController::class, 'addPermissionToRole']);
        Route::post('/role/remove/permission', [DashboardController::class, 'removePermissionToRole']);
        Route::post('/role/has/permission', [DashboardController::class, 'roleHasPermission']);
    });

    Route::group(['prefix' => 'company'], function(){
        Route::get('/details', [GeneralInformationController::class, 'getCompanyDetails']);
        Route::post('/save/details', [GeneralInformationController::class, 'saveCompanyDetails']);
        Route::post('/save/member', [GeneralInformationController::class, 'updateCompanyMember']);
        Route::post('/delete/member/file', [GeneralInformationController::class, 'deleteMemberDocument']);
    });

    Route::group(['prefix' => 'bookkeeping'], function(){
        Route::get('/document/list', [BookKeepingController::class, 'getDocumentList']);
        Route::get('/document/categories', [BookKeepingController::class, 'getDocumentCategories']);
        Route::get('/document/{document_id}', [BookKeepingController::class, 'viewBookkeepingDocument']);
        Route::post('/add/document', [BookKeepingController::class, 'addBookkeepingDocument']);
        Route::post('/document/library', [BookKeepingController::class, 'getDocumentLibrary']);
    });
});


// BROWSE
Route::get('/{datatype}', '\Wave\Http\Controllers\API\ApiController@browse');

// READ
Route::get('/{datatype}/{id}', '\Wave\Http\Controllers\API\ApiController@read');

// EDIT
Route::put('/{datatype}/{id}', '\Wave\Http\Controllers\API\ApiController@edit');

// ADD
Route::post('/{datatype}', '\Wave\Http\Controllers\API\ApiController@add');

// DELETE
Route::delete('/{datatype}/{id}', '\Wave\Http\Controllers\API\ApiController@delete');
