"use client";
import React, { PropsWithChildren } from "react";
import Link from "next/link";
import { useLocale } from "next-intl";

type props = {
  href: string;
  children: React.ReactNode;
  className?: string;
  prefetch?: boolean;
  scroll?: boolean;
  onClick?: () => void;
  isActive?: boolean;
  dataAos?: string;
  dataAosDuration?: string;
};

export default function LocalePath({
  href,
  className = "",
  prefetch = false,
  children,
  onClick,
  scroll,
  isActive = false,
  dataAos,
  dataAosDuration,
}: PropsWithChildren<props>) {
  const locale = useLocale();
  const isActiveClassName = isActive ? "active-link" : "";
  const hrefPath = locale === "ar" ? `${href}` : `/${locale}${href}`;
  return (
    <Link
      onClick={onClick}
      prefetch={prefetch}
      className={`${className}${isActiveClassName}`}
      href={hrefPath}
      scroll={scroll}
      data-aos={dataAos}
      data-aos-duration={dataAosDuration}
    >
      {children}
    </Link>
  );
}
