<?php

use App\Domains\CostUnit\Controllers\DistanceAllowanceController;
use App\Domains\CostUnit\Controllers\ListController;
use App\Domains\Invoice\Controllers\ChangeStateController;
use App\Domains\Invoice\Controllers\EditController;
use App\Domains\Invoice\Controllers\ListMyInvoicesController;
use App\Domains\Invoice\Controllers\NewInvoiceController;
use App\Domains\Invoice\Controllers\SaveInvoiceController;
use App\Domains\Invoice\Controllers\ShowInvoiceController;
use App\Middleware\IdentifyTenant;
use Illuminate\Support\Facades\Route;

Route::middleware(IdentifyTenant::class)->group(function () {
    Route::prefix('api/v1/invoice')->group(function () {
        Route::post('/new/{costUnitId}/{invoiceType}', SaveInvoiceController::class);
        Route::middleware(['auth'])->group(function () {
            Route::get('/details/{invoiceId}', ShowInvoiceController::class);
            Route::get('/showReceipt/{invoiceId}', [ShowInvoiceController::class, 'showReceipt']);

            Route::post('/details/{invoiceId}/change-state/{newState}', ChangeStateController::class);
            Route::post('/details/{invoiceId}/copy', [EditController::class, 'copyInvoice']);
            Route::post('/details/{invoiceId}/update', [EditController::class, 'updateInvoice']);
             Route::get('/my-invoices/{invoiceStatus}', [ListMyInvoicesController::class, 'getMyInvoicesByStatus']);




            Route::get('/create', [CreateController::class, 'showForm']);
        });



    });
});
