import './GenerativeFillButtons.scss';
import React = require('react');
import ReactLoading from 'react-loading';
import { activeColor } from './generativeFillUtils/generativeFillConstants';
import { Button, Type } from 'browndash-components';

interface ButtonContainerProps {
    getEdit: () => Promise<void>;
    loading: boolean;
    onReset: () => void;
}

const Buttons = ({ loading, getEdit, onReset }: ButtonContainerProps) => {
    return (
        <div className="generativeFillBtnContainer">
            <Button text="RESET" type={Type.PRIM} color={activeColor} onClick={onReset} />
            {loading ? (
                <Button
                    text="GET EDITS"
                    type={Type.TERT}
                    color={activeColor}
                    icon={<ReactLoading type="spin" color={'#ffffff'} width={20} height={20} />}
                    iconPlacement="right"
                    onClick={() => {
                        if (!loading) getEdit();
                    }}
                />
            ) : (
                <Button
                    text="GET EDITS"
                    type={Type.TERT}
                    color={activeColor}
                    onClick={() => {
                        if (!loading) getEdit();
                    }}
                />
            )}
        </div>
    );
};

export default Buttons;
