"use client";

import { useRouter, usePathname } from "next/navigation";
import TermsAndConditionsActions from "./TermsAndConditionsActions";

export default function TermsAndConditionsActionsWrapper() {
  const router = useRouter();
  const pathname = usePathname();

  const handleToggle = (agreed?: boolean) => {
    // Extract the base path (locale + /subscribe) from current pathname
    // pathname format: /[locale]/subscribe/terms-and-conditions
    const basePath = pathname.replace("/terms-and-conditions", "");
    router.push(basePath);
  };

  return <TermsAndConditionsActions onToggle={handleToggle} />;
}
