update: success modal

This commit is contained in:
CuriousMagpie
2022-09-08 12:55:53 -04:00
parent abdb6244d3
commit c6ba1d8402
3 changed files with 73 additions and 88 deletions

View File

@@ -5,9 +5,6 @@
:hide-footer="isFromBalance" :hide-footer="isFromBalance"
:modal-class="isFromBalance ? ['modal-hidden-footer'] : []" :modal-class="isFromBalance ? ['modal-hidden-footer'] : []"
> >
<!-- there are basically 3 footer conditions: isFromBalance, groupPlanUpgraded, & everyone else
was trying to make that work with a separate footer for groupPlanUpgraded
but that's not working-->
<div slot="modal-header"> <div slot="modal-header">
<div class="check-container d-flex align-items-center justify-content-center"> <div class="check-container d-flex align-items-center justify-content-center">
<div <div
@@ -19,21 +16,21 @@
<h2>{{ $t(isFromBalance ? 'success' : 'paymentSuccessful') }}</h2> <h2>{{ $t(isFromBalance ? 'success' : 'paymentSuccessful') }}</h2>
</div> </div>
<div slot="modal-footer"> <div slot="modal-footer">
<!-- everyone else -->
<div <div
v-if="!paymentData.paymentType === 'groupPlan' v-if="paymentData.paymentType !== 'groupPlan' || paymentData.newGroup"
&& !groupPlanUpgraded"
class="small-text" class="small-text"
> >
{{ $t('giftSubscriptionText4') }} {{ $t('giftSubscriptionText4') }}
</div> </div>
<!-- upgradedGroup -->
<div <div
v-else v-else
class="demographics" class="demographics d-flex flex-column justify-content-center"
> >
<!-- lockable label needs to be centered -->
<lockable-label <lockable-label
:text="$t('groupUse')" :text="$t('groupUse')"
class="demo-label" class="mx-auto label-text"
/> />
<select-translated-array <select-translated-array
:items="[ :items="[
@@ -49,12 +46,11 @@
:value="groupPlanUpgraded.demographics" :value="groupPlanUpgraded.demographics"
@select="groupPlanUpgraded.demographics = $event" @select="groupPlanUpgraded.demographics = $event"
/> />
<!-- need to add correct :disabled value here 'cause this one ain't working -->
<button <button
v-if="!paymentData.newGroup" v-if="!paymentData.newGroup"
class="btn btn-primary" class="btn btn-primary mx-auto"
:disabled="!'groupPlanUpgraded.demographics'" :disabled="!groupPlanUpgraded.demographics"
@click="close()" @click="submit()"
> >
{{ $t('submit') }} {{ $t('submit') }}
</button> </button>
@@ -62,6 +58,7 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-12 modal-body-col"> <div class="col-12 modal-body-col">
<!-- buy gems for self -->
<template v-if="paymentData.paymentType === 'gems'"> <template v-if="paymentData.paymentType === 'gems'">
<strong v-once>{{ $t('paymentYouReceived') }}</strong> <strong v-once>{{ $t('paymentYouReceived') }}</strong>
<div class="details-block gems"> <div class="details-block gems">
@@ -73,6 +70,7 @@
<span>{{ paymentData.gemsBlock.gems }}</span> <span>{{ paymentData.gemsBlock.gems }}</span>
</div> </div>
</template> </template>
<!-- buy or gift gems to someone else -->
<template <template
v-if="paymentData.paymentType === 'gift-gems' v-if="paymentData.paymentType === 'gift-gems'
|| paymentData.paymentType === 'gift-gems-balance'" || paymentData.paymentType === 'gift-gems-balance'"
@@ -87,12 +85,16 @@
<span>{{ paymentData.gift.gems.amount }}</span> <span>{{ paymentData.gift.gems.amount }}</span>
</div> </div>
</template> </template>
<!-- give gift subscription (non-recurring)-->
<template v-if="paymentData.paymentType === 'gift-subscription'"> <template v-if="paymentData.paymentType === 'gift-subscription'">
<span <div>
v-html="$t('paymentYouSentSubscription', { <span
name: paymentData.giftReceiver, months: paymentData.subscription.months})" v-html="$t('paymentYouSentSubscription', {
></span> name: paymentData.giftReceiver, months: paymentData.subscription.months})"
></span>
</div>
</template> </template>
<!-- buy self subscription (recurring) -->
<template v-if="paymentData.paymentType === 'subscription'"> <template v-if="paymentData.paymentType === 'subscription'">
<strong v-once>{{ $t('nowSubscribed') }}</strong> <strong v-once>{{ $t('nowSubscribed') }}</strong>
<div class="details-block"> <div class="details-block">
@@ -101,25 +103,37 @@
amount: paymentData.subscription.price, months: paymentData.subscription.months})" amount: paymentData.subscription.price, months: paymentData.subscription.months})"
></span> ></span>
</div> </div>
<div
v-once
class="small-text auto-renew"
>
{{ $t('paymentAutoRenew') }}
</div>
</template> </template>
<!-- buttons for subscriptions -->
<div>
<button
v-if="paymentData.paymentType === 'subscription'
|| paymentData.paymentType === 'gift-subscription'"
class="btn btn-primary"
@click="onwards()"
>
{{ $t('onwards') }}
</button>
</div>
<!-- group plan new or upgraded -->
<template v-if="paymentData.paymentType === 'groupPlan'"> <template v-if="paymentData.paymentType === 'groupPlan'">
<span <span
v-html="$t(paymentData.newGroup v-html="$t(paymentData.newGroup
? 'groupPlanCreated' : 'groupPlanUpgraded', {groupName: paymentData.group.name})" ? 'groupPlanCreated' : 'groupPlanUpgraded', {groupName: paymentData.group.name})"
></span> ></span>
<!--<div class="details-block">
<span
v-html="$t('paymentSubBilling', {
amount: groupPlanCost, months: paymentData.subscription.months})"
></span>
</div> -->
<div <div
v-if="!paymentData.newGroup" v-if="!paymentData.newGroup || paymentData.newGroup"
class="" class=""
> >
<div class="details-block group-billing-date"> <div class="details-block group-billing-date">
<span <span
v-html="$t('groupsPaymentSubBilling')" v-html="$t('groupsPaymentSubBilling', { renewalDate })"
> >
</span> </span>
</div> </div>
@@ -129,55 +143,17 @@
>{{ $t('groupsPaymentAutoRenew') }} >{{ $t('groupsPaymentAutoRenew') }}
</span> </span>
</div> </div>
<!-- this is the demographics code if needed to move back down here from footer
this was working BUT I couldn't get the CSS working which is why I moved it to footer
<div class="demographics">
lockable label needs to be centered
<lockable-label
:text="$t('groupUse')"
/>
<select-translated-array
:items="[
'groupParentChildren',
'groupCouple',
'groupFriends',
'groupCoworkers',
'groupManager',
'groupTeacher'
]"
class="group-input"
:placeholder="'groupUseDefault'"
:value="groupPlanUpgraded.demographics"
@select="groupPlanUpgraded.demographics = $event"
/>
need to add correct :disabled value here 'cause this one ain't working
<button
v-if="!paymentData.newGroup"
class="btn btn-primary"
@click="close()"
>
{{ $t('submit') }}
</button>
</div> -->
</div> </div>
</template> </template>
<template <!-- buy self subscription auto renew -->
<!-- <template
v-if="paymentData.paymentType === 'subscription'" v-if="paymentData.paymentType === 'subscription'"
> >
<span <span
v-once v-once
class="small-text auto-renew" class="small-text auto-renew"
>{{ $t('paymentAutoRenew') }}</span> >{{ $t('paymentAutoRenew') }}</span>
</template> </template> -->
<div>
<button
v-if="paymentData.paymentType === 'subscription'"
class="btn btn-primary"
@click="close()"
>
{{ $t('onwards') }}
</button>
</div>
</div> </div>
</div> </div>
</b-modal> </b-modal>
@@ -294,30 +270,33 @@
font-style: normal; font-style: normal;
} }
} }
.demographics {
background-color: $gray-700;
padding: 16px 0px;
margin-top: -16px;
width: 400px;
display: flex;
flex-direction: column;
justify-content: center;
.btn.btn-primary { .demographics {
margin-top: 24px; background-color: $gray-700;
width: 77px;
align-self: center;
} .label-text {
#lockable-label .modal-footer label { margin-bottom: 20px;
text-align: center !important; }
.group-input {
width: 400px !important; width: 400px !important;
margin-top: -24px !important;
} }
.btn {
margin-top: 0px;
width: 77px;
margin-bottom: 20px;
}
}
</style>
<style lang="scss">
@import '~@/assets/scss/mixins.scss';
}
</style> </style>
<script> <script>
import checkIcon from '@/assets/svg/check.svg'; import checkIcon from '@/assets/svg/check.svg';
import gemIcon from '@/assets/svg/gem.svg'; import gemIcon from '@/assets/svg/gem.svg';
@@ -325,6 +304,7 @@ import subscriptionBlocks from '@/../../common/script/content/subscriptionBlocks
import selectTranslatedArray from '@/components/tasks/modal-controls/selectTranslatedArray'; import selectTranslatedArray from '@/components/tasks/modal-controls/selectTranslatedArray';
import lockableLabel from '@/components/tasks/modal-controls/lockableLabel'; import lockableLabel from '@/components/tasks/modal-controls/lockableLabel';
import paymentsMixin from '@/mixins/payments'; import paymentsMixin from '@/mixins/payments';
import * as Analytics from '@/libs/analytics';
export default { export default {
components: { components: {
@@ -369,11 +349,16 @@ export default {
this.$root.$off('habitica:payments-success'); this.$root.$off('habitica:payments-success');
}, },
methods: { methods: {
close () { submit () {
this.paymentData = {};
this.$root.$emit('bv::hide::modal', 'payments-success-modal');
Analytics.track({ },
console.log(Analytics.track));
},
onwards () {
this.paymentData = {}; this.paymentData = {};
this.$root.$emit('bv::hide::modal', 'payments-success-modal'); this.$root.$emit('bv::hide::modal', 'payments-success-modal');
}, },
// how is amplitude formed?
}, },
}; };
</script> </script>

View File

@@ -39,12 +39,12 @@ export default {
return moment(this.user.purchased.plan.dateTerminated) return moment(this.user.purchased.plan.dateTerminated)
.format(this.user.preferences.dateFormat.toUpperCase()); .format(this.user.preferences.dateFormat.toUpperCase());
}, },
dateRenewal () { renewalDate () {
const renewalDate = moment().add(1, 'months');
if (!this.user.preferences || !this.user.preferences.dateFormat) { if (!this.user.preferences || !this.user.preferences.dateFormat) {
return this.user.purchased.plan.dateRenewal; return renewalDate;
} }
return moment(this.user.purchased.plan.dateRenewal).add(1, 'months') return renewalDate.format(this.user.preferences.dateFormat.toUpperCase());
.format(this.user.preferences.dateFormat.toUpperCase());
}, },
}, },
methods: { methods: {

View File

@@ -93,7 +93,7 @@
"paymentYouSentGems": "You sent <strong><%- name %></strong>:", "paymentYouSentGems": "You sent <strong><%- name %></strong>:",
"paymentYouSentSubscription": "You sent <strong><%- name %></strong> a <%= months %>-months Habitica subscription.", "paymentYouSentSubscription": "You sent <strong><%- name %></strong> a <%= months %>-months Habitica subscription.",
"paymentSubBilling": "Your subscription will be billed <strong>$<%= amount %></strong> every <strong><%= months %> months</strong>.", "paymentSubBilling": "Your subscription will be billed <strong>$<%= amount %></strong> every <strong><%= months %> months</strong>.",
"groupsPaymentSubBilling": "Your next billing date is <strong>11/11/1111</strong>.", "groupsPaymentSubBilling": "Your next billing date is <strong><%= renewalDate %></strong>.",
"paymentSubBillingWithMethod": "Your subscription will be billed <strong>$<%= amount %></strong> every <strong><%= months %> months</strong> via <strong><%= paymentMethod %></strong>.", "paymentSubBillingWithMethod": "Your subscription will be billed <strong>$<%= amount %></strong> every <strong><%= months %> months</strong> via <strong><%= paymentMethod %></strong>.",
"paymentAutoRenew": "This subscription will auto-renew until it is canceled. If you need to cancel this subscription, you can do so from your settings.", "paymentAutoRenew": "This subscription will auto-renew until it is canceled. If you need to cancel this subscription, you can do so from your settings.",
"groupsPaymentAutoRenew": "This subscription will auto-renew until it is canceled. If you need to cancel, you can do so from the Group Billing tab.", "groupsPaymentAutoRenew": "This subscription will auto-renew until it is canceled. If you need to cancel, you can do so from the Group Billing tab.",