/**
 * Requests Page Header Component
 */

import { FileText, Download, RefreshCw } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
import { PageHeader } from '@/components/common/PageHeader';

interface RequestsHeaderProps {
  isOrgLevel: boolean;
  isAdmin: boolean;
  loading: boolean;
  exporting: boolean;
  onExport: () => void;
}

export function RequestsHeader({
  isOrgLevel,
  isAdmin,
  loading,
  exporting,
  onExport
}: RequestsHeaderProps) {
  // Determine the title and description based on view mode
  const getTitle = () => {
    if (isOrgLevel) return "All Requests";
    if (isAdmin) return "All Requests"; // Admin viewing as personal
    return "All Requests"; // Regular user
  };

  const getDescription = () => {
    if (isOrgLevel) {
      return "View and filter all organization-wide workflow requests";
    }
    if (isAdmin) {
      return "Viewing requests where you are initiator, approver, or participant";
    }
    return "View and filter your workflow requests";
  };

  return (
    <div className="flex items-start justify-between gap-4" data-testid="requests-header-container">
      <div className="flex items-center gap-3">
      <PageHeader
        icon={FileText}
          title={getTitle()}
          description={getDescription()}
        testId="requests-header"
      />
        {/* View mode badge */}
        <Badge 
          variant="outline" 
          className={isOrgLevel 
            ? "bg-blue-50 text-blue-700 border-blue-200" 
            : "bg-green-50 text-green-700 border-green-200"
          }
        >
          {isOrgLevel ? "Organization" : "Personal"}
        </Badge>
      </div>
      <Button
        onClick={onExport}
        disabled={exporting || loading}
        className="bg-re-green hover:bg-re-green/90 text-white shrink-0"
        size="sm"
        data-testid="export-button"
      >
        {exporting ? (
          <>
            <RefreshCw className="w-4 h-4 mr-2 animate-spin" />
            Exporting...
          </>
        ) : (
          <>
            <Download className="w-4 h-4 mr-2" />
            Export
          </>
        )}
      </Button>
    </div>
  );
}

