<?php

namespace Maestro\Core\Providers;

use Maestro\Core\DataTables\DataTableQueryApplier;
use Maestro\Core\DataTables\DataTableRegistry;
use Maestro\Core\DataTables\Resources\ActivityLogTable;
use Maestro\Core\DataTables\Resources\ChecklistsTable;
use Maestro\Core\DataTables\Resources\CompaniesContactPersonsTable;
use Maestro\Core\DataTables\Resources\CompaniesTable;
use Maestro\Core\DataTables\Resources\CompanyLocationsTable;
use Maestro\Core\DataTables\Resources\DefaultDocumentsTable;
use Maestro\Core\DataTables\Resources\DefaultTasksTable;
use Maestro\Core\DataTables\Resources\DepartmentsTable;
use Maestro\Core\DataTables\Resources\JobFunctionsTable;
use Maestro\Core\DataTables\Resources\ProjectsTable;
use Maestro\Core\DataTables\Resources\ProjectTemplatesTable;
use Maestro\Core\DataTables\Resources\RolesTable;
use Maestro\Core\DataTables\Resources\SectorsTable;
use Maestro\Core\DataTables\Resources\SubsidyGrantorsTable;
use Maestro\Core\DataTables\Resources\SubsidyThemesTable;
use Maestro\Core\DataTables\Resources\TasksTable;
use Maestro\Core\DataTables\Resources\UsersTable;
use Illuminate\Support\ServiceProvider;

class DataTableServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     */
    public function register(): void
    {
        $this->app->singleton(DataTableQueryApplier::class, fn () => new DataTableQueryApplier);

        $this->app->singleton(DataTableRegistry::class, function () {
            $registry = new DataTableRegistry;
            $registry->register(CompaniesTable::class, 'companies');
            $registry->register(CompaniesContactPersonsTable::class, 'companies-contact-persons');
            $registry->register(CompanyLocationsTable::class, 'company-locations');
            $registry->register(UsersTable::class, 'users');
            $registry->register(SubsidyThemesTable::class, 'subsidy-themes');
            $registry->register(SubsidyGrantorsTable::class, 'subsidy-grantors');
            $registry->register(RolesTable::class, 'roles');
            $registry->register(SectorsTable::class, 'sectors');
            $registry->register(DefaultTasksTable::class, 'default-tasks');
            $registry->register(ChecklistsTable::class, 'checklists');
            $registry->register(DefaultDocumentsTable::class, 'default-documents');
            $registry->register(ProjectTemplatesTable::class, 'project-templates');
            $registry->register(DepartmentsTable::class, 'departments');
            $registry->register(JobFunctionsTable::class, 'job-functions');
            $registry->register(ProjectsTable::class, 'projects');
            $registry->register(TasksTable::class, 'tasks');
            $registry->register(ActivityLogTable::class, 'activity-log');

            return $registry;
        });
    }

    /**
     * Bootstrap services.
     */
    public function boot(): void
    {
        //
    }
}
