<?php

use App\Http\Controllers\ExportController;
use App\Http\Controllers\QuoteController;
use App\Http\Controllers\UpworkOAuthController;
use Illuminate\Support\Facades\Route;

Route::get('/', fn () => redirect('/admin'));

// ─── Exports (autenticado, descarga directa) ───────────────────────────────
Route::middleware(['auth'])->prefix('export')->name('export.')->group(function () {
    Route::get('sales',    [ExportController::class, 'sales'])->name('sales');
    Route::get('payments', [ExportController::class, 'payments'])->name('payments');
    Route::get('cxc',      [ExportController::class, 'cxc'])->name('cxc');
    Route::get('renewals', [ExportController::class, 'renewals'])->name('renewals');
});

// ─── Cotizaciones PDF ─────────────────────────────────────────────────────
Route::middleware(['auth'])->get('quote/{sale}',           [QuoteController::class, 'download'])->name('quote.download');
Route::middleware(['auth'])->get('quote-renewal/{renewal}',[QuoteController::class, 'downloadRenewal'])->name('quote.renewal');

// ─── Upwork OAuth2 skeleton ───────────────────────────────────────────────
Route::middleware(['auth'])->prefix('upwork')->name('upwork.')->group(function () {
    Route::get('connect',  [UpworkOAuthController::class, 'redirect'])->name('connect');
    Route::get('callback', [UpworkOAuthController::class, 'callback'])->name('callback');
});
