<?php

use App\Http\Controllers\Auth\AuthenticationController;
use App\Http\Controllers\BookingController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\OrderController;
use App\Http\Controllers\PaypalController;
use App\Http\Controllers\PaypalPaymentController;
use App\Http\Controllers\ProviderRegisterController;
use App\Http\Controllers\RevenueController;
use App\Http\Controllers\ServiceController;
use App\Http\Controllers\ServiceProviderController;
use App\Http\Controllers\ServiceTypeController;
use App\Http\Controllers\UserController;
use App\Models\ServiceType;
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 within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/


Route::post('/payment-accept', [PaypalPaymentController::class, 'payment_confirmation']);

Route::apiResource('/order', OrderController::class);
Route::apiResource('/provider-register', ProviderRegisterController::class);

Route::post('client/registration', [AuthenticationController::class, 'register']);
Route::post('client/login', [AuthenticationController::class, 'login']);
Route::post('admin/login', [AuthenticationController::class, 'adminLogin']);
Route::get('get-service-list', [ServiceTypeController::class, 'service_list']);
Route::get('get-service-list-details', [ServiceTypeController::class, 'service_list_details']);
Route::get('get-service-data/{id}', [ServiceTypeController::class, 'get_service_data']);

Route::get('dashboard-details', [DashboardController::class, 'report_details']);

Route::group(['middleware'=>'auth:sanctum', 'prefix'=>'client'], function () {
    Route::post('delete-account', [AuthenticationController::class, 'delete_account']);
    Route::apiResource('service-list', ServiceTypeController::class);
    Route::post('reset-password', [AuthenticationController::class, 'change_password']);
    Route::post('check-auth', [AuthenticationController::class, 'check_auth']);
    Route::post('logout', [AuthenticationController::class, 'logout']);
    Route::get('get-service-provider-list', [ServiceProviderController::class, 'get_service_provider_list']);
    Route::post('get-order-list', [OrderController::class, 'get_order_list']);
    Route::get('get-service-list', [ServiceController::class, 'get_service_list']);
    Route::post('assign-order', [OrderController::class, 'assign_order']);
    Route::get('order-assign-history', [OrderController::class, 'assign_order']);
    Route::get('order-history/{id}', [OrderController::class, 'order_history']);
    Route::get('get-customer-list', [UserController::class, 'index']);
    Route::post('report-details', [DashboardController::class, 'report_details']);
    Route::get('get-service-provider-details/{id}', [ServiceProviderController::class, 'get_service_provider_details']);
});

Route::group(['middleware'=>['auth:sanctum', 'provider'], 'prefix'=>'provider'], function () {
    Route::post('get-order-list', [OrderController::class, 'get_provider_order_list']);
    Route::resource('paypal', PaypalController::class);
    Route::resource('revenue', RevenueController::class);
    Route::post('provider-revenue', [RevenueController::class, 'provider_revenue']);
});
