import { Button } from "@/components/ui/button";
import React from "react";
import { ModButtonActionProps } from "./TButton";
import { CgSpinner } from "react-icons/cg";

class ModButtonAction extends React.Component<ModButtonActionProps> {
  constructor(props: ModButtonActionProps) {
    super(props);
  }
  render(): React.ReactNode {
    return (
      <Button
        disabled={this.props.isLoading}
        onClick={() => this.props.onClick()}
      >
        {this.props.isLoading ? (
          <CgSpinner size={20} className="mr-2 animate-spin" />
        ) : null}
        {this.props.isLoading
          ? this.props.isLoadingContent
          : this.props.content}
      </Button>
    );
  }
}

export { ModButtonAction };
