<?php

use Modules\Linksehat\Http\Controllers\Api\AppointmentController;
use Modules\Linksehat\Http\Controllers\Api\AuthController;
use Modules\Linksehat\Http\Controllers\Api\DashboardController;
use Modules\Linksehat\Http\Controllers\Api\DoctorController;
use Modules\Linksehat\Http\Controllers\Api\HospitalController;
use Modules\Linksehat\Http\Controllers\Api\NotificationTokenController;
use Modules\Linksehat\Http\Controllers\Api\PersonController;
use Modules\Linksehat\Http\Controllers\Api\ProfileController;
use Modules\Linksehat\Http\Controllers\Api\SearchController;
use Modules\Linksehat\Http\Controllers\Api\SpecialityController;

/*
|--------------------------------------------------------------------------
| 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('linksehat')->group(function () {

    Route::get('dashboard/{query}/{limit?}', [DashboardController::class, 'index']);

    Route::controller(SearchController::class)->group(function () {
        Route::get('search-person-speciality', 'searchSpecialityOrPerson');
        Route::get('search-hospital', 'searchHospital');
    });

    Route::controller(AuthController::class)->group(function () {
        Route::post('otp-request', 'otpRequest');
        Route::post('mock-otp', 'mockOtp');
        Route::post('login', 'login');
        Route::post('register', 'register');
        Route::get('social-login/{provider}', 'redirectSocialLogin');
        Route::get('social-login/{provider}/callback', 'handleSocialLoginCallback');
    });

    Route::controller(SpecialityController::class)->group(function () {
        Route::get('specialities', 'index');
        Route::get('list-specialities', 'listSpeciality');
    });

    Route::controller(HospitalController::class)->group(function () {
        Route::get('hospitals', 'index');
        Route::get('hospitals/{id}', 'show');
    });

    Route::controller(DoctorController::class)->group(function () {
        Route::get('doctors/online', 'index')->name('doctors.online');
        Route::get('doctors', 'index')->name('doctors.index');
        Route::post('doctors/{id}/schedule', 'schedule')->name('doctors.schedule');
        Route::get('doctors/{id}', 'show')->name('doctors.show');
    });


    Route::middleware('auth:sanctum')->group(function () {
        Route::get('profile', [ProfileController::class, 'index'])->name('profile');
        Route::post('profile', [ProfileController::class, 'update'])->name('profile.update');
        Route::post('notification-tokens/delete/{id}', [NotificationTokenController::class, 'destroy'])->name('profile.delete.token');
        Route::post('notification-tokens', [NotificationTokenController::class, 'store'])->name('profile.store.token');
        Route::apiResource('appointment', AppointmentController::class);
        Route::apiResource('families', PersonController::class)->except(['destroy']);
    });
});
