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/subscription/cancel-subscription.js
2017-11-03 16:26:07 +11:00

49 lines
1.1 KiB
JavaScript
Vendored

module.exports = {
props: ['user', 'team', 'billableType'],
/**
* The component's data.
*/
data() {
return {
form: new SparkForm({})
};
},
methods: {
/**
* Confirm the cancellation operation.
*/
confirmCancellation() {
$('#modal-confirm-cancellation').modal('show');
},
/**
* Cancel the current subscription.
*/
cancel() {
Spark.delete(this.urlForCancellation, this.form)
.then(() => {
Bus.$emit('updateUser');
Bus.$emit('updateTeam');
$('#modal-confirm-cancellation').modal('hide');
});
}
},
computed: {
/**
* Get the URL for the subscription cancellation.
*/
urlForCancellation() {
return this.billingUser
? '/settings/subscription'
: `/settings/${Spark.pluralTeamString}/${this.team.id}/subscription`;
}
}
};