<?php

use App\Http\Controllers\Owner\ArtistItemController;
use App\Http\Controllers\Owner\CatalogPriceRuleController;
use App\Http\Controllers\Owner\ClientController;
use App\Http\Controllers\Owner\DashboardController;
use App\Http\Controllers\Owner\ExternalPartnerController;
use App\Http\Controllers\Owner\GiftItemController;
use App\Http\Controllers\Owner\MariachiGroupController;
use App\Http\Controllers\Owner\OtherCostItemController;
use App\Http\Controllers\Owner\PaymentMethodController;
use App\Http\Controllers\Owner\QuoteCalculatorController;
use App\Http\Controllers\Owner\QuoteTransportRuleController;
use App\Http\Controllers\Owner\ReportController;
use App\Http\Controllers\Owner\RoleController;
use App\Http\Controllers\Owner\SerenataController;
use App\Http\Controllers\Owner\SerenataPackageController;
use App\Http\Controllers\Owner\SerenataPlannerController;
use App\Http\Controllers\Owner\SettingsController;
use App\Http\Controllers\Owner\TeamController;
use App\Http\Controllers\Owner\WorkspaceController;
use Illuminate\Support\Facades\Route;

Route::prefix('owner')->name('owner.')->middleware(['auth', 'owner', 'permission.team', 'panel.route'])->group(function () {
    Route::redirect('/', '/owner/dashboard');
    Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
    Route::post('/workspace/switch', [WorkspaceController::class, 'switch'])->name('workspace.switch');
    Route::get('/cotizador', [QuoteCalculatorController::class, 'index'])->name('quotes.calculator');
    Route::post('/cotizador', [QuoteCalculatorController::class, 'calculate'])->name('quotes.calculator.calculate');
    Route::get('/reportes', [ReportController::class, 'index'])->name('reports.index');

    Route::get('/serenatas', [SerenataController::class, 'index'])->name('serenatas.index');
    Route::get('/serenatas/package-template', [SerenataController::class, 'packageTemplate'])->name('serenatas.package-template');
    Route::get('/serenatas/location-options', [SerenataController::class, 'locationOptions'])->name('serenatas.location-options');
    Route::get('/serenatas/planificador', [SerenataPlannerController::class, 'index'])->name('serenatas.planner');
    Route::get('/serenatas/planificador/data', [SerenataPlannerController::class, 'data'])->name('serenatas.planner.data');
    Route::patch('/serenatas/planificador/move', [SerenataPlannerController::class, 'move'])->name('serenatas.planner.move');
    Route::post('/serenatas/planificador/optimize', [SerenataPlannerController::class, 'optimize'])->name('serenatas.planner.optimize');
    Route::get('/serenatas/{serenata}', [SerenataController::class, 'show'])->name('serenatas.show');
    Route::patch('/serenatas/{serenata}/status', [SerenataController::class, 'updateStatus'])->name('serenatas.update-status');
    Route::patch('/serenatas/{serenata}/notes', [SerenataController::class, 'updateNotes'])->name('serenatas.update-notes');
    Route::patch('/serenatas/{serenata}/service-note', [SerenataController::class, 'updateServicePrivateNote'])->name('serenatas.update-service-note');
    Route::patch('/serenatas/{serenata}/event-info', [SerenataController::class, 'updateEventInfo'])->name('serenatas.update-event-info');
    Route::patch('/serenatas/{serenata}/address', [SerenataController::class, 'updateAddress'])->name('serenatas.update-address');
    Route::patch('/serenatas/{serenata}/payment-method', [SerenataController::class, 'updatePaymentMethod'])->name('serenatas.update-payment-method');
    Route::patch('/serenatas/{serenata}/actual-customer-charge', [SerenataController::class, 'updateActualCustomerCharge'])->name('serenatas.update-actual-customer-charge');
    Route::patch('/serenatas/{serenata}/pricing', [SerenataController::class, 'updatePricing'])->name('serenatas.update-pricing');
    Route::patch('/serenatas/{serenata}/discount', [SerenataController::class, 'updateDiscount'])->name('serenatas.update-discount');
    Route::patch('/serenatas/{serenata}/cedida', [SerenataController::class, 'updateCeded'])->name('serenatas.update-cedida');
    Route::post('/serenatas/{serenata}/external-movements', [SerenataController::class, 'addExternalPartnerMovement'])->name('serenatas.add-external-movement');
    Route::post('/serenatas/{serenata}/service-adjustment', [SerenataController::class, 'addServiceAdjustment'])->name('serenatas.add-service-adjustment');
    Route::patch('/serenatas/{serenata}/cost-item', [SerenataController::class, 'updateCostItem'])->name('serenatas.update-cost-item');
    Route::patch('/serenatas/{serenata}/cost-item/remove', [SerenataController::class, 'removeCostItem'])->name('serenatas.remove-cost-item');
    Route::patch('/serenatas/{serenata}/cost-item/restore', [SerenataController::class, 'restoreCostItem'])->name('serenatas.restore-cost-item');
    Route::post('/serenatas/{serenata}/payments', [SerenataController::class, 'addPayment'])->name('serenatas.add-payment');
    Route::post('/serenatas/{serenata}/refund', [SerenataController::class, 'addRefund'])->name('serenatas.add-refund');
    Route::post('/serenatas', [SerenataController::class, 'store'])->name('serenatas.store');
    Route::post('/serenatas/ai-parse', [SerenataController::class, 'aiParse'])->name('serenatas.ai-parse');
    Route::post('/serenatas/address-resolve', [SerenataController::class, 'resolveAddress'])->name('serenatas.address-resolve');
    Route::post('/serenatas/address-suggestions', [SerenataController::class, 'addressSuggestions'])->name('serenatas.address-suggestions');
    Route::get('/clientes', [ClientController::class, 'index'])->name('clients.index');
    Route::get('/clientes/{customer}', [ClientController::class, 'show'])->name('clients.show');
    Route::post('/clientes', [ClientController::class, 'store'])->name('clients.store');
    Route::patch('/clientes/{customer}/deactivate', [ClientController::class, 'deactivate'])->name('clients.deactivate');

    Route::get('/configuracion', [SettingsController::class, 'index'])->name('settings.index');
    Route::post('/configuracion', [SettingsController::class, 'update'])->name('settings.update');
    Route::post('/configuracion/api-tokens', [SettingsController::class, 'storeApiToken'])->name('settings.api-tokens.store');
    Route::post('/configuracion/api-tokens/reset', [SettingsController::class, 'resetApiTokens'])->name('settings.api-tokens.reset');
    Route::post('/configuracion/api-tokens/{apiToken}/revoke', [SettingsController::class, 'revokeApiToken'])->name('settings.api-tokens.revoke');
    Route::get('/configuracion/equipo', [TeamController::class, 'index'])->name('settings.team');
    Route::post('/configuracion/equipo', [TeamController::class, 'store'])->name('settings.team.store');
    Route::patch('/configuracion/equipo/{user}/deactivate', [TeamController::class, 'deactivate'])->name('settings.team.deactivate');
    Route::get('/configuracion/roles', [RoleController::class, 'index'])->name('settings.roles');
    Route::post('/configuracion/roles', [RoleController::class, 'store'])->name('settings.roles.store');
    Route::put('/configuracion/roles/{staffRole}', [RoleController::class, 'update'])->name('settings.roles.update');
    Route::delete('/configuracion/roles/{staffRole}', [RoleController::class, 'destroy'])->name('settings.roles.destroy');
    Route::get('/configuracion/obsequios', [GiftItemController::class, 'index'])->name('settings.gifts');
    Route::post('/configuracion/obsequios', [GiftItemController::class, 'store'])->name('settings.gifts.store');
    Route::put('/configuracion/obsequios/{giftItem}', [GiftItemController::class, 'update'])->name('settings.gifts.update');
    Route::delete('/configuracion/obsequios/{giftItem}', [GiftItemController::class, 'destroy'])->name('settings.gifts.destroy');
    Route::get('/configuracion/artistas', [ArtistItemController::class, 'index'])->name('settings.artists');
    Route::post('/configuracion/artistas', [ArtistItemController::class, 'store'])->name('settings.artists.store');
    Route::put('/configuracion/artistas/{artistItem}', [ArtistItemController::class, 'update'])->name('settings.artists.update');
    Route::delete('/configuracion/artistas/{artistItem}', [ArtistItemController::class, 'destroy'])->name('settings.artists.destroy');
    Route::get('/configuracion/otros-costos', [OtherCostItemController::class, 'index'])->name('settings.other-costs');
    Route::post('/configuracion/otros-costos', [OtherCostItemController::class, 'store'])->name('settings.other-costs.store');
    Route::put('/configuracion/otros-costos/{otherCostItem}', [OtherCostItemController::class, 'update'])->name('settings.other-costs.update');
    Route::delete('/configuracion/otros-costos/{otherCostItem}', [OtherCostItemController::class, 'destroy'])->name('settings.other-costs.destroy');
    Route::get('/configuracion/externos', [ExternalPartnerController::class, 'index'])->name('settings.external-partners');
    Route::get('/configuracion/externos/{externalPartner}', [ExternalPartnerController::class, 'show'])->name('settings.external-partners.show');
    Route::post('/configuracion/externos', [ExternalPartnerController::class, 'store'])->name('settings.external-partners.store');
    Route::put('/configuracion/externos/{externalPartner}', [ExternalPartnerController::class, 'update'])->name('settings.external-partners.update');
    Route::patch('/configuracion/externos/{externalPartner}/deactivate', [ExternalPartnerController::class, 'deactivate'])->name('settings.external-partners.deactivate');
    Route::delete('/configuracion/externos/{externalPartner}', [ExternalPartnerController::class, 'destroy'])->name('settings.external-partners.destroy');
    Route::get('/configuracion/grupos-mariachi', [MariachiGroupController::class, 'index'])->name('settings.mariachi-groups');
    Route::get('/configuracion/grupos-mariachi/{mariachiGroup}', [MariachiGroupController::class, 'show'])->name('settings.mariachi-groups.show');
    Route::post('/configuracion/grupos-mariachi', [MariachiGroupController::class, 'store'])->name('settings.mariachi-groups.store');
    Route::put('/configuracion/grupos-mariachi/{mariachiGroup}', [MariachiGroupController::class, 'update'])->name('settings.mariachi-groups.update');
    Route::patch('/configuracion/grupos-mariachi/{mariachiGroup}/deactivate', [MariachiGroupController::class, 'deactivate'])->name('settings.mariachi-groups.deactivate');
    Route::delete('/configuracion/grupos-mariachi/{mariachiGroup}', [MariachiGroupController::class, 'destroy'])->name('settings.mariachi-groups.destroy');
    Route::get('/configuracion/pagos', [PaymentMethodController::class, 'index'])->name('settings.payments');
    Route::post('/configuracion/pagos', [PaymentMethodController::class, 'store'])->name('settings.payments.store');
    Route::put('/configuracion/pagos/{paymentMethod}', [PaymentMethodController::class, 'update'])->name('settings.payments.update');
    Route::delete('/configuracion/pagos/{paymentMethod}', [PaymentMethodController::class, 'destroy'])->name('settings.payments.destroy');
    Route::get('/configuracion/paquetes', [SerenataPackageController::class, 'index'])->name('settings.packages');
    Route::post('/configuracion/paquetes', [SerenataPackageController::class, 'store'])->name('settings.packages.store');
    Route::put('/configuracion/paquetes/{serenataPackage}', [SerenataPackageController::class, 'update'])->name('settings.packages.update');
    Route::delete('/configuracion/paquetes/{serenataPackage}', [SerenataPackageController::class, 'destroy'])->name('settings.packages.destroy');
    Route::get('/configuracion/reglas-precio', [CatalogPriceRuleController::class, 'index'])->name('settings.price-rules.index');
    Route::post('/configuracion/reglas-precio', [CatalogPriceRuleController::class, 'store'])->name('settings.price-rules.store');
    Route::put('/configuracion/reglas-precio/{catalogPriceRule}', [CatalogPriceRuleController::class, 'update'])->name('settings.price-rules.update');
    Route::delete('/configuracion/reglas-precio/{catalogPriceRule}', [CatalogPriceRuleController::class, 'destroy'])->name('settings.price-rules.destroy');
    Route::get('/configuracion/reglas-cotizador', [QuoteTransportRuleController::class, 'index'])->name('settings.quote-rules');
    Route::post('/configuracion/reglas-cotizador', [QuoteTransportRuleController::class, 'store'])->name('settings.quote-rules.store');
    Route::put('/configuracion/reglas-cotizador/{quoteTransportRule}', [QuoteTransportRuleController::class, 'update'])->name('settings.quote-rules.update');
    Route::delete('/configuracion/reglas-cotizador/{quoteTransportRule}', [QuoteTransportRuleController::class, 'destroy'])->name('settings.quote-rules.destroy');
});
