feat: implement BackButton component for consistent navigation

- Added BackButton component to standardize back navigation across pages.
- Integrated BackButton into various pages, replacing custom back buttons for consistency.
- Updated PageHeader to accept backTo prop for displaying BackButton when navigating from subpages.
- Created useGoBack hook to handle navigation logic, determining whether to go back in history or redirect to a fallback page.
- Added tests for BackButton and its integration with PageHeader to ensure expected behavior.
This commit is contained in:
hamed
2026-07-29 20:26:51 +03:30
parent e6267080b2
commit e0e8fbd1e4
31 changed files with 224 additions and 82 deletions
+2 -3
View File
@@ -10,6 +10,7 @@ import { api } from '../lib/api';
import type { ApiResponse } from '../lib/api';
import MobileInput from '../components/ui/MobileInput';
import { iranMobileSchema } from '../lib/utils';
import BackButton from '../components/ui/BackButton';
import { latinDigitsField } from '../lib/forms';
const schema = z.object({
@@ -39,9 +40,7 @@ export default function ClinicFormPage() {
return (
<div className="page" style={{ maxWidth: 640 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 28 }}>
<button className="btn ghost sm" onClick={() => navigate('/admin/clinics')}>
<ArrowRightIcon style={{ width: 16, height: 16 }} />بازگشت
</button>
<BackButton fallback="/admin/clinics" />
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<BuildingOffice2Icon style={{ width: 22, height: 22, color: 'var(--primary)' }} />
<h1 style={{ margin: 0, fontSize: 20, fontWeight: 700 }}>افزودن کلینیک جدید</h1>