Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

Commit

Permalink
JS formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
rennokki committed Feb 28, 2021
1 parent a4e04ea commit 74954dd
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 21 deletions.
22 changes: 9 additions & 13 deletions stubs/inertia/resources/js/BillingPortal/PlanSlide.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
</template>
<template v-else>
<jet-button
v-if="! currentPlan"
v-if="!currentPlan"
@click.native="subscribeToPlan(plan.id)"
>
Subscribe
Expand Down Expand Up @@ -108,6 +108,7 @@ export default {
JetButton,
JetSecondaryButton,
},
props: [
'plan',
'active',
Expand All @@ -119,42 +120,37 @@ export default {
'endingDate',
'disable',
],
methods: {
/**
* Subscribe to a new plan.
*
* @param string planId
* @return void
* @param {string} planId
*/
subscribeToPlan (planId) {
subscribeToPlan(planId) {
this.$inertia.post(this.route('billing-portal.subscription.plan-subscribe', { plan: planId }));
},
/**
* Swap to a new plan.
*
* @param string planId
* @return void
* @param {string} planId
*/
swapPlan (planId) {
swapPlan(planId) {
this.$inertia.post(this.route('billing-portal.subscription.plan-swap', { plan: planId }));
},
/**
* Cancel the current subscription.
*
* @return void
*/
cancelSubscription () {
cancelSubscription() {
this.$inertia.post(this.route('billing-portal.subscription.cancel'));
},
/**
* Resume the current subscription.
*
* @return void
*/
resumeSubscription () {
resumeSubscription() {
this.$inertia.post(this.route('billing-portal.subscription.resume'));
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ export default {
components: {
AppLayout,
},
props: ['invoices'],
data: () => ({
dateFormatOptions: {
year: 'numeric',
Expand All @@ -84,7 +86,14 @@ export default {
hour12: false,
},
}),
methods: {
/**
* Format the given unix date to a human readable one.
*
* @param {number} unix
*/
formatDate(unix) {
return new Intl.DateTimeFormat('en-GB', this.dateFormatOptions).format(
new Date(unix * 1000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default {
'intent',
'stripe_key',
],
data () {
data() {
return {
stripe: null,
card: null,
Expand All @@ -111,7 +111,7 @@ export default {
cvc: null,
};
},
mounted () {
mounted() {
this.stripe = Stripe(this.stripe_key);
this.card = this.stripe.elements();
Expand Down Expand Up @@ -153,12 +153,15 @@ export default {
this.cvc.mount('#card-cvc');
},
methods: {
async addPaymentMethod () {
/**
* Submit the payment method form.
*/
async addPaymentMethod() {
const { paymentMethod, error } = await this.stripe.createPaymentMethod(
'card', this.number, { billing_details: { name: this.name } }
);
if (! error) {
if (!error) {
this.$inertia.post(this.route('billing-portal.payment-method.store'), { token: paymentMethod.id });
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ export default {
/**
* Set the default payment method.
*
* @param Object method
* @param {Object} method
*/
setAsDefault (method) {
setAsDefault(method) {
this.$inertia.post(
this.route('billing-portal.payment-method.default', { payment_method: method.id })
);
Expand All @@ -115,9 +115,9 @@ export default {
/**
* Delete a payment method.
*
* @param Object method
* @param {Object} method
*/
deletePaymentMethod (method) {
deletePaymentMethod(method) {
this.$inertia.delete(
this.route('billing-portal.payment-method.destroy', { payment_method: method.id })
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default {
JetSecondaryButton,
PlanSlide,
},
props: [
'currentPlan',
'hasDefaultPaymentMethod',
Expand Down

0 comments on commit 74954dd

Please sign in to comment.