import React from 'react';
import PropTypes from 'prop-types';

import { T, translateComponent } from 'Framework/i18n';

import './Styles.scss';

export class Tools extends React.Component {
    renderExtraTools() {
        return null;
    }

    render() {
        const { props } = this;
        return (
            <div className="tools">
                {this.renderExtraTools()}

                {props.availableTools.fastConfiguration !== undefined &&
                    props.availableTools.fastConfiguration === true && (
                        <button
                            className="tools-fast-configuration-button"
                            onClick={props.onFastConfiguration}
                            title={props.t('tools.fastconfigurationButton')}
                        >
                            <i />
                            {T('tools.fastconfigurationButton')}
                        </button>
                    )}

                {props.availableTools.save !== undefined && props.availableTools.save === true && (
                    <button
                        className="tools-save-button"
                        onClick={props.onSave}
                        title={props.t('tools.saveButton')}
                    >
                        <i />
                        {T('tools.saveButton')}
                    </button>
                )}

                {props.availableTools.load !== undefined && props.availableTools.load === true && (
                    <button
                        className="tools-load-button"
                        onClick={props.onLoad}
                        title={props.t('tools.loadButton')}
                    >
                        <i />
                        {T('tools.loadButton')}
                    </button>
                )}

                {props.availableTools.share !== undefined && props.availableTools.share === true && (
                    <button
                        className="tools-share-button"
                        onClick={props.onShare}
                        title={props.t('tools.shareButton')}
                    >
                        <i />
                        {T('tools.shareButton')}
                    </button>
                )}

                {props.availableTools.print !== undefined && props.availableTools.print === true && (
                    <button
                        className="tools-print-button"
                        onClick={props.onPrint}
                        title={props.t('tools.printButton')}
                    >
                        <i />
                        {T('tools.printButton')}
                    </button>
                )}
            </div>
        );
    }
}

Tools.propTypes = {
    availableTools: PropTypes.object,
    onFastConfiguration: PropTypes.func,
    onSave: PropTypes.func,
    onLoad: PropTypes.func,
    onShare: PropTypes.func,
    onPrint: PropTypes.func,
    t: PropTypes.func,
};

export default translateComponent(Tools);
