<?php

use App\Http\Controllers\Auth\AuthController;
use App\Http\Controllers\Auth\ForgotPasswordController;
use App\Http\Controllers\BitacoraController;
use App\Http\Controllers\Conservation\ConversationController;
use App\Http\Controllers\Opportunity\OpportunityController;
use App\Http\Controllers\Customer\CustomerController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\ExampleController;
use App\Http\Controllers\Opportunity\ActivityController;
use App\Http\Controllers\Opportunity\ProcessController;
use App\Http\Controllers\Opportunity\StageController;
use App\Http\Controllers\Quote\QuoteController;
use App\Http\Controllers\Realty\ProjectController;
use App\Http\Controllers\Realty\PropertyController;
use App\Http\Controllers\Sales\PaymetPlanController;
use App\Http\Controllers\Sales\SalesController;
use App\Http\Controllers\SystemLogController;
use App\Http\Controllers\User\UserController;
use Illuminate\Http\Request;
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 and all of them will
| be assigned to the "api" middleware group. Make something great!
|
*/

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});

Route::group(['prefix' => 'authen'], function () {
    Route::post('login', [AuthController::class, 'login']);
    Route::post('logout', [AuthController::class, 'logout']);
    // Route::post('forgot-password', [ForgotPasswordController::class, 'sendResetLinkEmail']);
    // Route::put('reset-password', [ForgotPasswordController::class, 'resetPassword']);
    // Route::get('verify-token/{token}/{email}', [ForgotPasswordController::class, 'verifyTokenResetPassword']);
});
Route::get('/example', [ExampleController::class, 'example']);



/* ----------- RUTAS DE LA INTELIGENCIA ARTIFICIAL---------------------*/
Route::post('/activity', [ActivityController::class, 'register']);
Route::patch('/opportunity/convert-prospect/{id}', [OpportunityController::class, 'convert_opportunity_prospect']);
Route::get('/customer/get-customer-phone', [CustomerController::class, 'get_customer_by_phone']);
Route::post('/customer/register', [CustomerController::class, 'register_customer']);
Route::post('/customer/register/prospect', [CustomerController::class, 'register_customer_like_prospect']);

Route::post('/conversation/register', [ConversationController::class, 'register_conversation']);
Route::get('/conversation/get-conversation-phone/{phone}', [ConversationController::class, 'get_conversation_phone']);
Route::patch('/conversation/update/{phone}/{thread_id}', [ConversationController::class, 'udpdateThread']);

