{"size": 2094, "ext": "js", "max_stars_repo_path": "services/catarse/catarse.js/legacy/src/c/signed-friend-facebook-connect.js", "max_stars_repo_name": "common-group/services-core", "max_stars_repo_stars_event_min_datetime": "2018-09-27T01:40:09.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-24T13:08:15.000Z", "max_issues_repo_path": "services/catarse/catarse.js/legacy/src/c/signed-friend-facebook-connect.js", "max_issues_repo_name": "common-group/services-core", "max_issues_repo_issues_event_min_datetime": "2018-08-29T10:15:13.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T14:24:21.000Z", "max_forks_repo_path": "services/catarse/catarse.js/legacy/src/c/signed-friend-facebook-connect.js", "max_forks_repo_name": "common-group/services-core", "max_forks_repo_forks_event_min_datetime": "2018-08-24T15:30:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-11T19:14:43.000Z"}
{"max_stars_count": 56, "max_issues_count": 344, "max_forks_count": 41, "avg_line_length": 43.625, "max_line_length": 145, "alphanum_fraction": 0.4541547278}
import m from 'mithril';
import _ from 'underscore';
import h from '../h';
import connectFacebook from './connect-facebook';

const SignedFriendFacebookConnect = {
    oninit: function(vnode) {
        const mapWithAvatar = () => _.sample(_.filter(vnode.attrs.friendListVM.collection(), item => !_.isNull(item.avatar)), 8);

        vnode.state = {
            mapWithAvatar
        };
    },
    view: function({state, attrs}) {
        if (attrs.friendListVM.isLoading()) {
            return h.loader();
        }
        const total = attrs.friendListVM.total();
        return m('.w-section.section.bg-backs-carrosel.section-large', [
            m('.w-container', [
                m('.card.card-big', [
                    m('.w-row', [
                        m('.w-col.w-col-8', [
                            m('.fontsize-largest.u-marginbottom-20', 'Encontre projetos incríveis junto com seus amigos'),
                            m('.fontsize-small', 'O universo do Catarse junto com a sua rede do Facebook te farão descobrir projetos incríveis!')
                        ]),
                        m('.w-col.w-col-4.u-text-center', [
                            m('.fontsize-smallest.u-marginbottom-10', `${total} dos seus amigos estão no Catarse!`),
                            m('.u-marginbottom-20', [
                                _.map(state.mapWithAvatar(), item => m(`img.thumb.small.u-round.u-marginbottom-10[src="${item.avatar}"]`)),
                            ]),
                                (total > 0 ?
                                    m(connectFacebook, {
                                        label: 'Procure seus amigos',
                                        linkClass: 'a.w-button.btn.btn-large',
                                        buttonClass: 'input.btn.btn-fb.btn-large.u-margintop-30.u-marginbottom-10.w-button',
                                    }) : ''
                                )
                        ])
                    ])
                ])
            ])
        ]);
    }
};

export default SignedFriendFacebookConnect;
