This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
site-base/spark/resources/assets/js/settings/payment-method/redeem-coupon.js
2017-11-03 16:26:07 +11:00

42 lines
905 B
JavaScript
Vendored

module.exports = {
props: ['user', 'team', 'billableType'],
/**
* The component's data.
*/
data() {
return {
form: new SparkForm({
coupon: ''
})
};
},
methods: {
/**
* Redeem the given coupon code.
*/
redeem() {
Spark.post(this.urlForRedemption, this.form)
.then(() => {
this.form.coupon = '';
this.$parent.$emit('updateDiscount');
});
}
},
computed: {
/**
* Get the URL for redeeming a coupon.
*/
urlForRedemption() {
return this.billingUser
? '/settings/payment-method/coupon'
: `/settings/${Spark.pluralTeamString}/${this.team.id}/payment-method/coupon`;
}
}
};