'use client';

import type { KanbanFilters as KanbanFiltersType } from '@/lib/types';
import { ObjectivesBoard } from './ObjectivesBoard';
import { Task, TaskStatus } from '@/lib/types';
import { UserPreferences } from '@/lib/types';
import { KanbanFilters } from './KanbanFilters';

interface KanbanHeaderProps {
  showFilters: boolean;
  showObjectives: boolean;
  kanbanFilters: KanbanFiltersType;
  onFiltersChange: (filters: KanbanFiltersType) => void;
  preferences: UserPreferences;
  onToggleStatusVisibility: (status: TaskStatus) => void;
  pinnedTasks: Task[];
  onEditTask: (task: Task) => void;
  onUpdateStatus: (taskId: string, newStatus: TaskStatus) => Promise<void>;
  pinnedTagName?: string;
  visibleStatuses?: TaskStatus[];
}

export function KanbanHeader({
  showFilters,
  showObjectives,
  kanbanFilters,
  onFiltersChange,
  preferences,
  onToggleStatusVisibility,
  pinnedTasks,
  onEditTask,
  onUpdateStatus,
  pinnedTagName,
  visibleStatuses,
}: KanbanHeaderProps) {
  return (
    <>
      {/* Barre de filtres - conditionnelle */}
      {showFilters && (
        <KanbanFilters
          filters={kanbanFilters}
          onFiltersChange={onFiltersChange}
          hiddenStatuses={new Set(preferences.columnVisibility.hiddenStatuses)}
          onToggleStatusVisibility={onToggleStatusVisibility}
        />
      )}

      {/* Section Objectifs Principaux - conditionnelle */}
      {showObjectives && pinnedTasks.length > 0 && (
        <ObjectivesBoard
          tasks={pinnedTasks}
          onEditTask={onEditTask}
          onUpdateStatus={onUpdateStatus}
          compactView={kanbanFilters.compactView as boolean}
          pinnedTagName={pinnedTagName}
          visibleStatuses={visibleStatuses}
        />
      )}
    </>
  );
}
