shinkan-jinkendo/frontend/src/components/PageReturnButton.jsx
Lars 4588ef4c7e
Some checks failed
Deploy Development / deploy (push) Failing after 24s
Test Suite / pytest-backend (push) Successful in 34s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Failing after 7s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m22s
Refactor navigation components and enhance return context handling
- Replaced `PageReturnLink` with `PageReturnButton` for consistent back navigation across various pages.
- Updated multiple components, including `ExercisePeekModal`, `PageFormEditorChrome`, and `ExerciseDetailPage`, to utilize the new return context features.
- Enhanced CSS styles for the new return button to improve visual consistency.
- Improved navigation logic in `TrainingFrameworkProgramEditPage` and `TrainingModuleEditPage` to ensure seamless user experience when navigating back to previous locations.
2026-05-20 07:42:46 +02:00

31 lines
902 B
JavaScript

import React, { useMemo } from 'react'
import { ArrowLeft } from 'lucide-react'
import { useNavReturn } from '../hooks/useNavReturn'
/**
* App-typischer Zurück-Schalter (kein Router-Link) — nutzt appReturn / History / Fallback.
*/
export default function PageReturnButton({
fallbackPath,
fallbackLabel,
className = 'page-return-btn btn btn-secondary btn-small',
}) {
const fallback = useMemo(
() =>
fallbackPath && fallbackLabel
? { path: fallbackPath, label: fallbackLabel }
: null,
[fallbackPath, fallbackLabel]
)
const { goBack, target } = useNavReturn(fallback)
if (!target?.label) return null
return (
<button type="button" className={className} onClick={goBack} aria-label={target.label}>
<ArrowLeft size={16} strokeWidth={2.25} className="page-return-btn__icon" aria-hidden />
<span>{target.label}</span>
</button>
)
}