import "./footer.scss";
import React from "react";
import { useLocation } from "react-router-dom";
import {Trans, useTranslation} from 'react-i18next';
import DemokritosLogo from "../../SVG/DemokritosLogo";

interface FooterProps {
    noLogo?: boolean;
}

const Footer = ({ noLogo = false }: FooterProps) => {
    const location = useLocation();
    const {t, i18n} = useTranslation();
    const locationpath = location.pathname.split("/");
    const locationServiceRoot = locationpath[2];
    const locationOther = locationpath[1];

    // Get the current year
    const currentYear = new Date().getFullYear();

    return (
        <footer id={`footer`} className={`${locationServiceRoot} ${locationOther==='settings'? 'settings' : ''} ${locationOther==='dashboard'? 'dashboard' : ''} ${noLogo ? "" : "hasLogo"}`}>
            {/*{locationServiceRoot === "dpass" && <div className={locationServiceRoot}></div> }*/}
            <div className={noLogo ? "container-fluid ps-0" : "container"}>
                <div className="footer-inner">
                    {noLogo || (
                        <div className="logo-wrapper">
                            <a href={'https://www.demokritos.gr/el/'} target={'_blank'}>
                                <DemokritosLogo color={"#204686"} />
                            </a>
                        </div>
                    )}
                    <p className="footer_copyrights">
                        &#169; {currentYear} {t('footer.footer_text')}
                    </p>
                </div>
            </div>
        </footer>
    );
};

function areEqual(prevProps: FooterProps, nextProps: FooterProps) {
    /*
    return true if passing nextProps to render would return
    the same result as passing prevProps to render,
    otherwise return false
    */
    return prevProps.noLogo === nextProps.noLogo;
}

export default React.memo(Footer, areEqual);
