import React from 'react'; import { SettingsMenu } from '@/components/layout/SettingsMenu'; import useMediaQuery from '@/hooks/useMediaQuery'; import '@/styles/header.css'; import { ProfileModal } from '@/components/modals/ProfileModal'; interface HeaderProps { title: string; titleContent?: React.ReactNode; onCreateClick: () => void; createButtonText: string; additionalButton?: React.ReactNode; onSearchChange?: (searchTerm: string) => void; hideSearch?: boolean; onMenuClick?: () => void; } export const Header: React.FC = ({ title, titleContent, onCreateClick, createButtonText, additionalButton, onSearchChange, hideSearch = false, onMenuClick }) => { const [showSettings, setShowSettings] = React.useState(false); const [searchTerm, setSearchTerm] = React.useState(""); const [showProfileModal, setShowProfileModal] = React.useState(false); const isMobile = useMediaQuery('(max-width: 767px)'); const handleSettingsClick = (e: React.MouseEvent) => { e.stopPropagation(); setShowSettings(!showSettings); }; const handleOpenProfileModal = () => { setShowSettings(false); setShowProfileModal(true); }; const handleCloseProfileModal = () => { setShowProfileModal(false); }; const handleSearchChange = (e: React.ChangeEvent) => { const value = e.target.value; setSearchTerm(value); onSearchChange?.(value); }; const handleClearSearch = () => { setSearchTerm(""); onSearchChange?.(""); }; const renderIcon = () => { if (createButtonText === "Upload the app") { return ( ); } return ( ); }; return (
{/* Desktop: all in one row; Mobile: stacked */} {!isMobile ? (
{titleContent ? titleContent : title && (

{title}

)} {!hideSearch && (
{searchTerm && ( )}
)}
{additionalButton} {/* DesktopCreateButton */} {createButtonText && ( )}
{showSettings && { setShowSettings(false); }} onOpenProfileModal={handleOpenProfileModal} />}
) : (
{additionalButton} {/* MobileCreateButton */} {createButtonText && ( )}
{showSettings && { setShowSettings(false); }} onOpenProfileModal={handleOpenProfileModal} />}
{titleContent ? (
{titleContent}
) : title && (

{title}

)} {!hideSearch && (
{searchTerm && ( )}
)}
)} {showProfileModal && }
); };