<?php
declare(strict_types=1);

use App\Controllers\AccountController;
use App\Controllers\ActivityController;
use App\Controllers\AssignmentController;
use App\Controllers\AuthController;
use App\Controllers\CalendarController;
use App\Controllers\CampaignController;
use App\Controllers\ContactController;
use App\Controllers\DashboardController;
use App\Controllers\EmailController;
use App\Controllers\LeadController;
use App\Controllers\ListController;
use App\Controllers\NotificationController;
use App\Controllers\OpportunityController;
use App\Controllers\ReportController;
use App\Controllers\RoleController;
use App\Controllers\SearchController;
use App\Controllers\ServiceController;
use App\Controllers\SettingsController;
use App\Controllers\SetupController;
use App\Controllers\TaskController;
use App\Controllers\TemplateController;
use App\Controllers\TrackingController;
use App\Controllers\UnsubscribeAdminController;
use App\Controllers\UserController;
use App\Controllers\QuoteController;
use App\Controllers\DocumentController;
use App\Controllers\OrderController;
use App\Controllers\ContractController;
use App\Controllers\InvoiceController;
use App\Controllers\ApprovalController;
use App\Controllers\RenewalController;
use App\Controllers\JobController;
use App\Controllers\EquipmentController;
use App\Core\Router;

