<?php

use App\Modules\Dashboard\Controllers\AccountingHubPageController;
use App\Modules\Dashboard\Controllers\DashboardController;
use App\Modules\Dashboard\Controllers\ModulePlaceholderController;
use App\Modules\Dashboard\Controllers\NotificationCenterController;
use App\Modules\Dashboard\Controllers\PersonaDashboardController;
use Illuminate\Support\Facades\Route;

Route::middleware(['auth', 'verified', 'tenant.lifecycle', 'subscription.writable'])->group(function () {
    Route::get('/dashboard', [DashboardController::class, 'index'])
        ->name('dashboard.index');

    Route::get('/dashboard/accounting', [AccountingHubPageController::class, 'index'])
        ->name('dashboard.accounting-hub');

    Route::get('/dashboard/ops/{persona}', [PersonaDashboardController::class, 'show'])
        ->whereIn('persona', ['warehouse', 'procurement', 'sales', 'finance', 'admin'])
        ->name('dashboard.ops.show');

    Route::get('/notifications', [NotificationCenterController::class, 'index'])
        ->name('notifications.index');
    Route::post('/notifications/{id}/read', [NotificationCenterController::class, 'markRead'])
        ->whereUuid('id')
        ->name('notifications.read');
    Route::post('/notifications/read-all', [NotificationCenterController::class, 'markAllRead'])
        ->name('notifications.read-all');
    Route::post('/notifications/bulk-read', [NotificationCenterController::class, 'markManyRead'])
        ->name('notifications.bulk-read');

    Route::get('/modules/inventory', [ModulePlaceholderController::class, 'inventory'])
        ->middleware('module:inventory')
        ->name('tenant.modules.inventory');

    Route::get('/modules/finance', [ModulePlaceholderController::class, 'finance'])
        ->middleware('module:finance')
        ->name('tenant.modules.finance');

    Route::get('/modules/crm', [ModulePlaceholderController::class, 'crm'])
        ->middleware('module:crm')
        ->name('tenant.modules.crm');

    Route::get('/modules/sales', [ModulePlaceholderController::class, 'sales'])
        ->middleware('module:sales')
        ->name('tenant.modules.sales');
});
