feat: add BackButton, protect UserDashboard auth, fix product loading metadata title and add WebOTP auto-submit
This commit is contained in:
1 parent
2ce24b0473
commit
9870516256
9 files changed
+185
-51
No files matched your search
@@ -0,0 +1,38 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { ArrowRight } from "lucide-react";
|
||||
import { cn } from "../lib/utils";
|
||||
|
||||
interface BackButtonProps {
|
||||
className?: string;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
export default function BackButton({ className, label = "بازگشت" }: BackButtonProps) {
|
||||
const router = useRouter();
|
||||
|
||||
const handleBack = () => {
|
||||
// router.back() preserves browser history and scroll position natively
|
||||
if (typeof window !== "undefined" && window.history.length > 1) {
|
||||
router.back();
|
||||
} else {
|
||||
router.push("/");
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleBack}
|
||||
className={cn(
|
||||
"inline-flex items-center gap-2 px-4 py-2 bg-white/80 backdrop-blur-sm border border-medical-gray-200 hover:border-canina-blue hover:text-canina-blue text-medical-gray-700 text-xs font-black rounded-xl transition-all shadow-xs active:scale-95 whitespace-nowrap cursor-pointer",
|
||||
className
|
||||
)}
|
||||
>
|
||||
<ArrowRight className="w-4 h-4" />
|
||||
<span>{label}</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user