<?php

use Illuminate\Support\Facades\Route;

/** @var \Laravel\Lumen\Routing\Router $router */


/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/

Route::group([
    'prefix' => 'admin'

], function ($router) {

    Route::post('login', 'Admin\AuthController@login');
    Route::post('logout', 'Admin\AuthController@logout');
});

Route::group([

    'middleware' => 'auth:admin',
    'prefix' => 'admin'

], function ($router) {

    Route::get('refresh', 'Admin\AuthController@refresh');
    Route::post('me', 'Admin\AuthController@me');

});

Route::group([

    'middleware' => 'auth:admin',
    'prefix' => 'admin',

], function ($router) {

    Route::get('users', 'Admin\UserController@index');
    Route::get('users_inactive', 'Admin\UserController@inactiveUsers');
    Route::get('users/{id}', 'Admin\UserController@show');
    Route::put('users', 'Admin\UserController@create');
    Route::put('users/{id}', 'Admin\UserController@edit');
    Route::delete('users/{id}', 'Admin\UserController@delete');

    Route::post('activateUsers', 'Admin\UserController@activateUsers');
    Route::post('activatePN', 'Admin\ProductController@activatePN');

    Route::get('documents', 'Admin\FileController@index');
    Route::get('documents/folder/{id}', 'Admin\FileController@showById');
    Route::post('documents/show', 'Admin\FileController@show');
    Route::post('documents/delete', 'Admin\FileController@delete');
    Route::delete('documents/folder/{id}', 'Admin\FileController@deleteFolder');
    Route::post('documents/upload', 'Admin\FileController@upload');
    Route::post('documents/download', 'Admin\FileController@download');
    Route::post('documents/editLabelAndPN', 'Admin\FileController@editLabelAndPN');

    Route::get('companies', 'Admin\CompanyController@index');
    Route::get('companies/{id}', 'Admin\CompanyController@show');
    Route::post('companies/find', 'Admin\CompanyController@getCompanyByName');
    Route::put('companies', 'Admin\CompanyController@create');
    Route::put('companies/{id}', 'Admin\CompanyController@edit');
    Route::delete('companies/{id}', 'Admin\CompanyController@delete');
    Route::post('companies/link', 'Admin\CompanyController@linkUser');
    Route::post('companies/unlink', 'Admin\CompanyController@unlinkUser');
    Route::post('companies/allInactivePn', 'Admin\CompanyController@allInactivePn');
    
    Route::post('products/countInactivePn', 'Admin\ProductController@countInactivePn');
    Route::post('companies/validate', 'Admin\CompanyController@validateCompany');

    Route::delete('cabins/{id}', 'Admin\CabinController@delete');
    Route::delete('products/{id}', 'Admin\ProductController@delete');

    Route::get('notifications', 'Admin\NotificationsController@index');
    Route::post('notifications/mark-read/{id}', 'Admin\NotificationsController@markRead');
    Route::post('notifications/mark-unread/{id}', 'Admin\NotificationsController@markUnread');
    Route::post('notifications/mark-all', 'Admin\NotificationsController@markAll');

    Route::post('s3sync', 'Admin\FileController@S3_force_sync');
    Route::post('s3syncApply', 'Admin\FileController@S3_apply_force_sync_result');

    Route::post('s3check', 'Admin\FileController@S3_check_path');
    Route::post('s3updateToLocal', 'Admin\FileController@S3_to_local_update');
    Route::post('s3uploadToLocal', 'Admin\FileController@S3_to_local_upload');
    Route::post('s3deleteToLocal', 'Admin\FileController@S3_to_local_delete');

    Route::post('listAllRatings', 'RatingController@listAll');
    Route::post('exportRatings', 'RatingController@export');

    Route::post('latestReview', 'RatingController@latestReview');
    Route::post('lastNotification', 'Admin\NotificationsController@lastNotification');
    Route::post('toggleActiveProduct', 'Admin\CompanyController@toggleActiveProduct');


});

Route::group([
    'prefix' => 'api'

], function ($router) {

    Route::post('login', 'AuthController@login');
    Route::post('logout', 'AuthController@logout');
    Route::post('register', 'Admin\AuthController@register');
    Route::post('save_ratings', 'RatingController@save');
    Route::get('exportRatings', 'RatingController@export');

    Route::get('companies/exportInactivePn', 'Admin\CompanyController@exportInactivePN');
    Route::get('companies/exportCustomersAndFiles', 'Admin\CompanyController@exportCustomersAndFiles');


    Route::post('resetpassword', 'Admin\AuthController@generateResetToken');
    Route::post('renew_expired_user', 'Admin\UserController@renewExpiredUser');

    # Route::post('/password/email', 'PasswordController@postEmail');
    # Route::post('/password/reset/{token}', 'PasswordController@postReset');

    # Route::get('forget-password', 'Admin\PasswordResetController@showForgetPasswordForm');
    Route::post('forget-password', 'Admin\PasswordResetController@submitForgetPasswordForm'); 
    # Route::get('reset-password/{token}', ['as' => 'api.reset.password.get', 'uses' => 'Admin\PasswordResetController@showResetPasswordForm']);
    Route::post('reset-password', ['as' => 'reset.password.post', 'uses' => 'Admin\PasswordResetController@submitResetPasswordForm']);


});

Route::group([

    'middleware' => 'auth:api',
    'prefix' => 'api'

], function ($router) {

    Route::get('refresh', 'AuthController@refresh');
    Route::post('me', 'AuthController@me');

    Route::get('documents', 'FileController@index');
    Route::get('documents/folder/{id}', 'FileController@showById');
    Route::post('documents/download', 'FileController@download');

    Route::get('company', 'CompanyController@show');
    Route::put('company', 'CompanyController@edit');

    Route::delete('cabins/{id}', 'CabinController@delete');
    Route::delete('products/{id}', 'ProductController@delete');
    Route::put('products/{id}', 'ProductController@update');

    Route::put('me', 'UserController@edit');

    Route::get('notifications', 'NotificationsController@index');
    Route::post('notifications/mark-read/{id}', 'NotificationsController@markRead');
    Route::post('notifications/mark-unread/{id}', 'NotificationsController@markUnread');
    Route::post('notifications/user-mark-all', 'NotificationsController@markAll');


});


