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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user