<?php

use App\Mail\TempMail;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::prefix('auth')->group(function () {
    Route::post('login', [\App\Http\Controllers\Auth\AuthController::class, 'login']);
    Route::post('/forgot-password', \App\Http\Controllers\Auth\ForgotPasswordController::class);
    Route::post('/reset-password', \App\Http\Controllers\Auth\ResetPasswordController::class);
});

/* --- Routes verified --- */
Route::middleware(['auth:sanctum', 'ability:Client', 'verified'])->group(function () {
    Route::post('pld', [\App\Http\Controllers\PldController::class, 'index']);

    Route::post('units', [\App\Http\Controllers\ClientController::class, 'index']);


    Route::get('download', [\App\Http\Controllers\InfoSectorialController::class, 'download']);
});

/* --- Routes Admin --- */
Route::middleware(['auth:sanctum', 'ability:Admin'])->group(function () {
    Route::apiResource('user', \App\Http\Controllers\UserController::class);

    Route::put('notification/{notification}', [\App\Http\Controllers\NotificationController::class, 'update']);
    Route::post('notification', [\App\Http\Controllers\NotificationController::class, 'store']);
    Route::delete('notification/{notification}', [\App\Http\Controllers\NotificationController::class, 'destroy']);

    Route::put('faq/{faq}', [\App\Http\Controllers\FaqController::class, 'update']);
    Route::post('faq', [\App\Http\Controllers\FaqController::class, 'store']);
    Route::delete('faq/{faq}', [\App\Http\Controllers\FaqController::class, 'destroy']);

    Route::post('updateFile', [\App\Http\Controllers\InfoSectorialController::class, 'updateFile']);

    Route::post('aboutUs', [\App\Http\Controllers\AboutUsController::class, 'store']);

    Route::post('sendFile', [\App\Http\Controllers\FileController::class, 'store']);
});

/* --- Routes Client --- */
Route::middleware(['auth:sanctum', 'ability:Client'])->group(function () {
    Route::post('pld/overview', [\App\Http\Controllers\PldController::class, 'overviewByRegion']); //Visão Geral por Região
    Route::post('pld/list', [\App\Http\Controllers\PldController::class, 'listConsumption']); // Tabela de Consumo
    Route::post('pld/daily', [\App\Http\Controllers\PldController::class, 'consumptionByDaily']); // Consumo por Diário
    Route::post('pld/schedule', [\App\Http\Controllers\PldController::class, 'consumptionBySchedule']); // Consumo por Horários

    Route::post('economy', [\App\Http\Controllers\EconomyController::class, 'index']);
    Route::post('economy/grossAnnual', [\App\Http\Controllers\EconomyController::class, 'grossAnnualEconomy']);
    Route::post('economy/grossMonthly', [\App\Http\Controllers\EconomyController::class, 'grossMonthlyEconomy']);
    Route::post('economy/estimates', [\App\Http\Controllers\EconomyController::class, 'captiveMonthlyEconomy']);
    Route::post('economy/MWh', [\App\Http\Controllers\EconomyController::class, 'costMWhEconomy']);

    Route::post('telemetry/powerFactor', [\App\Http\Controllers\TelemetryController::class, 'discretization']);
    Route::post('telemetry/demand', [\App\Http\Controllers\TelemetryController::class, 'discretization']);
    Route::post('telemetry/discretization', [\App\Http\Controllers\TelemetryController::class, 'discretization']);

    Route::get('telemetry/download', [\App\Http\Controllers\TelemetryController::class, 'download']);

    Route::post('operation/summary', [\App\Http\Controllers\OperationSummaryController::class, 'operationSummary']); // Resumo Operações
    Route::post('operation', [\App\Http\Controllers\OperationSummaryController::class, 'index']);

    Route::post('notify', [\App\Http\Controllers\NotificationController::class, 'notify']);

    Route::get('news', [\App\Http\Controllers\NewsController::class, 'send']);
});

/* --- Routes Admin and Client --- */
Route::middleware(['auth:sanctum', 'ability:Admin,Client'])->group(function () {
    Route::get('aboutUs', [\App\Http\Controllers\AboutUsController::class, 'index']);

    Route::get('faq', [\App\Http\Controllers\FaqController::class, 'index']);
    Route::get('faq/{faq}', [\App\Http\Controllers\FaqController::class, 'show']);

    Route::get('notification', [\App\Http\Controllers\NotificationController::class, 'index']);
    Route::get('notification/{notification}', [\App\Http\Controllers\NotificationController::class, 'show']);

    Route::post('auth/logout', [\App\Http\Controllers\Auth\AuthController::class, 'logout']);
});

Route::post('import', [\App\Http\Controllers\UserController::class, 'importUserControll']);
