import {Button, ButtonProps} from "antd";
import React, {FC} from "react";
import "./Button.scss";
import Loading from "./Loading";

export type StyleType =
    | "confirmative"
    | "destructive"
    | "dark"
    | "primary"
    | "link-dark"
    | "badge"
    | "tertiary"
    | "link";

export interface StarshipButtonProps {
    styleType?: StyleType;
}
//Partial<{ styleType: StyleType }>;

const StarshipButton: FC<StarshipButtonProps & ButtonProps> = props => {
    const {
        className,
        styleType = "primary",
        type = "primary",
        shape,
        ...buttonProps
    } = props;
    const btnType: {[key in StyleType]: string} = {
        confirmative: "starship-btn-confirmative",
        destructive: "starship-btn-destructive",
        dark: "starship-btn-dark",
        primary: "starship-btn-primary",
        "link-dark": "starship-link-hover-btn-dark",
        badge: "starship-btn-badge",
        tertiary: "starship-btn-norm-hover-color",
        link: "starship-link",
    };
    return (
        <Button
            {...buttonProps}
            type={type}
            className={`starship-btn ${props.className} ${btnType[styleType]} ${
                shape === "round" && "round"
            }`}
        >
            {buttonProps.loading ? <Loading /> : buttonProps.children}
        </Button>
    );
};

export default StarshipButton;
