<commit_before><script lang="coffee">
import { startCase, compact } from 'lodash-es'
import parseISO from 'date-fns/parseISO'
import AbilityService from '@/shared/services/ability_service'

export default
  props:
    group: Object
  methods:
    displayDate: (dateString) -> @exactDate(parseISO(dateString))
  computed:
    referralCodeExtra: -> @$t('subscription_status.referral_code_help')
    canSee: -> !@group.parentId && AbilityService.canAdminister(@group)
    expiresAt: -> @exactDate(@group.subscription.expires_at)
    showUpgradeButton: -> @group.subscription.plan == "trial"
    tableData: ->
      {
        plan: startCase(@group.subscription.plan)
        state: startCase(@group.subscription.state)
        expires_at: @displayDate(@group.subscription.expires_at) if @group.subscription.plan == 'trial'
        renews_at: @displayDate(@group.subscription.renews_at)
        active_members: @group.subscription.members_count
        max_members: @group.subscription.max_members if @group.subscription.max_members
        max_threads: @group.subscription.max_threads if @group.subscription.max_threads
        referral_code: "<strong>#{@group.subscription.referral_code}</strong> - <a href='https://help.loomio.org/en/subscriptions/referral_code/' target=_blank>#{@referralCodeExtra}</a>" if @group.subscription.referral_code
        chargify_link: "<a href=#{@group.subscription.management_link} target=_blank>#{@$t('subscription_status.manage_payment_details')}</a>" if @group.subscription.management_link
      }
</script>
<template lang="pug">
v-card.my-6(v-if="canSee" outlined)
  v-card-title
    v-icon.mr-2(color="primary") mdi-rocket
    h1.headline(v-t="'group_page.options.subscription_status'")
    v-btn.ml-2(icon small href="https://help.loomio.org/en/subscriptions/" target="_blank" :title="$t('common.help')")
      v-icon(color="accent") mdi-help-circle-outline
  div.px-6
    v-simple-table(dense)
      template(v-slot:default)
        tbody
          tr(v-for="(val, key) in tableData" :key="key" v-if="val")
            td(v-t="'subscription_status.' + key")
            td(v-html="val")
  v-card-actions(v-if="showUpgradeButton")
    v-spacer
    v-btn(color="primary" href="/upgrade" target="_blank" v-t="'current_plan_button.upgrade'")<commit_msg>guard against null dates<commit_after><script lang="coffee">
import { startCase, compact } from 'lodash-es'
import parseISO from 'date-fns/parseISO'
import AbilityService from '@/shared/services/ability_service'

export default
  props:
    group: Object
  methods:
    displayDate: (dateString) -> @exactDate(parseISO(dateString))
  computed:
    referralCodeExtra: -> @$t('subscription_status.referral_code_help')
    canSee: -> !@group.parentId && AbilityService.canAdminister(@group)
    showUpgradeButton: -> @group.subscription.plan == "trial"
    tableData: ->
      {
        plan: startCase(@group.subscription.plan)
        state: startCase(@group.subscription.state)
        expires_at: @displayDate(@group.subscription.expires_at) if @group.subscription.plan == 'trial' && @group.subscription.expires_at
        renews_at: @displayDate(@group.subscription.renews_at) if @group.subscription.renews_at
        active_members: @group.subscription.members_count
        max_members: @group.subscription.max_members if @group.subscription.max_members
        max_threads: @group.subscription.max_threads if @group.subscription.max_threads
        referral_code: "<strong>#{@group.subscription.referral_code}</strong> - <a href='https://help.loomio.org/en/subscriptions/referral_code/' target=_blank>#{@referralCodeExtra}</a>" if @group.subscription.referral_code
        chargify_link: "<a href=#{@group.subscription.management_link} target=_blank>#{@$t('subscription_status.manage_payment_details')}</a>" if @group.subscription.management_link
      }
</script>
<template lang="pug">
v-card.my-6(v-if="canSee" outlined)
  v-card-title
    v-icon.mr-2(color="primary") mdi-rocket
    h1.headline(v-t="'group_page.options.subscription_status'")
    v-btn.ml-2(icon small href="https://help.loomio.org/en/subscriptions/" target="_blank" :title="$t('common.help')")
      v-icon(color="accent") mdi-help-circle-outline
  div.px-6
    v-simple-table(dense)
      template(v-slot:default)
        tbody
          tr(v-for="(val, key) in tableData" :key="key" v-if="val")
            td(v-t="'subscription_status.' + key")
            td(v-html="val")
  v-card-actions(v-if="showUpgradeButton")
    v-spacer
    v-btn(color="primary" href="/upgrade" target="_blank" v-t="'current_plan_button.upgrade'")
{'fraction_non_alphanumeric': 0.15362824144693832, 'fraction_numerical': 0.0021791239921551534, 'mean_word_length': 4.324825986078887, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 32, 'https://': 4, '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': '1683060', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1528, 'n_words': 213}