import preact, { h, Component } from 'preact'; // eslint-disable-line no-unused-vars

export default class Footer extends Component {

    constructor() {
        super();
    }

    render(props) {
        const pages = props.pages || [],
              page = props.page || {},
              paths = page.paths || [];

        return (
            <footer class="l-footer" role="contentinfo">
                <hr />
                <ul class="o-nav c-nav-lang">
                    {paths.sort((a, b) => a.order > b.order).map(path => {
                        return (
                            <li><a href={path.path}>{path.name}</a></li>
                        )
                    })}
                </ul>
                <ul class="o-nav c-nav-sub">
                    {pages.sort((a, b) => a.order > b.order).map(item => {
                        let classCSS = 'o-nav--link c-nav-sub--link';

                        if (item.objectID === page.ID) {
                            classCSS += ' is-active--nav-sub--link'
                        }

                        return (
                            <li class="o-nav--item c-nav-sub--item">
                                <a class={classCSS} href={item.path}>{item.title}</a>
                            </li>

                        );
                    })}
                </ul>
            </footer>
        );
    }
}
