feat: Introduce and integrate a mobile back button component across agent and user profile pages.
This commit is contained in:
36
src/components/layout/MobileBackButton.tsx
Normal file
36
src/components/layout/MobileBackButton.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
'use client';
|
||||
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
interface MobileBackButtonProps {
|
||||
label?: string;
|
||||
fallbackHref?: string;
|
||||
}
|
||||
|
||||
export function MobileBackButton({ label, fallbackHref }: MobileBackButtonProps) {
|
||||
const router = useRouter();
|
||||
|
||||
const handleBack = () => {
|
||||
if (window.history.length > 1) {
|
||||
router.back();
|
||||
} else if (fallbackHref) {
|
||||
router.push(fallbackHref);
|
||||
} else {
|
||||
router.push('/');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={handleBack}
|
||||
className="lg:hidden flex items-center gap-2 mb-4 hover:opacity-70 transition-opacity cursor-pointer"
|
||||
>
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
|
||||
<path d="M19 12H5M5 12L12 19M5 12L12 5" stroke="#00293D" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
||||
</svg>
|
||||
{label && (
|
||||
<span className="font-fractul font-medium text-[14px] text-[#00293D]">{label}</span>
|
||||
)}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user