<?php

use App\Http\Controllers\Api\AttendanceController;
use App\Http\Controllers\Api\ClientController;
use App\Http\Controllers\Api\DashboardController;
use App\Http\Controllers\Api\DeviceController;
use App\Http\Controllers\Api\EmployeeController;
use App\Http\Controllers\Api\PackageController;
use App\Http\Controllers\Api\PayrollController;
use App\Http\Controllers\Api\RuleController;
use Illuminate\Support\Facades\Route;

Route::prefix('v1')->group(function () {
    Route::get('health', fn () => ['status' => 'ok', 'service' => 'workforce-api']);

    Route::middleware(['auth:sanctum'])->group(function () {
        Route::get('dashboard/super-admin', [DashboardController::class, 'superAdmin']);
        Route::get('dashboard/client', [DashboardController::class, 'client']);

        Route::apiResource('clients', ClientController::class);
        Route::apiResource('packages', PackageController::class);

        Route::middleware(['tenant.active', 'module.access'])->group(function () {
            Route::apiResource('employees', EmployeeController::class);
            Route::apiResource('devices', DeviceController::class);
            Route::apiResource('rules', RuleController::class);
            Route::post('attendance/sync', [AttendanceController::class, 'sync']);
            Route::post('attendance/calculate', [AttendanceController::class, 'calculate']);
            Route::post('payroll/generate', [PayrollController::class, 'generate']);
            Route::post('payroll/{payroll}/approve', [PayrollController::class, 'approve']);
            Route::post('payroll/{payroll}/lock', [PayrollController::class, 'lock']);
        });
    });
});
