yarn prettier

This commit is contained in:
Rimian Perkins 2019-09-12 07:14:16 +10:00
parent 11b2917254
commit fdd4d1ed5f
9 changed files with 56 additions and 60 deletions

View File

@ -13,30 +13,31 @@ export default Ember.Component.extend({
this.setProperties({
confirmation: false,
currency: settings.discourse_donations_currency,
currency: settings.discourse_donations_currency
});
},
actions: {
closeModal() {
this.set('paymentError', false);
this.set('confirmation', false);
this.set("paymentError", false);
this.set("confirmation", false);
},
handleConfirmStripeCard(paymentMethod) {
this.set('confirmation', paymentMethod);
this.set("confirmation", paymentMethod);
},
confirmStripeCard() {
const paymentMethodId = this.confirmation.id;
this.stripePaymentHandler(paymentMethodId, this.amount).then((paymentIntent) => {
if (paymentIntent.error) {
this.set('paymentError', paymentIntent.error);
this.stripePaymentHandler(paymentMethodId, this.amount).then(
paymentIntent => {
if (paymentIntent.error) {
this.set("paymentError", paymentIntent.error);
} else {
// console.log('ok done');
}
}
else {
// console.log('ok done');
}
});
},
},
);
}
}
});

View File

@ -1,4 +1,3 @@
export default Ember.Component.extend({
init() {
this._super(...arguments);
@ -9,14 +8,14 @@ export default Ember.Component.extend({
cardError: false,
color: jQuery("body").css("color"),
backgroundColor: jQuery("body").css("background-color"),
stripe: Stripe(settings.discourse_patrons_public_key),
stripe: Stripe(settings.discourse_patrons_public_key)
});
},
didInsertElement() {
this._super(...arguments);
const color = this.get('color');
const color = this.get("color");
const style = {
base: {
@ -29,32 +28,33 @@ export default Ember.Component.extend({
const elements = this.stripe.elements();
const card = elements.create("card", { style, hidePostalCode: true });
card.mount('#card-element');
card.mount("#card-element");
this.set("card", card);
card.on("change", (result) => {
this.set('cardError', false);
card.on("change", result => {
this.set("cardError", false);
if(result.error) {
this.set('cardError', result.error.message);
if (result.error) {
this.set("cardError", result.error.message);
}
});
},
actions: {
submitStripeCard() {
this.stripe.createPaymentMethod('card', this.card).then((result) => {
if (result.error) {
this.set('cardError', result.error.message);
this.stripe.createPaymentMethod("card", this.card).then(
result => {
if (result.error) {
this.set("cardError", result.error.message);
} else {
this.handleConfirmStripeCard(result.paymentMethod);
}
},
() => {
this.set("cardError", "Unknown error.");
}
else {
this.handleConfirmStripeCard(result.paymentMethod);
}
}, () => {
this.set('cardError', 'Unknown error.');
});
},
},
);
}
}
});

View File

@ -7,8 +7,8 @@ export default Ember.Controller.extend({
data: { paymentMethodId, amount },
method: "post"
}).catch(() => {
return { error: 'An error occured while submitting the form.' };
return { error: "An error occured while submitting the form." };
});
},
},
}
}
});

View File

@ -1,4 +1 @@
export default Ember.Controller.extend({
});
export default Ember.Controller.extend({});

View File

@ -1,6 +1,5 @@
export default function () {
this.route('patrons', function() {
export default function() {
this.route("patrons", function() {
this.route("show", { path: ":pid" });
});
}

View File

@ -1,3 +1 @@
export default Discourse.Route.extend({
});
export default Discourse.Route.extend({});

View File

@ -1,4 +1,3 @@
.discourse-patrons-section-columns {
display: flex;
justify-content: space-between;
@ -33,7 +32,7 @@
}
}
#card-element{
#card-element {
padding: 20px 0;
}

View File

@ -13,7 +13,10 @@ componentTest("Discourse Patrons donation form has content", {
},
async test(assert) {
assert.ok(find(".discourse-patrons-section-columns").length, "The card section renders");
assert.ok(
find(".discourse-patrons-section-columns").length,
"The card section renders"
);
assert.ok(
find("dummy-component-tag").length,
"The stripe component renders"
@ -25,20 +28,19 @@ componentTest("donation form has a confirmation", {
template: `{{donation-form confirmation=confirmation}}`,
beforeEach() {
this.registry.register(
"component:stripe-card",
Ember.Component.extend()
);
this.registry.register("component:stripe-card", Ember.Component.extend());
},
async test(assert) {
this.set("confirmation", { "card": { "last4": "4242" }});
this.set("confirmation", { card: { last4: "4242" } });
const confirmExists = find(".discourse-donations-confirmation").length;
assert.ok(confirmExists, "The confirmation form renders");
const last4 = find(".discourse-donations-last4").text().trim();
const last4 = find(".discourse-donations-last4")
.text()
.trim();
assert.equal(last4, ".... .... .... 4242", "The last 4 digits are correct");
}

View File

@ -9,7 +9,7 @@ componentTest("Discourse Patrons stripe card success", {
window.Stripe = () => {
return {
createPaymentMethod() {
return new Ember.RSVP.Promise((resolve) => {
return new Ember.RSVP.Promise(resolve => {
resolve({});
});
},
@ -19,11 +19,11 @@ componentTest("Discourse Patrons stripe card success", {
return {
on() {},
card() {},
mount() {},
mount() {}
};
},
}
};
},
}
};
};
},
@ -36,5 +36,5 @@ componentTest("Discourse Patrons stripe card success", {
});
await click(".btn-payment");
},
}
});