<?php

use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Log;
use Illuminate\Http\Request;
use App\Models\DataList;
use App\Models\Master;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\AuthController;
Route::get('/mewa', [DashboardController::class, 'mewa'])->name('mewa');
// Auth routes
Route::get('/login', [AuthController::class, 'showLoginForm'])->name('login');
Route::post('/login', [AuthController::class, 'login']);
Route::post('/logout', [AuthController::class, 'logout'])->name('logout');
Route::get('/forgot-password', [AuthController::class, 'showForgotPassword'])->name('password.request');
Route::post('/forgot-password', [AuthController::class, 'processForgotPassword'])->name('password.update');

// Protected routes
Route::middleware('auth')->group(function () {
    Route::get('/', [DashboardController::class, 'index'])->name('dashboard');

});

Route::post('/data-receive', function (Request $request) {

    $validatedData = $request->validate([
        'dataReceiveBody' => 'required|array',
    ]);
    $data = $validatedData['dataReceiveBody'];

    Log::info('Processed data:', ['data' => $data]);

    return response()->json(['code' => '200', 'msg' => 'OK']);
});
