import React from 'react';
import PropTypes from 'prop-types';
import { createNamespace } from '../../../../../tools/namingTools';
import Image from '../../../../../atoms/image/Image';

import './styles/FooterLogo.scss';

const n = createNamespace('FooterLogo');

const FooterLogo = ({
    alt,
    src,
    url
}) => {
    if (!src) {
        return null;
    }

    const renderLogo = (
        <Image
            className={n('image').props.className}
            alt={alt}
            src={src}
        />
    );

    return (
        <div {...n('logo').withTestId().props}>
            {url ? (
                <a {...n('link').props} href={url}>{renderLogo}</a>
            ) : renderLogo}
        </div>
    );
};

FooterLogo.propTypes = {
    alt: PropTypes.string,
    src: PropTypes.string,
    url: PropTypes.string
};

FooterLogo.defaultProps = {
    alt: null,
    src: null,
    url: null
};

export default FooterLogo;
