<?php

use App\Http\Controllers\Admin\ActivityLogController;
use App\Http\Controllers\Admin\Auth\AuthController;
use App\Http\Controllers\Admin\BrandingController;
use App\Http\Controllers\Admin\DashboardController;
use App\Http\Controllers\Admin\RoleController;
use App\Http\Controllers\Admin\UserController;
use Illuminate\Support\Facades\Route;

Route::middleware('guest')->prefix('admin')->name('admin.')->group(function () {
    Route::get('login', [AuthController::class, 'showLogin'])->name('login');
    Route::post('login', [AuthController::class, 'storeLogin']);
    Route::get('register', [AuthController::class, 'showRegister'])->name('register');
    Route::post('register', [AuthController::class, 'storeRegister']);
});

Route::middleware(['auth', 'admin'])->prefix('admin')->name('admin.')->group(function () {
    Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');

    // Products
    Route::resource('products', \App\Http\Controllers\Admin\ProductController::class);

    // Sales
    Route::resource('sales', \App\Http\Controllers\Admin\SaleController::class)->only(['index', 'create', 'store']);

    // Repairs
    Route::resource('repairs', \App\Http\Controllers\Admin\RepairController::class);

    // Second-hand Buys
    Route::resource('second-hand-buys', \App\Http\Controllers\Admin\SecondHandBuyController::class);

    // Tools
    Route::resource('tools', \App\Http\Controllers\Admin\ToolController::class);

    // Profit
    Route::get('/profit', [App\Http\Controllers\Admin\ProfitController::class, 'index'])->name('profit.index');

    // Accounts
    Route::get('/accounts', [App\Http\Controllers\Admin\AccountsController::class, 'index'])->name('accounts.index');

    // Unlock Service Platform
    Route::get('/unlock-orders', [AdminUnlockOrderController::class, 'index'])->name('unlock-orders.index');
    Route::get('/unlock-orders/{order}', [AdminUnlockOrderController::class, 'show'])->name('unlock-orders.show');
    Route::put('/unlock-orders/{order}/status', [AdminUnlockOrderController::class, 'updateStatus'])->name('unlock-orders.updateStatus');
    Route::put('/unlock-orders/{order}/note', [AdminUnlockOrderController::class, 'addNote'])->name('unlock-orders.addNote');
    
    Route::get('/businesses', [AdminBusinessController::class, 'index'])->name('businesses.index');
    Route::get('/businesses/{business}', [AdminBusinessController::class, 'show'])->name('businesses.show');
    
    Route::get('/payments', [AdminBusinessPaymentController::class, 'index'])->name('payments.index');
    Route::put('/payments/{payment}/verify', [AdminBusinessPaymentController::class, 'verify'])->name('payments.verify');
    
    Route::get('/subscriptions', [AdminSubscriptionController::class, 'index'])->name('subscriptions.index');
    Route::put('/subscriptions/{business}', [AdminSubscriptionController::class, 'update'])->name('subscriptions.update');