return static function (Router $r): void {
    $r->get('/login', [AuthController::class, 'showLogin'], false);
    $r->post('/login', [AuthController::class, 'login'], false);
    $r->get('/logout', [AuthController::class, 'logout'], true);

    $r->get('/track/open/{token}', [TrackingController::class, 'open'], false);
    $r->get('/track/click/{token}', [TrackingController::class, 'click'], false);
    $r->get('/unsubscribe/{token}', [TrackingController::class, 'unsubscribeForm'], false);
    $r->post('/unsubscribe/{token}', [TrackingController::class, 'unsubscribeSave'], false);

    $r->get('/', [DashboardController::class, 'index']);
    $r->get('/dashboard', [DashboardController::class, 'index']);

    $r->get('/accounts', [AccountController::class, 'index']);
    $r->get('/accounts/form-data', [AccountController::class, 'formData']);
    $r->post('/accounts', [AccountController::class, 'store']);
    $r->get('/accounts/{id}', [AccountController::class, 'show']);
    $r->post('/accounts/{id}', [AccountController::class, 'update']);

    $r->get('/contacts', [ContactController::class, 'index']);
    $r->post('/contacts', [ContactController::class, 'store']);
    $r->get('/contacts/{id}', [ContactController::class, 'show']);

    $r->get('/leads', [LeadController::class, 'index']);
    $r->post('/leads', [LeadController::class, 'store']);
    $r->get('/leads/{id}', [LeadController::class, 'show']);
    $r->post('/leads/{id}/qualify', [LeadController::class, 'qualify']);
    $r->post('/leads/{id}/convert', [LeadController::class, 'convert']);

    $r->get('/opportunities', [OpportunityController::class, 'index']);
    $r->post('/opportunities', [OpportunityController::class, 'store']);
    $r->get('/opportunities/{id}', [OpportunityController::class, 'show']);
    $r->post('/opportunities/{id}', [OpportunityController::class, 'update']);
    $r->post('/opportunities/{id}/stage', [OpportunityController::class, 'moveStage']);
    $r->post('/opportunities/{id}/fulfill', [OpportunityController::class, 'fulfill']);

    $r->get('/tasks', [TaskController::class, 'index']);
    $r->post('/tasks', [TaskController::class, 'store']);
    $r->get('/tasks/{id}/file', [TaskController::class, 'file']);
    $r->post('/tasks/{id}/complete', [TaskController::class, 'complete']);
    $r->post('/tasks/{id}', [TaskController::class, 'update']);

    $r->post('/activities', [ActivityController::class, 'store']);
    $r->get('/activities/{id}/file', [ActivityController::class, 'file']);

    $r->get('/calendar', [CalendarController::class, 'index']);
    $r->post('/calendar', [CalendarController::class, 'store']);

    $r->get('/emails', [EmailController::class, 'index']);
    $r->post('/emails', [EmailController::class, 'store']);

    $r->get('/search', [SearchController::class, 'index']);

    $r->get('/reports', [ReportController::class, 'index']);
    $r->get('/assignment', [AssignmentController::class, 'index']);
    $r->post('/assignment', [AssignmentController::class, 'store']);

    $r->get('/users', [UserController::class, 'index']);
    $r->post('/users', [UserController::class, 'store']);
    $r->post('/users/{id}', [UserController::class, 'update']);
    $r->post('/users/{id}/toggle', [UserController::class, 'toggle']);

    $r->get('/roles', [RoleController::class, 'index']);
    $r->get('/settings', [SettingsController::class, 'index']);
    $r->post('/settings/connect', [SettingsController::class, 'connect']);
    $r->post('/settings/industry', [SettingsController::class, 'industry']);
    $r->post('/settings/timezone', [SettingsController::class, 'timezone']);
    $r->post('/settings/tips', [SettingsController::class, 'tips']);
    $r->post('/settings/marketing-connect', [SettingsController::class, 'marketingConnect']);
    $r->post('/settings/portal', [SettingsController::class, 'portal']);
    $r->post('/settings/system', [SettingsController::class, 'system']);
    $r->post('/settings/customer-users', [SettingsController::class, 'customerUser']);
    $r->post('/settings/customer-users/{id}/toggle', [SettingsController::class, 'customerUserToggle']);

    $r->get('/documents', [DocumentController::class, 'index']);
    $r->post('/documents', [DocumentController::class, 'store']);
    $r->get('/documents/{id}/file', [DocumentController::class, 'file']);
    $r->get('/documents/{id}/signed', [DocumentController::class, 'signed']);

    $r->get('/quotes', [QuoteController::class, 'index']);
    $r->post('/quotes', [QuoteController::class, 'store']);
    $r->get('/quotes/{id}', [QuoteController::class, 'show']);
    $r->get('/quotes/{id}/file', [QuoteController::class, 'file']);
    $r->post('/quotes/{id}/submit', [QuoteController::class, 'submit']);
    $r->post('/quotes/{id}/send', [QuoteController::class, 'send']);
    $r->post('/quotes/{id}/esign', [QuoteController::class, 'esign']);

    $r->get('/orders', [OrderController::class, 'index']);
    $r->post('/orders', [OrderController::class, 'store']);
    $r->post('/orders/{id}/status', [OrderController::class, 'status']);

    $r->get('/contracts', [ContractController::class, 'index']);
    $r->post('/contracts', [ContractController::class, 'store']);
    $r->get('/contracts/{id}', [ContractController::class, 'show']);
    $r->get('/contracts/{id}/file', [ContractController::class, 'file']);
    $r->post('/contracts/{id}/esign', [ContractController::class, 'esign']);

    $r->get('/invoices', [InvoiceController::class, 'index']);
    $r->post('/invoices', [InvoiceController::class, 'store']);
    $r->get('/invoices/{id}', [InvoiceController::class, 'show']);
    $r->get('/invoices/{id}/file', [InvoiceController::class, 'file']);
    $r->post('/invoices/{id}/file', [InvoiceController::class, 'replaceFile']);
    $r->post('/invoices/{id}/pay', [InvoiceController::class, 'pay']);

    $r->get('/approvals', [ApprovalController::class, 'index']);
    $r->post('/approvals/{id}', [ApprovalController::class, 'decide']);

    $r->get('/renewals', [RenewalController::class, 'index']);

    $r->get('/jobs', [JobController::class, 'index']);
    $r->post('/jobs', [JobController::class, 'store']);
    $r->get('/jobs/{id}', [JobController::class, 'show']);
    $r->post('/jobs/{id}', [JobController::class, 'update']);
    $r->post('/jobs/{id}/notes', [JobController::class, 'note']);

    $r->get('/equipment', [EquipmentController::class, 'index']);
    $r->post('/equipment', [EquipmentController::class, 'store']);

    $r->get('/setup', [SetupController::class, 'index']);
    $r->get('/setup/names', [SetupController::class, 'names']);
    $r->get('/setup/fields', [SetupController::class, 'fields']);
    $r->get('/setup/stages', [SetupController::class, 'stages']);
    $r->get('/setup/forms', [SetupController::class, 'forms']);
    $r->get('/setup/alerts', [SetupController::class, 'alerts']);
    $r->get('/setup/dashboard', [SetupController::class, 'dashboard']);
    $r->get('/setup/permissions', [SetupController::class, 'permissions']);
    $r->post('/setup/save', [SetupController::class, 'save']);
    $r->post('/setup/publish', [SetupController::class, 'publish']);
    $r->post('/setup/undo', [SetupController::class, 'undo']);

    $r->get('/campaigns', [CampaignController::class, 'index']);
    $r->post('/campaigns', [CampaignController::class, 'store']);
    $r->get('/campaigns/reports', [CampaignController::class, 'reports']);
    $r->get('/campaigns/{id}', [CampaignController::class, 'show']);
    $r->post('/campaigns/{id}/send', [CampaignController::class, 'send']);
    $r->post('/campaign-recipients/{id}/bounce', [CampaignController::class, 'bounce']);

    $r->get('/lists', [ListController::class, 'index']);
    $r->get('/lists/preview', [ListController::class, 'preview']);
    $r->post('/lists', [ListController::class, 'store']);

    $r->get('/templates', [TemplateController::class, 'index']);
    $r->post('/templates', [TemplateController::class, 'store']);
    $r->post('/templates/{id}', [TemplateController::class, 'update']);

    $r->get('/unsubscribes', [UnsubscribeAdminController::class, 'index']);

    $r->get('/service', [ServiceController::class, 'index']);
    $r->get('/service/{id}', [ServiceController::class, 'show']);
    $r->post('/service/{id}/attend', [ServiceController::class, 'attend']);
    $r->post('/service/notes', [ServiceController::class, 'note']);
    $r->post('/service/request', [ServiceController::class, 'request']);

    $r->get('/notifications/{id}', [NotificationController::class, 'open']);
    $r->post('/notifications/{id}/read', [NotificationController::class, 'read']);
};
