<?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\AutocompleteController;
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;
use Modules\Linksehat\Http\Controllers\Api\LinkingController;

/*
|--------------------------------------------------------------------------
| 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('logout', 'logout');
        Route::post('login-phone', 'loginPhone');
        Route::post('register', 'register');
        Route::post('forget-password', 'forgetPassword');
        Route::post('reset-password', 'resetPassword');
        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/{id}', [ProfileController::class, 'index'])->name('profile');
        Route::get('change-profile/{id}', [ProfileController::class, 'changeProfile'])->name('change-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']);

        Route::get('autocomplete/marital_status', [AutocompleteController::class, 'maritalStatus']);
        Route::get('autocomplete/blood_type', [AutocompleteController::class, 'bloodType']);
        Route::get('autocomplete/relationship', [AutocompleteController::class, 'relationship']);
        Route::get('autocomplete/corporate', [AutocompleteController::class, 'corporate']);

        Route::post('manual-linking', [LinkingController::class, 'linkingValidate']);

        Route::get('card/{member_id}', [LinkingController::class, 'card']);

    });
});
