<?php

use App\Http\Controllers\User\AccountController;
use App\Http\Controllers\User\AnnouncementController;
use App\Http\Controllers\User\BinaryTreeController;
use App\Http\Controllers\User\ComplianceController;
use App\Http\Controllers\User\DashboardController;
use App\Http\Controllers\User\IncomeController;
use App\Http\Controllers\User\KycController;
use App\Http\Controllers\User\MatrixTreeController;
use App\Http\Controllers\User\MessagingController;
use App\Http\Controllers\User\NotificationController;
use App\Http\Controllers\User\OrderController;
use App\Http\Controllers\User\PlanController;
use App\Http\Controllers\User\RankController;
use App\Http\Controllers\User\ReferralController;
use App\Http\Controllers\User\ReportController;
use App\Http\Controllers\User\ShopController;
use App\Http\Controllers\User\SupportController;
use App\Http\Controllers\User\TeamController;
use App\Http\Controllers\User\UpiController;
use App\Http\Controllers\User\WalletController;
use App\Http\Controllers\User\WithdrawalController;
use Illuminate\Support\Facades\Route;

Route::prefix('user')->name('user.')->middleware(['auth', 'role:user'])->group(function () {
    Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
    Route::get('/dashboard/metrics', [DashboardController::class, 'metrics'])->name('dashboard.metrics');
    Route::get('/wallet', [WalletController::class, 'index'])->name('wallet');
    Route::post('/wallet/transfer', [WalletController::class, 'transfer'])->name('wallet.transfer');
    Route::get('/income', [IncomeController::class, 'index'])->name('income');
    Route::get('/team', [TeamController::class, 'index'])->name('team');
    Route::get('/binary-tree', [BinaryTreeController::class, 'index'])->name('binary-tree');
    Route::get('/tree', [BinaryTreeController::class, 'index'])->name('tree');
    Route::get('/matrix-tree', [MatrixTreeController::class, 'index'])->name('matrix-tree');
    Route::get('/referrals', [ReferralController::class, 'index'])->name('referrals');
    Route::get('/reports', [ReportController::class, 'index'])->name('reports');
    Route::get('/reports/income', [ReportController::class, 'income'])->name('reports.income');
    Route::get('/reports/payouts', [ReportController::class, 'payouts'])->name('reports.payouts');
    Route::get('/reports/orders', [ReportController::class, 'orders'])->name('reports.orders');
    Route::get('/reports/yearly', [ReportController::class, 'yearly'])->name('reports.yearly');
    Route::get('/shop', [ShopController::class, 'index'])->name('shop');
    Route::post('/shop/order', [ShopController::class, 'placeOrder'])->name('shop.order');
    Route::get('/orders', [OrderController::class, 'index'])->name('orders');
    Route::post('/orders/{order}/cancel', [OrderController::class, 'cancel'])->name('orders.cancel');
    Route::get('/orders/{order}/invoice', [OrderController::class, 'invoice'])->name('orders.invoice');
    Route::get('/withdrawals', [WithdrawalController::class, 'index'])->name('withdrawals');
    Route::post('/withdrawals/otp', [WithdrawalController::class, 'sendOtp'])->middleware('throttle:otp')->name('withdrawals.otp');
    Route::post('/withdrawals', [WithdrawalController::class, 'store'])->name('withdrawals.store');
    Route::get('/notifications', [NotificationController::class, 'index'])->name('notifications');
    Route::post('/notifications/read', [NotificationController::class, 'markRead'])->name('notifications.read');
    Route::get('/kyc', [KycController::class, 'index'])->name('kyc');
    Route::post('/kyc', [KycController::class, 'store'])->name('kyc.store');
    Route::get('/account', [AccountController::class, 'index'])->name('account');
    Route::get('/profile', [AccountController::class, 'index'])->name('profile');
    Route::post('/profile/update', [AccountController::class, 'updateProfile'])->name('profile.update');
    Route::post('/profile/security', [AccountController::class, 'updateSecurity'])->name('profile.security');
    Route::post('/profile/preferences', [AccountController::class, 'updatePreferences'])->name('profile.preferences');
    Route::get('/upi', [UpiController::class, 'index'])->name('upi');
    Route::post('/upi', [UpiController::class, 'store'])->name('upi.store');
    Route::get('/plans', [PlanController::class, 'index'])->name('plans');
    Route::get('/rank', [RankController::class, 'index'])->name('rank');
    Route::get('/support', [SupportController::class, 'index'])->name('support');
    Route::post('/support', [SupportController::class, 'store'])->name('support.store');
    Route::post('/support/{ticketId}/close', [SupportController::class, 'close'])->name('support.close');
    Route::get('/announcements', [AnnouncementController::class, 'index'])->name('announcements');
    Route::get('/messages', [MessagingController::class, 'index'])->name('messages');
    Route::post('/messages', [MessagingController::class, 'store'])->name('messages.store');
    Route::get('/compliance', [ComplianceController::class, 'index'])->name('compliance');
    Route::post('/compliance', [ComplianceController::class, 'store'])->name('compliance.store');
});