Route::group(['middleware' => ['api', 'jwt.auth']], function () {
    Route::put('/change_password', [ForgotPasswordController::class, 'changePassword']);
    //user
    Route::post('/user', [UserController::class, 'register']);
    Route::post('/user/{id}/rol', [UserController::class, 'update_rol']);
    Route::put('/user/{id}', [UserController::class, 'update_user']);
    Route::get('/user/{id}', [UserController::class, 'get_user']);
    Route::get('/users', [UserController::class, 'list_user_pagination']);
    Route::get('/roles', [UserController::class, 'all_roles']);

    Route::get('/customer/get-customer/{id}', [CustomerController::class, 'get_customer']);
    // Route::get('/customer/perfil/{id}', [CustomerController::class, 'get_perfil_customer']);



    Route::put('/customer/update/{id}', [CustomerController::class, 'update_customer']);
    Route::get('/customer/list-paginated', [CustomerController::class, 'list_customer_paginate']);

    Route::post('/opportunity/register', [OpportunityController::class, 'register_new_Opportunity']);
    Route::get('/opportunity/list-paginated', [OpportunityController::class, 'list_oportunity_paginate']);
    Route::get('/opportunity/get-opportunity/{id}', [OpportunityController::class, 'get_opportunity']);
    Route::patch('/opportunity/update/{id}', [OpportunityController::class, 'update_opportunity']);
    Route::get('/opportunity/kanban/{user_id}', [OpportunityController::class, 'oportunity_kanban_user']);



    Route::get('/conversations/list-paginated', [ConversationController::class, 'list_conversation_paginate']);
    Route::patch('/conversations/update-status/{id}/{status}', [ConversationController::class, 'edit_status_conversation']);
    //project
    Route::post('/project', [ProjectController::class, 'register']);
    Route::put('/project/{id}', [ProjectController::class, 'update']);
    Route::get('/project/{id}', [ProjectController::class, 'get']);
    Route::get('/projects', [ProjectController::class, 'list_project_pagination']);
    Route::get('/projects/combo', [ProjectController::class, 'all_projects']);
    Route::get('/project/{id}/properties', [PropertyController::class, 'list_Property_to_project']);


    Route::post('/property', [PropertyController::class, 'register']);
    Route::get('/property/{id}', [PropertyController::class, 'get']);
    Route::patch('/property/{id}', [PropertyController::class, 'updateProperty']);
    Route::get('/properties', [PropertyController::class, 'list_Property_pagination']);
    Route::get('/properties/{type}', [PropertyController::class, 'list_Property_type']);
    Route::get('/available/properties', [PropertyController::class, 'properties_available']);

    Route::get('/typeActivities', [ActivityController::class, 'all_type_activity']);

    Route::get('/activity/{id}', [ActivityController::class, 'get']);
    Route::patch('/activity/{id}', [ActivityController::class, 'update']);
    Route::get('/activity/asesor/{id}/fecha-past', [ActivityController::class, 'get_by_past_date']);
    Route::get('/activity/asesor/{id}/fecha-future', [ActivityController::class, 'get_by_future_date']);
    Route::get('/activity/oportunity/{oportunityId}/asesor/{asesorId}', [ActivityController::class, 'get_by_oportunity_user']);
    Route::get('/activity/asesor/{asesorId}/fecha', [ActivityController::class, 'get_by_fecha_asesor']);
    Route::get('/activity/asesor/{asesorId}/fecha-rango', [ActivityController::class, 'get_by_rango_fecha_asesor']);
    Route::patch('/activity/{id}/change_status', [ActivityController::class, 'change_status']);
    Route::patch('/activity/{id}/change_status_activity', [ActivityController::class, 'change_status_activity']);

    // Route::patch('/activity/{id}/complete', [ActivityController::class, 'complete']);
    Route::patch('/activity/{id}/discard', [ActivityController::class, 'discard']);

    Route::post('/sale', [SalesController::class, 'register']);
    Route::post('/sale/changeStage', [SalesController::class, 'register_changeStage']);

    Route::patch('/sale/{id}/status', [SalesController::class, 'change_status']);
    Route::patch('/sale/{id}/status/signature', [SalesController::class, 'change_status_confirmation_signature']);
    Route::patch('/sale/{id}/discard', [SalesController::class, 'discard_sale']);

    Route::patch('/sale/{id}', [SalesController::class, 'update']);
    Route::get('/sale/{id}', [SalesController::class, 'get']);
    Route::get('/sales/list-paginated', [SalesController::class, 'list_sales_paginate']);
    Route::get('/sale/opportunity/{id}', [SalesController::class, 'get_by_opportunity']);


    Route::get('/opportunity/{opportunity_id}/stage/{stage_id}', [ProcessController::class, 'get_by_opportunity_stage']);
    Route::patch('/opportunity/{opportunity_id}/procedure/{procedure_id}', [ProcessController::class, 'update_procedure_opportunities']);
    Route::patch('/opportunity/{opportunity_id}/stage/{stage_id}', [StageController::class, 'change_Stage']);

    Route::post('/quote/register', [QuoteController::class, 'register_quote']);
    Route::patch('/quote/{id}/change_status', [QuoteController::class, 'change_status']);
    Route::patch('/quote/{id}/change_status_customer', [QuoteController::class, 'change_status_customer']);

    Route::get('/quote/list-paginated', [QuoteController::class, 'list_quote_paginate']);
    Route::get('/quote/{id}', [QuoteController::class, 'get_quote']);

    Route::patch('/sale/paymentPlans/{id}/confirm', [PaymetPlanController::class, 'confirm_payment']);
    Route::patch('/sale/paymentPlans/{id}', [PaymetPlanController::class, 'update_payment']);

    Route::get('/customer/{id}/bitacora', [BitacoraController::class, 'getCustomerActivities']);
    Route::get('/customer/perfil/{id}', [CustomerController::class, 'get_perfil_customer']);

    Route::get('/system-log', [SystemLogController::class, 'pagination_system_log']);
});

Route::get('/dashboard/general', [DashboardController::class, 'getGeneralStatistics']);
Route::get('/dashboard/sale', [DashboardController::class, 'getSaleStatistics']);
Route::get('/dashboard/quote', [DashboardController::class, 'getQuoteStatics']);
Route::get('/dashboard/activity', [DashboardController::class, 'getActivityStatics']);
Route::get('/dashboard/seller', [DashboardController::class, 'getSeller']);
Route::get('/dashboard/properties', [DashboardController::class, 'getPropertyStatistics']);
Route::get('/dashboard/properties/{type}', [DashboardController::class, 'getPropertyTypeStatistics']);
Route::get('/dashboard/monthly', [DashboardController::class, 'getMonthyReport']);
Route::get('/dashboard/week', [DashboardController::class, 'getWeekReport']);
// reporte del seller
Route::get('/dashboard/activities', [DashboardController::class, 'getActivityStatistics']);

Route::get('/export/customer', [CustomerController::class, 'customer_export']);
Route::get('/export/property', [PropertyController::class, 'property_export']);
Route::get('/export/quote', [QuoteController::class, 'quote_export']);
Route::get('/export/sale', [SalesController::class, 'sale_export']);



