<?php

use App\Http\Controllers\ClientInvoicesController;
use App\Http\Controllers\ClientProjectsController;
use App\Http\Controllers\ClientServicesController;
use App\Http\Controllers\ClientTransactionsController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\DocumentUpdateController;
use App\Http\Controllers\LanguageController;
use Illuminate\Support\Facades\Route;

Route::post('/change-language', [LanguageController::class, 'changeLanguage'])->name('change.language');

// All dashboard routes require authentication
Route::prefix('dashboard')->middleware(['auth'])->group(function () {
    Route::get('/', [DashboardController::class, 'index'])->name('dashboard');
    Route::get('/overview', [DashboardController::class, 'index_panel'])->name('dashboard_panel');
    Route::get('/profile', [DashboardController::class, 'profile'])->name('dashboard.profile');
    Route::put('/profile', [DashboardController::class, 'update'])->name('dashboard.profile.update');

    Route::get('/service-requests', [ClientServicesController::class, 'index'])->name('dashboard.service.requests');
    Route::get('/service-requests/{id}', [ClientServicesController::class, 'show'])->name('dashboard.service.requests.show');

    Route::get('/projects', [ClientProjectsController::class, 'index'])->name('dashboard.projects');
    Route::get('/projects-details/{id}', [ClientProjectsController::class, 'show'])->name('dashboard.project.show');
    Route::get('/pay/{id}', [ClientProjectsController::class, 'pay'])->name('dashboard.project.pay');
    Route::post('/payment/{id}/process', [ClientProjectsController::class, 'processPayment'])->name('dashboard.payment.process');
    
    // Documents routes
    Route::get('/projects/{project}/documents', [DocumentUpdateController::class, 'showUploadForm'])->name('dashboard.projects.documents');
    Route::post('/projects/{project}/documents/submit', [DocumentUpdateController::class, 'submitDocuments'])->name('dashboard.projects.documents.submit');
    Route::get('/projects/{project}/documents/{documentIndex}/download', [DocumentUpdateController::class, 'getDocument'])->name('dashboard.projects.documents.download');

    // Transactions routes
    Route::get('/transactions', [ClientTransactionsController::class, 'transactions'])->name('dashboard.transactions');
    Route::get('/transactions/{id}/show', [ClientTransactionsController::class, 'show'])->name('dashboard.transactions.details');

    // Invoices routes
    Route::get('/invoices', [ClientInvoicesController::class, 'invoices'])->name('dashboard.invoices');
    Route::get('/invoices/{id}/show', [ClientInvoicesController::class, 'show'])->name('dashboard.invoices.details');
});

require __DIR__ . '/auth.php';
require __DIR__ . '/admin.php';
require __DIR__ . '/frontend.php';