<?php

use App\Http\Controllers\API\StockController as APIStockController;
use App\Http\Controllers\ItemController; // Import the ItemController
use App\Http\Controllers\UserAccountController; // Import the ItemController
use App\Http\Controllers\InvoiceController; // Import the ItemController
use App\Http\Controllers\ItemStockController; // Import the ItemStockController
use App\Http\Controllers\CustomerController; // Import the CustomerCreditController
use Illuminate\Support\Facades\Route;

Route::prefix('api/v1')->group(function ()
{
    Route::get('/items', [ItemController::class, 'index']);
    Route::get('/itemsbyItemID/{item_code}', [ItemController::class, 'show']); // Fetch a single item by item_code
    Route::get('/itemsbyBarcode/{barcode}', [ItemController::class, 'showbarcode']); // Fetch a single item by item_code
    Route::post('/items', [ItemController::class, 'store']); // Create a new item
    //Route::put('/items/{item_code}', [ItemController::class, 'update']);
   // Route::delete('/items/{item_code}', [ItemController::class, 'destroy']);
    Route::get('/items/search/{name}', [ItemController::class, 'searchByName']); // Search items by name

});

Route::prefix('api/v1')->group(function () {
    Route::controller(UserAccountController::class)->group(function () {
        Route::get('/users', 'index');
        Route::get('/users/{id}', 'show');
        Route::post('/users/find-by-pin', [UserAccountController::class, 'findByPin']);
        Route::get('/users/username/{username}', 'showByUsername');
        Route::get('/users/search/{name}', 'searchByName');
        Route::post('/users', 'store');
        // Route::put('/users/{id}', 'update');
        // Route::delete('/users/{id}', 'destroy');
        // Route::patch('/users/{id}/active-status', 'setActiveStatus');
        // Route::patch('/users/{id}/last-login', 'updateLastLogin');
    });
});

Route::prefix('api/v1')->group(function () {
    Route::controller(InvoiceController::class)->group(function () {
        Route::get('/sales/summary', 'getSalesReport');
        Route::get('/sales/detailed', 'getDetailedSalesReport');
        Route::get('/sales/chart', 'getSalesChartData');

        Route::get('/invoices', 'getInvoices');
        Route::get('/invoicedetails', 'getInvoiceById');
        Route::get('/customers/{customerId}/invoices', 'getCustomerInvoices');
        Route::get('/branchlist', 'getBranchList');
        Route::get('/customers', 'customers');
    });
    Route::controller(ItemStockController::class)->group(function () {
        Route::get('/stock', 'getStockData');
    });

    Route::controller(CustomerController::class)->group(function () {
        Route::get('/customer-credits', 'getCustomerCredits');
    });


});



