o2o-triple-pick/components/BackButton.tsx

28 lines
724 B
TypeScript

"use client";
import { useRouter } from "next/navigation";
// 뒤로가기 — 직전 페이지(예: 투표하던 매치 페이지)로 복귀.
// 히스토리가 없으면(직접 진입) 홈으로 폴백.
export default function BackButton({
label,
home,
}: {
label: string;
home: string;
}) {
const router = useRouter();
const goBack = () => {
if (typeof window !== "undefined" && window.history.length > 1) router.back();
else router.push(home);
};
return (
<button
onClick={goBack}
className="flex items-center gap-1.5 rounded-full border border-white/12 bg-white/8 px-[18px] py-[9px] text-[18px] font-bold text-white/85 active:scale-95"
>
{label}
</button>
);
}