<commit_before>import m from 'mithril';
import _ from 'underscore';
import moment from 'moment';
import I18n from 'i18n-js';
import { catarse } from '../api';
import models from '../models';
import h from '../h';

const I18nScope = _.partial(h.i18nScope, 'projects.subscription_fields');

const dashboardSubscriptionCard = {
    controller(args) {
        const subscription = args.subscription,
            reward = m.prop(),
            user = m.prop();

        if (subscription.user_external_id) {
            const filterUserVM = catarse.filtersVM({
                    id: 'eq'
                }).id(subscription.user_external_id),
                lU = catarse.loaderWithToken(models.userDetail.getRowOptions(filterUserVM.parameters()));

            lU.load().then((data) => {
                user(_.first(data));
            });
        }

        if (subscription.reward_external_id) {
            const filterRewVM = catarse.filtersVM({
                    id: 'eq'
                }).id(subscription.reward_external_id),
                lRew = catarse.loaderWithToken(models.rewardDetail.getRowOptions(filterRewVM.parameters()));

            lRew.load().then((data) => {
                reward(_.first(data));
            });
        }
        const statusClass = {
            active: 'fa-circle.text-success',
            started: 'fa-circle.text-waiting',
            inactive: 'fa-circle.text-error',
            canceled: 'fa-times-circle.text-error',
            deleted: 'fa-circle.text-error',
            error: 'fa-circle.text-error'
        };
        const paymentClass = {
            boleto: 'fa-barcode',
            credit_card: 'fa-credit-card'
        };
        return {
            statusClass,
            reward,
            user,
            paymentClass
        };
    },
    view(ctrl, args) {
        const subscription = args.subscription,
            statusClass = ctrl.statusClass,
            paymentClass = ctrl.paymentClass;

        return m('.card', ctrl.user() ?
            m('.w-row', [
                m('.table-col.w-col.w-col-3',
                    m('.w-row', [
                        m('.w-col.w-col-3',
                            m(`img.u-marginbottom-10.user-avatar[src='${h.useAvatarOrDefault(ctrl.user().profile_img_thumbnail)}']`)
                        ),
                        m('.w-col.w-col-9', [
                            m('.fontsize-smaller.fontweight-semibold.lineheight-tighter',
                                ctrl.user().name
                            ),
                            m('.fontcolor-secondary.fontsize-smallest',
                                ctrl.user().email
                            )
                        ])
                    ])
                ),
                m('.table-col.w-col.w-col-3',
                    m('.fontsize-smaller',
                        _.isEmpty(ctrl.reward()) ? '' : `${ctrl.reward().description.substring(0, 20)}...`
                    )
                ),
                m('.table-col.w-col.w-col-1', [
                    m('.fontsize-smaller',
                        `R$${h.formatNumber(subscription.amount / 100, 0, 3)}`
                    ),
                    m('.fontcolor-secondary.fontsize-mini.fontweight-semibold.lineheight-tightest', [
                        m(`span.fa.${paymentClass[subscription.checkout_data.payment_method]}`,
                            ''
                        ),
                        I18n.t(subscription.checkout_data.payment_method, I18nScope())
                    ])
                ]),
                m('.w-col.w-col-1', [
                    m('.fontsize-smaller',
                        `R$${h.formatNumber(subscription.total_paid / 100, 0, 3)}`
                    ),
                    m('.fontcolor-secondary.fontsize-mini.fontweight-semibold.lineheight-tightest',
                        `${subscription.paid_count} meses`
                    )
                ]),
                m('.w-col.w-col-2',<commit_msg>fix payment method<commit_after>import m from 'mithril';
import _ from 'underscore';
import moment from 'moment';
import I18n from 'i18n-js';
import { catarse } from '../api';
import models from '../models';
import h from '../h';

const I18nScope = _.partial(h.i18nScope, 'projects.subscription_fields');

const dashboardSubscriptionCard = {
    controller(args) {
        const subscription = args.subscription,
            reward = m.prop(),
            user = m.prop();

        if (subscription.user_external_id) {
            const filterUserVM = catarse.filtersVM({
                    id: 'eq'
                }).id(subscription.user_external_id),
                lU = catarse.loaderWithToken(models.userDetail.getRowOptions(filterUserVM.parameters()));

            lU.load().then((data) => {
                user(_.first(data));
            });
        }

        if (subscription.reward_external_id) {
            const filterRewVM = catarse.filtersVM({
                    id: 'eq'
                }).id(subscription.reward_external_id),
                lRew = catarse.loaderWithToken(models.rewardDetail.getRowOptions(filterRewVM.parameters()));

            lRew.load().then((data) => {
                reward(_.first(data));
            });
        }
        const statusClass = {
            active: 'fa-circle.text-success',
            started: 'fa-circle.text-waiting',
            inactive: 'fa-circle.text-error',
            canceled: 'fa-times-circle.text-error',
            deleted: 'fa-circle.text-error',
            error: 'fa-circle.text-error'
        };
        const paymentClass = {
            boleto: 'fa-barcode',
            credit_card: 'fa-credit-card'
        };
        return {
            statusClass,
            reward,
            user,
            paymentClass
        };
    },
    view(ctrl, args) {
        const subscription = args.subscription,
            statusClass = ctrl.statusClass,
            paymentClass = ctrl.paymentClass;

        return m('.card', ctrl.user() ?
            m('.w-row', [
                m('.table-col.w-col.w-col-3',
                    m('.w-row', [
                        m('.w-col.w-col-3',
                            m(`img.u-marginbottom-10.user-avatar[src='${h.useAvatarOrDefault(ctrl.user().profile_img_thumbnail)}']`)
                        ),
                        m('.w-col.w-col-9', [
                            m('.fontsize-smaller.fontweight-semibold.lineheight-tighter',
                                ctrl.user().name
                            ),
                            m('.fontcolor-secondary.fontsize-smallest',
                                ctrl.user().email
                            )
                        ])
                    ])
                ),
                m('.table-col.w-col.w-col-3',
                    m('.fontsize-smaller',
                        _.isEmpty(ctrl.reward()) ? '' : `${ctrl.reward().description.substring(0, 20)}...`
                    )
                ),
                m('.table-col.w-col.w-col-1', [
                    m('.fontsize-smaller',
                        `R$${h.formatNumber(subscription.amount / 100, 0, 3)}`
                    ),
                    m('.fontcolor-secondary.fontsize-mini.fontweight-semibold.lineheight-tightest', [
                        m(`span.fa.${paymentClass[subscription.payment_method]}`,
                            ''
                        ),
                        I18n.t(subscription.payment_method, I18nScope())
                    ])
                ]),
                m('.w-col.w-col-1', [
                    m('.fontsize-smaller',
                        `R$${h.formatNumber(subscription.total_paid / 100, 0, 3)}`
                    ),
                    m('.fontcolor-secondary.fontsize-mini.fontweight-semibold.lineheight-tightest',
                        `${subscription.paid_count} meses`
                    )
                ]),
                m('.w-col.w-col-2',
{'fraction_non_alphanumeric': 0.1356186663330414, 'fraction_numerical': 0.008507444013511823, 'mean_word_length': 1.2298465829846583, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4211784', 'n_tokens_mistral': 2239, 'n_tokens_neox': 2118, 'n_words': 275}