/**
 * Copyright (c) 2023-present Plane Software, Inc. and contributors
 * SPDX-License-Identifier: AGPL-3.0-only
 * See the LICENSE file for details.
 */

import React from "react";
import { cn } from "../utils";

export interface AuthForgotPasswordProps {
  onForgotPassword?: () => void;
  className?: string;
  text?: string;
  disabled?: boolean;
}

export function AuthForgotPassword({
  onForgotPassword,
  className = "",
  text = "Forgot your password?",
  disabled = false,
}: AuthForgotPasswordProps) {
  const handleClick = (e: React.MouseEvent) => {
    e.preventDefault();
    if (!disabled && onForgotPassword) {
      onForgotPassword();
    }
  };

  return (
    <button
      type="button"
      onClick={handleClick}
      disabled={disabled}
      className={cn(
        "text-13 text-accent-primary transition-colors duration-200 hover:text-accent-secondary",
        {
          "cursor-not-allowed opacity-50": disabled,
          "cursor-pointer": !disabled,
        },
        className
      )}
    >
      {text}
    </button>
  );
}
