This repository has been archived on 2026-02-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
breakpilot-pwa/studio-v2/components/worksheet-editor/PageNavigator.tsx
Benjamin Admin 21a844cb8a fix: Restore all files lost during destructive rebase
A previous `git pull --rebase origin main` dropped 177 local commits,
losing 3400+ files across admin-v2, backend, studio-v2, website,
klausur-service, and many other services. The partial restore attempt
(660295e2) only recovered some files.

This commit restores all missing files from pre-rebase ref 98933f5e
while preserving post-rebase additions (night-scheduler, night-mode UI,
NightModeWidget dashboard integration).

Restored features include:
- AI Module Sidebar (FAB), OCR Labeling, OCR Compare
- GPU Dashboard, RAG Pipeline, Magic Help
- Klausur-Korrektur (8 files), Abitur-Archiv (5+ files)
- Companion, Zeugnisse-Crawler, Screen Flow
- Full backend, studio-v2, website, klausur-service
- All compliance SDKs, agent-core, voice-service
- CI/CD configs, documentation, scripts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 09:51:32 +01:00

127 lines
4.3 KiB
TypeScript

'use client'
import { useTheme } from '@/lib/ThemeContext'
import { useLanguage } from '@/lib/LanguageContext'
import { useWorksheet } from '@/lib/worksheet-editor/WorksheetContext'
interface PageNavigatorProps {
className?: string
}
export function PageNavigator({ className = '' }: PageNavigatorProps) {
const { isDark } = useTheme()
const { t } = useLanguage()
const {
document,
currentPageIndex,
setCurrentPageIndex,
addPage,
deletePage,
canvas
} = useWorksheet()
const pages = document?.pages || []
const handlePageChange = (index: number) => {
if (!canvas || !document || index === currentPageIndex) return
// Save current page state
const currentPage = document.pages[currentPageIndex]
if (currentPage) {
currentPage.canvasJSON = JSON.stringify(canvas.toJSON())
}
// Load new page
setCurrentPageIndex(index)
const newPage = document.pages[index]
if (newPage?.canvasJSON) {
canvas.loadFromJSON(JSON.parse(newPage.canvasJSON), () => {
canvas.renderAll()
})
} else {
// Clear canvas for new page
canvas.clear()
canvas.backgroundColor = '#ffffff'
canvas.renderAll()
}
}
// Glassmorphism styles
const containerStyle = isDark
? 'backdrop-blur-xl bg-white/10 border border-white/20'
: 'backdrop-blur-xl bg-white/70 border border-black/10 shadow-xl'
const pageButtonStyle = (isActive: boolean) => isDark
? isActive
? 'bg-purple-500/30 text-purple-300 border-purple-400/50'
: 'bg-white/5 text-white/70 border-white/10 hover:bg-white/10'
: isActive
? 'bg-purple-100 text-purple-700 border-purple-300'
: 'bg-white/50 text-slate-600 border-slate-200 hover:bg-slate-100'
const labelStyle = isDark ? 'text-white/70' : 'text-slate-600'
return (
<div className={`flex items-center gap-3 p-3 rounded-2xl ${containerStyle} ${className}`}>
{/* Page Label */}
<span className={`text-sm font-medium ${labelStyle}`}>
Seiten:
</span>
{/* Page Buttons */}
<div className="flex items-center gap-2">
{pages.map((page, index) => (
<div key={page.id} className="relative group">
<button
onClick={() => handlePageChange(index)}
className={`w-10 h-10 flex items-center justify-center rounded-lg border text-sm font-medium transition-all ${pageButtonStyle(index === currentPageIndex)}`}
>
{index + 1}
</button>
{/* Delete button (visible on hover, not for single page) */}
{pages.length > 1 && (
<button
onClick={(e) => {
e.stopPropagation()
deletePage(index)
}}
className={`absolute -top-2 -right-2 w-5 h-5 rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity ${
isDark
? 'bg-red-500/80 text-white hover:bg-red-500'
: 'bg-red-500 text-white hover:bg-red-600'
}`}
title="Seite löschen"
>
<svg className="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
)}
</div>
))}
{/* Add Page Button */}
<button
onClick={addPage}
className={`w-10 h-10 flex items-center justify-center rounded-lg border border-dashed transition-all ${
isDark
? 'border-white/30 text-white/50 hover:border-white/50 hover:text-white/70 hover:bg-white/5'
: 'border-slate-300 text-slate-400 hover:border-slate-400 hover:text-slate-500 hover:bg-slate-50'
}`}
title="Seite hinzufügen"
>
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4v16m8-8H4" />
</svg>
</button>
</div>
{/* Page Info */}
<span className={`text-sm ${labelStyle}`}>
{currentPageIndex + 1} / {pages.length}
</span>
</div>
)
}