import { Button } from "@/components/ui/button";
import { getTranslations } from "next-intl/server";
import Link from "next/link";

interface SuccessPageActionsProps {
  isTrial?: boolean;
}

export default async function SuccessPageActions({
  isTrial = false,
}: SuccessPageActionsProps) {
  const t = await getTranslations("SuccessPage");
  const dashboardUrl =
    process.env.NEXT_PUBLIC_DASHBAORD_URL || "https://app.motakamil.sa";

  return (
    <div className="flex flex-col sm:flex-row gap-4 justify-center">
      <Button
        asChild
        className="bg-secondary-dark text-white hover:bg-secondary-main"
      >
        <Link href="/">{t("backToSite")}</Link>
      </Button>
      <Button
        asChild
        className="bg-secondary-dark text-white hover:bg-secondary-main"
      >
        <Link href={dashboardUrl} target="_blank">
          {t("goToDashboard")}
        </Link>
      </Button>
      {/* Nothing was paid on a trial, so there's no invoice */}
      {!isTrial && (
        <Button variant="outline" className="border-secondary-dark text-secondary-dark hover:bg-secondary-dark hover:text-primary-main">
          {t("downloadInvoice")}
        </Button>
      )}
    </div>
  );
}
