"use client";

import { useTranslation } from "@turbostarter/i18n";
import { cn } from "@turbostarter/ui";
import { buttonVariants } from "@turbostarter/ui-web/button";

import { pathsConfig } from "~/config/paths";
import { authClient } from "~/lib/auth/client";
import { TurboLink } from "~/modules/common/turbo-link";

export const CtaButton = (
  props: Omit<React.ComponentProps<typeof TurboLink>, "href">,
) => {
  const { t } = useTranslation(["common", "marketing"]);
  const { data } = authClient.useSession();

  return (
    <TurboLink
      {...props}
      href={
        data?.session
          ? pathsConfig.dashboard.user.index
          : pathsConfig.auth.login
      }
      className={cn(buttonVariants(), props.className)}
    >
      {!data?.session ? t("cta.button") : t("dashboard")}
    </TurboLink>
  );
};
