<?php

use App\Apps\Versionmgr\Controllers\DashboardController;
use App\Apps\Versionmgr\Controllers\HistoryController;
use App\Apps\Versionmgr\Controllers\PackageController;
use App\Apps\Versionmgr\Controllers\RepairController;
use App\Apps\Versionmgr\Controllers\VersionController;
use Illuminate\Support\Facades\Route;

Route::get('/', [DashboardController::class, 'index']);

Route::prefix('api')->group(function () {
    Route::get('current', [VersionController::class, 'current']);
    Route::get('check', [VersionController::class, 'check']);
    Route::post('skip', [VersionController::class, 'skip']);
    Route::post('upgrade', [VersionController::class, 'upgrade']);
    Route::get('upgrade/status', [VersionController::class, 'upgradeStatus']);
    Route::post('rollback', [VersionController::class, 'rollback']);
    Route::get('upgrade-path', [VersionController::class, 'upgradePath']);

    Route::get('packages', [PackageController::class, 'list']);
    Route::post('packages/upload', [PackageController::class, 'doUpload']);
    Route::delete('packages/{id}', [PackageController::class, 'delete']);
    Route::post('packages/{id}/upgrade', [PackageController::class, 'upgrade']);

    Route::get('repair/check', [RepairController::class, 'check']);
    Route::post('repair/prepare', [RepairController::class, 'prepare']);
    Route::post('repair/execute', [RepairController::class, 'execute']);
    Route::get('repair/status', [RepairController::class, 'status']);
    Route::post('repair/cleanup', [RepairController::class, 'cleanup']);

    Route::get('history', [HistoryController::class, 'list']);
});

Route::get('/packages', [PackageController::class, 'index']);
Route::get('/packages/upload', [PackageController::class, 'upload']);
Route::get('/repair', [RepairController::class, 'index']);
Route::get('/history', [HistoryController::class, 'index']);
