<?php

use App\Http\Controllers\Companies\AddNewMemberController;
use App\Http\Controllers\Companies\ApproveIdentificationDocumentController;
use App\Http\Controllers\Companies\AssignCompanyToSegmentController;
use App\Http\Controllers\Companies\CreateCompanyController;
use App\Http\Controllers\Companies\CreateIdentificationDocumentController;
use App\Http\Controllers\Companies\DeleteCompanyController;
use App\Http\Controllers\Companies\FetchCompanyBookingQuotationController;
use App\Http\Controllers\Companies\FetchCompanyController;
use App\Http\Controllers\Companies\FetchCompanyEInvoiceInfoController;
use App\Http\Controllers\Companies\ListBusinessTypesController;
use App\Http\Controllers\Companies\ListCompaniesController;
use App\Http\Controllers\Companies\ListCompanyTypesController;
use App\Http\Controllers\Companies\RemoveCompanyFromSegmentController;
use App\Http\Controllers\Companies\UpdateCompanyController;
use App\Http\Controllers\Companies\UpdateCompanyDebtorController;
use App\Http\Controllers\Companies\UpdateCompanyDetailsController;
use App\Http\Controllers\Companies\UpdateCompanyEInvoiceInfoController;
use App\Http\Controllers\Companies\UpdateCompanyNameAndDebtorController;
use App\Http\Controllers\Companies\UpdateCompanyProfileController;
use App\Http\Controllers\Companies\UpdateCompanyStatusController;
use App\Http\Controllers\Companies\UpdateSupplierCurrenciesController;
use Illuminate\Support\Facades\Route;

Route::group(['prefix' => 'company', 'as' => 'company.'], function () {
    Route::get('/{id}/show', [FetchCompanyController::class, 'fetch'])->name('show');
    Route::get('/list', [ListCompaniesController::class, 'list'])->name('list');
    Route::post('/create', [CreateCompanyController::class, 'create'])->name('create');
    Route::put('/update/{id}', [UpdateCompanyController::class, 'update'])->name('update');
    Route::put('/update/{id}/profile', [UpdateCompanyProfileController::class, 'update'])->name('profile.update');
    Route::put('update/{id}/status', [UpdateCompanyStatusController::class, 'update'])->name('status.update');
    // Route::delete('/delete/{id}', [DeleteCompanyController::class, 'destroy'])->name('delete');
    Route::delete('/delete/{id}', [DeleteCompanyController::class, 'destroy'])->name('destroy');
    Route::put('/name-and-debtor/update/{id}', [UpdateCompanyNameAndDebtorController::class, 'update'])->name('update.nameAndDebtor');

    Route::get('/business-type/list', [ListBusinessTypesController::class, 'list'])->name('business_type.list');
    Route::get('/company-type/list', [ListCompanyTypesController::class, 'list'])->name('company_type.list');

    Route::put('/update/debtor/{id}', [UpdateCompanyDebtorController::class, 'update'])->name('delete');

    Route::post('/team/create', [AddNewMemberController::class, 'create'])->name('team.create');

    Route::group(['prefix' => '{id}/segment', 'as' => 'segment.'], function () {
        Route::post('/assign', [AssignCompanyToSegmentController::class, 'assign'])->name('assign');
        Route::delete('/detach/{segment_id}', [RemoveCompanyFromSegmentController::class, 'detach'])->name('detach');
    });

    Route::group(['prefix' => '{id}/currency', 'as' => 'currency.'], function () {
        Route::post('/convert', [FetchCompanyBookingQuotationController::class, 'fetch'])->name('convert');
    });

    Route::put('supplier/{id}/currencies/update', [UpdateSupplierCurrenciesController::class, 'update'])->name('supplier.currencies.update');

    Route::group(['prefix' => '{id}/identification', 'as' => 'identification.'], function () {
        Route::post('/create', [CreateIdentificationDocumentController::class, 'create'])->name('create');
        Route::put('/{document_id}/approval/{status}', [ApproveIdentificationDocumentController::class, 'approve'])->where('status', 'approve|reject')->name('approval');
    });

    Route::put('/details/update/{id}', [UpdateCompanyDetailsController::class, 'update'])->name('update.details');
    Route::get('/e-invoice/info/{id}', [FetchCompanyEInvoiceInfoController::class, 'fetch'])->name('einvoice.info');
    Route::post('/e-invoice/info/update', [UpdateCompanyEInvoiceInfoController::class, 'updateInfo'])->name('einvoice.info.update');
    Route::post('/e-invoice/request/update', [UpdateCompanyEInvoiceInfoController::class, 'updateRequest'])->name('einvoice.request.update');
    Route::post('/e-invoice/request/update/changeofmind', [UpdateCompanyEInvoiceInfoController::class, 'updateChangeOfMindRequest'])->name('einvoice.request.change');
});
