<?php

namespace App\Providers\Filament;

use App\Providers\Filament\Concerns\ConfiguresCrmPanel;
use Filament\Http\Middleware\Authenticate;
use Filament\Http\Middleware\AuthenticateSession;
use Filament\Http\Middleware\DisableBladeIconComponents;
use Filament\Http\Middleware\DispatchServingFilamentEvent;
use Filament\Panel;
use Filament\PanelProvider;
use Filament\Support\Colors\Color;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\View\Middleware\ShareErrorsFromSession;

class ConstructionPanelProvider extends PanelProvider
{
    use ConfiguresCrmPanel;

    public function panel(Panel $panel): Panel
    {
        return $this->configureCrmPanel(
            $panel
            ->id('construction')
            ->path('construction')
            ->login()
            ->brandName('Construction CRM')
            ->colors(['primary' => Color::Orange])
            ->discoverResources(in: app_path('Filament/Construction/Resources'), for: 'App\\Filament\\Construction\\Resources')
            ->discoverPages(in: app_path('Filament/Construction/Pages'), for: 'App\\Filament\\Construction\\Pages')
            ->discoverWidgets(in: app_path('Filament/Construction/Widgets'), for: 'App\\Filament\\Construction\\Widgets')
            ->middleware([
                EncryptCookies::class,
                AddQueuedCookiesToResponse::class,
                StartSession::class,
                AuthenticateSession::class,
                ShareErrorsFromSession::class,
                VerifyCsrfToken::class,
                SubstituteBindings::class,
                DisableBladeIconComponents::class,
                DispatchServingFilamentEvent::class,
            ])
            ->authMiddleware([Authenticate::class])
            ->navigationGroups([
                'Projects',
                'Materials & Vendors',
                'Site Reports',
                'Finance',
            ])
        );
    }
}
