import { ComponentProps } from "react";
import { Button, ButtonSpinner } from "./button";

type CustomButtonAttrs = {
  isLoading?: boolean;
} & ComponentProps<typeof Button>;

const CustomButton = ({
  isLoading = false,
  children,
  ...rest
}: CustomButtonAttrs) => {
  return (
    <Button
      className={isLoading ? "opacity-70" : ""}
      disabled={isLoading}
      {...rest}
    >
      {isLoading && <ButtonSpinner />}
      <>{children}</>
    </Button>
  );
};

export default CustomButton;
