mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
feat(admin): interactive subscription section fields
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<subscription-and-perks
|
<subscription-and-perks
|
||||||
:subscription="hero.purchased.plan"
|
:hero="hero"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<cron-and-auth
|
<cron-and-auth
|
||||||
|
|||||||
@@ -8,58 +8,113 @@
|
|||||||
Subscription, Monthly Perks
|
Subscription, Monthly Perks
|
||||||
</h3>
|
</h3>
|
||||||
<div v-if="expand">
|
<div v-if="expand">
|
||||||
<div v-if="subscription.paymentMethod">
|
<form @submit.prevent="saveHero({hero, msg: 'Subscription Perks'})">
|
||||||
Payment Method:
|
<div v-if="hero.purchased.plan.paymentMethod">
|
||||||
<strong>{{ subscription.paymentMethod }}</strong>
|
Payment method:
|
||||||
|
<strong>{{ hero.purchased.plan.paymentMethod }}</strong>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="subscription.planId">
|
<div v-if="hero.purchased.plan.planId">
|
||||||
Payment Schedule ("basic-earned" is monthly):
|
Payment schedule ("basic-earned" is monthly):
|
||||||
<strong>{{ subscription.planId }}</strong>
|
<strong>{{ hero.purchased.plan.planId }}</strong>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="subscription.dateCreated">
|
<div v-if="hero.purchased.plan.dateCreated">
|
||||||
Creation Date:
|
Creation date:
|
||||||
<strong>{{ moment(subscription.dateCreated).format('YYYY/MM/DD') }}</strong>
|
<strong>{{ dateFormat(hero.purchased.plan.dateCreated) }}</strong>
|
||||||
</div>
|
|
||||||
<div v-if="subscription.dateTerminated">
|
|
||||||
Termination Date:
|
|
||||||
<strong>{{ moment(subscription.dateTerminated).format('YYYY/MM/DD') }}</strong>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
Consecutive Months:
|
Termination date:
|
||||||
<strong>{{ subscription.consecutive.count }}</strong>
|
<strong
|
||||||
|
v-if="hero.purchased.plan.dateTerminated"
|
||||||
|
>
|
||||||
|
{{ dateFormat(hero.purchased.plan.dateTerminated) }}
|
||||||
|
</strong>
|
||||||
|
<strong v-else> None </strong>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
Months Until Renewal:
|
Consecutive months:
|
||||||
<strong>{{ subscription.consecutive.offset }}</strong>
|
<strong>{{ hero.purchased.plan.consecutive.count }}</strong>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
Gem Cap:
|
Months until renewal:
|
||||||
<strong>{{ subscription.consecutive.gemCapExtra + 25 }}</strong>
|
<strong>{{ hero.purchased.plan.consecutive.offset || 1}}</strong>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
Next Mystic Hourglass:
|
||||||
|
<strong>{{ nextHourGlassDate }}</strong>
|
||||||
|
</div>
|
||||||
|
<div class="form-inline">
|
||||||
|
<label>
|
||||||
|
Mystic Hourglasses:
|
||||||
|
<input
|
||||||
|
v-model="hero.purchased.plan.consecutive.trinkets"
|
||||||
|
class="form-control"
|
||||||
|
type="number"
|
||||||
|
min="0"
|
||||||
|
step="1"
|
||||||
|
>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
Gem cap:
|
||||||
|
<strong>{{ hero.purchased.plan.consecutive.gemCapExtra + 25 }}</strong>
|
||||||
|
</div>
|
||||||
|
<div class="form-inline">
|
||||||
|
<label>
|
||||||
|
Gems bought this month:
|
||||||
|
<input
|
||||||
|
v-model="hero.purchased.plan.gemsBought"
|
||||||
|
class="form-control"
|
||||||
|
type="number"
|
||||||
|
min="0"
|
||||||
|
:max="hero.purchased.plan.consecutive.gemCapExtra + 25"
|
||||||
|
step="1"
|
||||||
|
>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="subscription.extraMonths > 0"
|
v-if="hero.purchased.plan.extraMonths > 0"
|
||||||
>
|
>
|
||||||
Additional Credit (applied upon cancellation):
|
Additional credit (applied upon cancellation):
|
||||||
<strong>{{ subscription.extraMonths }}</strong>
|
<strong>{{ hero.purchased.plan.extraMonths }}</strong>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
Mystery Items:
|
Mystery Items:
|
||||||
<span
|
<span
|
||||||
v-for="(item, index) in subscription.mysteryItems"
|
v-if="hero.purchased.plan.mysteryItems.length > 0"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
v-for="(item, index) in hero.purchased.plan.mysteryItems"
|
||||||
:key="index"
|
:key="index"
|
||||||
>
|
>
|
||||||
<strong v-if="index < subscription.mysteryItems.length"> {{ item }}, </strong>
|
<strong v-if="index < hero.purchased.plan.mysteryItems.length - 1">
|
||||||
|
{{ item }},
|
||||||
|
</strong>
|
||||||
<strong v-else> {{ item }} </strong>
|
<strong v-else> {{ item }} </strong>
|
||||||
</span>
|
</span>
|
||||||
|
</span>
|
||||||
|
<span v-else>
|
||||||
|
<strong>None</strong>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<input
|
||||||
|
type="submit"
|
||||||
|
value="Save"
|
||||||
|
class="btn btn-primary mt-1"
|
||||||
|
>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import moment from 'moment';
|
||||||
|
import saveHero from '../mixins/saveHero';
|
||||||
|
import { getPlanContext } from '@/../../common/script/cron';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
mixins: [saveHero],
|
||||||
props: {
|
props: {
|
||||||
subscription: {
|
hero: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
@@ -69,5 +124,17 @@ export default {
|
|||||||
expand: false,
|
expand: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
nextHourGlassDate () {
|
||||||
|
const currentPlanContext = getPlanContext(this.hero, new Date());
|
||||||
|
|
||||||
|
return currentPlanContext.nextHourglassDate.format('MMMM');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
dateFormat (date) {
|
||||||
|
return moment(date).format('YYYY/MM/DD');
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -273,6 +273,15 @@ api.updateHero = {
|
|||||||
hero.balance = updateData.balance;
|
hero.balance = updateData.balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (updateData.purchased && updateData.purchased.plan) {
|
||||||
|
if (updateData.purchased.plan.gemsBought) {
|
||||||
|
hero.purchased.plan.gemsBought = updateData.purchased.plan.gemsBought;
|
||||||
|
}
|
||||||
|
if (updateData.purchased.plan.consecutive && updateData.purchased.plan.consecutive.trinkets) {
|
||||||
|
hero.purchased.plan.consecutive.trinkets = updateData.purchased.plan.consecutive.trinkets;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// give them gems if they got an higher level
|
// give them gems if they got an higher level
|
||||||
// tier = level in this context
|
// tier = level in this context
|
||||||
let newTier = updateData.contributor && updateData.contributor.level;
|
let newTier = updateData.contributor && updateData.contributor.level;
|
||||||
|
|||||||
Reference in New Issue
Block a user