Phase 1: NoteEditor Split (64KB → 9 focused components) - components/note-editor/: types.ts, context, toolbar, title-block, content-area, metadata-section, full-page, dialog compositions - Maintains backwards compatibility via re-export from note-editor.tsx Phase 2: Context Consolidation (5 → 3 contexts) - NotebooksContext absorbs LabelContext (labels CRUD) - EditorUIContext merges HomeViewContext + NotebookDragContext - Removed: LabelContext, home-view-context, notebook-drag-context Phase 3: React Query Infrastructure - Added QueryProvider with @tanstack/react-query - lib/query-keys.ts: centralized query key definitions - lib/query-hooks.ts: useNotes, useNotebooksQuery, useLabelsQuery - lib/use-refresh.ts: hybrid invalidateQueries + triggerRefresh helper - NotebooksContext: invalidateQueries on mutations (with triggerRefresh fallback) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
64 lines
1.6 KiB
TypeScript
64 lines
1.6 KiB
TypeScript
'use client'
|
|
|
|
import { Suspense } from 'react'
|
|
import { Header } from './header'
|
|
import { useSearchParams, useRouter } from 'next/navigation'
|
|
import { useNotebooks } from '@/context/notebooks-context'
|
|
|
|
interface HeaderWrapperProps {
|
|
onColorFilterChange?: (color: string | null) => void
|
|
user?: any
|
|
}
|
|
|
|
function HeaderContent({ onColorFilterChange, user }: HeaderWrapperProps) {
|
|
const searchParams = useSearchParams()
|
|
const router = useRouter()
|
|
const { labels } = useNotebooks()
|
|
|
|
const selectedLabels = searchParams.get('labels')?.split(',').filter(Boolean) || []
|
|
const selectedColor = searchParams.get('color') || null
|
|
|
|
const handleLabelFilterChange = (labels: string[]) => {
|
|
const params = new URLSearchParams(searchParams.toString())
|
|
|
|
if (labels.length > 0) {
|
|
params.set('labels', labels.join(','))
|
|
} else {
|
|
params.delete('labels')
|
|
}
|
|
|
|
router.push(`/?${params.toString()}`)
|
|
}
|
|
|
|
const handleColorFilterChange = (color: string | null) => {
|
|
const params = new URLSearchParams(searchParams.toString())
|
|
|
|
if (color) {
|
|
params.set('color', color)
|
|
} else {
|
|
params.delete('color')
|
|
}
|
|
|
|
router.push(`/?${params.toString()}`)
|
|
onColorFilterChange?.(color)
|
|
}
|
|
|
|
return (
|
|
<Header
|
|
selectedLabels={selectedLabels}
|
|
selectedColor={selectedColor}
|
|
onLabelFilterChange={handleLabelFilterChange}
|
|
onColorFilterChange={handleColorFilterChange}
|
|
user={user}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export function HeaderWrapper(props: HeaderWrapperProps) {
|
|
return (
|
|
<Suspense fallback={<div className="h-16 border-b bg-background/95" />}>
|
|
<HeaderContent {...props} />
|
|
</Suspense>
|
|
)
|
|
}
|