import { useEffect, useRef } from 'react'; import { Link } from '@tanstack/react-router'; import { BookOpen, Lightbulb, MessagesSquare } from 'lucide-react'; import { __ } from '@wordpress/i18n'; import BrandMark from '@/components/BrandMark'; import StatusPill from '@/components/StatusPill'; import boot from '@/lib/boot'; import { useHasUnsavedChanges } from '@/store/settings-store'; import type { PageInfo } from '@/pages/registry'; interface AppHeaderProps { pages: PageInfo[]; /** Active page ID. */ current?: string; onRequestFeature: () => void; } /** * Sticky header: brand bar with help links (Support last, on the right, as * on the CookieYes screen), then the page tabs with an "Unsaved changes" * label while any edits are unsaved. */ export default function AppHeader( { pages, current, onRequestFeature }: AppHeaderProps ) { const tabs = useRef( null ); const unsaved = useHasUnsavedChanges(); // On narrow screens the tab bar scrolls sideways; keep the active tab in // view, also when the unsaved label appears and narrows the bar. useEffect( () => { const bar = tabs.current; const active = bar?.querySelector( '[aria-current="page"]' ); if ( bar && active && ( active.offsetLeft < bar.scrollLeft || active.offsetLeft + active.offsetWidth > bar.scrollLeft + bar.clientWidth ) ) { bar.scrollLeft = active.offsetLeft - 20; } }, [ current, unsaved ] ); return (

{ __( 'AI Content Generator', 'ai-content-generator-for-woocommerce' ) }

{ unsaved && { __( 'Unsaved changes', 'ai-content-generator-for-woocommerce' ) } }
); }