import React from 'react';
import PropTypes from 'prop-types';
import { createNamespace } from '../../../../../tools/namingTools';
import { replacePlaceholders } from '../../../../../tools/stringTools';

import './styles/FooterCopyright.scss';

const n = createNamespace('FooterCopyright');

const FooterCopyright = ({ text }) => {
    if (!text || typeof text !== 'string') {
        return null;
    }

    return (
        <div {...n('wrapper').withE2EId().props}>
            <p {...n('text').props}>{replacePlaceholders(text, { currentYear: new Date().getFullYear() })}</p>
        </div>
    );
};

FooterCopyright.propTypes = {
    text: PropTypes.string
};

FooterCopyright.defaultProps = {
    text: ''
};

export default FooterCopyright;
