<?php

declare(strict_types=1);

use Illuminate\Support\Facades\Route;
use Maestro\Core\Modules\HourRegistration\Http\Controllers\HourApprovalController;
use Maestro\Core\Modules\HourRegistration\Http\Controllers\HourExportController;
use Maestro\Core\Modules\HourRegistration\Http\Controllers\HourInvoicingApiController;
use Maestro\Core\Modules\HourRegistration\Http\Controllers\HourRegistryController;
use Maestro\Core\Modules\HourRegistration\Http\Controllers\HourTimesheetWeekController;
use Maestro\Core\Modules\HourRegistration\Http\Controllers\HourBulkEntryController;
use Maestro\Core\Modules\HourRegistration\Http\Controllers\HourMonthEntriesController;
use Maestro\Core\Modules\HourRegistration\Http\Controllers\HourWorkbenchDailyTotalsController;

Route::middleware(['web', 'auth:sanctum', 'maestro.module:hours'])
    ->prefix('api/hours')
    ->group(function (): void {
        Route::get('/week/current', [HourTimesheetWeekController::class, 'current']);
        Route::get('/month-entries', HourMonthEntriesController::class);
        Route::post('/entries/bulk', HourBulkEntryController::class);
        Route::get('/workbench/daily-totals', HourWorkbenchDailyTotalsController::class);

        Route::get('/weeks/{hour_week}', [HourTimesheetWeekController::class, 'show']);

        Route::put('/weeks/{hour_week}/lines', [HourTimesheetWeekController::class, 'sync']);
        Route::post('/weeks/{hour_week}/submit', [HourTimesheetWeekController::class, 'submit']);
        Route::post('/weeks/{hour_week}/unlock', [HourTimesheetWeekController::class, 'unlock']);

        Route::post('/lines/{hour_timesheet_line}/approve', [HourApprovalController::class, 'approve']);
        Route::post('/lines/{hour_timesheet_line}/reject', [HourApprovalController::class, 'reject']);

        Route::get('/export/csv', [HourExportController::class, 'csv']);
        Route::get('/invoicing/by-client', [HourInvoicingApiController::class, 'byClient']);

        Route::get('/registry/internal-categories', [HourRegistryController::class, 'internalCategories']);
        Route::get('/registry/customers', [HourRegistryController::class, 'customers']);
        Route::get('/registry/projects', [HourRegistryController::class, 'projects']);
        Route::get('/registry/tasks', [HourRegistryController::class, 'tasks']);

        Route::post('/registry/projects', [HourRegistryController::class, 'storeProject']);
        Route::post('/registry/tasks', [HourRegistryController::class, 'storeTask']);
    });
