"use client";

import { useLocale } from "next-intl";
import { Toaster as HotToaster, type ToasterProps } from "react-hot-toast";

export function Toaster(props: ToasterProps) {
  const locale = useLocale();
  const isArabic = locale === "ar";

  const toastClassName = `${isArabic ? "font-arabic tracking-normal" : "font-latin"} text-[13px] leading-5`;

  return (
    <HotToaster
      key={locale}
      {...props}
      position={props.position ?? (isArabic ? "top-right" : "top-left")}
      reverseOrder={props.reverseOrder ?? false}
      toastOptions={{
        ...props.toastOptions,
        className:
          props.toastOptions?.className ??
          toastClassName,
        style: {
          borderRadius: "36px",
          ...(props.toastOptions?.style ?? {}),
        },
      }}
    />
  );
}
