<?php

namespace App\Filament\Pages;

use Filament\Pages\Page;

class HRDDashboard extends Page
{
    protected static ?string $navigationIcon = 'heroicon-o-users';

    protected static string $view = 'filament.pages.hrd-dashboard';

    protected static ?string $title = 'HRD Dashboard';

    protected static ?string $navigationLabel = 'HRD Dashboard';

    protected static ?string $navigationGroup = 'Dashboard';

    protected static ?int $navigationSort = 2;

    protected static ?string $description = 'Dashboard untuk HRD - data karyawan, pengajuan, dan kehadiran';

    public function getHeaderWidgets(): array
    {
        return [
            \App\Filament\Widgets\HRD\HRDStatsWidget::class,
        ];
    }

    public function getFooterWidgets(): array
    {
        return [
            \App\Filament\Widgets\HRD\PendingApprovalsWidget::class,
            \App\Filament\Widgets\HRD\RequestStatisticsWidget::class,
            \App\Filament\Widgets\HRD\AttendanceOverviewWidget::class,
        ];
    }

    public function getHeaderWidgetsColumns(): int|array
    {
        return 1;
    }

    public function getFooterWidgetsColumns(): int|array
    {
        return [
            'md' => 2,
            'xl' => 3,
        ];
    }

    public static function shouldRegisterNavigation(): bool
    {
        // Tampil untuk admin, manager, atau user dengan permission tertentu
        $user = auth()->user();
        return $user && (
            $user->hasRole('super_admin') || 
            $user->hasRole('admin') || 
            $user->hasRole('manager') ||
            $user->can('view_all_attendances')
        );
    }
}
