<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use \App\Http\Controllers\Api\HelperController;
use App\Http\Controllers\Api\AuthController;
use App\Http\Middleware\ApiUserMiddleware;
use App\Http\Controllers\Api\SubscriptionController;
use App\Http\Controllers\Api\Employee\EmployeeHelperController;

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


Route::middleware([\App\Http\Middleware\ForceJsonResponse::class])->group(function () {

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

        Route::get('/categories', [HelperController::class, 'categories']);
        Route::get('/sliders', [HelperController::class, 'sliders']);
        Route::get('/services', [HelperController::class, 'services']);
        Route::get('/events', [HelperController::class, 'events']);
        Route::get('/courses', [HelperController::class, 'courses']);
        Route::get('/subscription', [HelperController::class, 'subscription']);
        Route::get('test', function () {
            $data = (object)[];
            dd($data);
            return response()->json(['test' => 1])->withHeaders(['Content-Type' => 'application/json']);
        });
        Route::middleware('guest')->group(function () {

            Route::prefix('auth')->group(function () {
                Route::post('/login', [AuthController::class, 'login']);
                Route::post('/refresh-token', [AuthController::class, 'refresh']);
                Route::post('/sign-up', [AuthController::class, 'register']);
                Route::post('/sign-up/verify-phone', [AuthController::class, 'verifyPhone']);
                Route::post('/sign-up/resend-verify-phone', [AuthController::class, 'resendVerifyPhone']);
                Route::post('/register', [AuthController::class, 'register']);
                Route::post('/send-otp', [AuthController::class, 'sendOtp']);
                Route::post('forget-password', [AuthController::class, 'submitForgetPasswordForm']);
                Route::post('reset-password', [AuthController::class, 'submitResetPasswordForm']);

            });
        });

        Route::middleware([ApiUserMiddleware::class])->group(function () {

            Route::prefix('auth')->group(function () {
                Route::post('/change-password', [AuthController::class, 'changePassword'])->name('client.change.password');
                Route::get('/logout', [AuthController::class, 'logout'])->name('client.logout');
                Route::get('/profile', [AuthController::class, 'profile']);
                Route::post('/profile/update', [AuthController::class, 'profileUpdate']);
                Route::post('/delete-account', [AuthController::class, 'delete'])->name('delete');

            });
            Route::get('/my-events', [HelperController::class, 'myEvents']);
            Route::get('/my-courses', [HelperController::class, 'myCourses']);
            Route::get('/children', [HelperController::class, 'children'])->name('children');
            Route::get('/wallet', [HelperController::class, 'wallet'])->name('wallet');
            Route::post('/store-wallet', [HelperController::class, 'storeWallet'])->name('storeWallet');
            Route::post('/store-event-subscription', [SubscriptionController::class, 'storeEventSubscription'])->name('storeEventSubscription');
            Route::post('/change-payment-status-event-subscribes', [SubscriptionController::class, 'ChangePaymentStatusEventSubscribes'])->name('ChangePaymentStatusEventSubscribes');

            Route::post('/store-course-subscription', [SubscriptionController::class, 'storeCourseSubscription'])->name('storeEventSubscription');
            Route::post('/change-payment-status-course-subscribes', [SubscriptionController::class, 'ChangePaymentStatusCourseSubscribes'])->name('ChangePaymentStatusEventSubscribes');

        });
    });


    Route::prefix('employee')->group(function () {
        Route::middleware('guest')->group(function () {

            Route::prefix('auth')->group(function () {
                Route::post('/login', [\App\Http\Controllers\Api\Employee\AuthController::class, 'login']);
                Route::post('/refresh-token', [\App\Http\Controllers\Api\Employee\AuthController::class, 'refresh']);
                Route::post('/sign-up', [\App\Http\Controllers\Api\Employee\AuthController::class, 'register']);
                Route::post('/sign-up/verify-phone', [\App\Http\Controllers\Api\Employee\AuthController::class, 'verifyPhone']);
                Route::post('/sign-up/resend-verify-phone', [\App\Http\Controllers\Api\Employee\AuthController::class, 'resendVerifyPhone']);
                Route::post('/register', [\App\Http\Controllers\Api\Employee\AuthController::class, 'register']);
                Route::post('/send-otp', [\App\Http\Controllers\Api\Employee\AuthController::class, 'sendOtp']);
                Route::post('forget-password', [\App\Http\Controllers\Api\Employee\AuthController::class, 'submitForgetPasswordForm']);
                Route::post('reset-password', [\App\Http\Controllers\Api\Employee\AuthController::class, 'submitResetPasswordForm']);

            });

        });
        Route::prefix('auth')->group(function () {
            Route::post('/change-password', [\App\Http\Controllers\Api\Employee\AuthController::class, 'changePassword'])->name('employee.change.password');
            Route::get('/logout', [\App\Http\Controllers\Api\Employee\AuthController::class, 'logout'])->name('employee.logout');
            Route::get('/profile', [\App\Http\Controllers\Api\Employee\AuthController::class, 'profile']);
            Route::post('/profile/update', [\App\Http\Controllers\Api\Employee\AuthController::class, 'profileUpdate']);
            Route::post('/delete-account', [\App\Http\Controllers\Api\Employee\AuthController::class, 'delete'])->name('delete');

        });

        Route::get('/absence-list', [EmployeeHelperController::class, 'absenceList'])->name('absenceList');
        Route::post('/store-absence', [EmployeeHelperController::class, 'storeAbsence'])->name('storeAbsence');
        Route::post('/store-employee-absence', [EmployeeHelperController::class, 'storeEmployeeAbsence'])->name('storeEmployeeAbsence');

    });

});

