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({ this.setProperties({
confirmation: false, confirmation: false,
currency: settings.discourse_donations_currency, currency: settings.discourse_donations_currency
}); });
}, },
actions: { actions: {
closeModal() { closeModal() {
this.set('paymentError', false); this.set("paymentError", false);
this.set('confirmation', false); this.set("confirmation", false);
}, },
handleConfirmStripeCard(paymentMethod) { handleConfirmStripeCard(paymentMethod) {
this.set('confirmation', paymentMethod); this.set("confirmation", paymentMethod);
}, },
confirmStripeCard() { confirmStripeCard() {
const paymentMethodId = this.confirmation.id; const paymentMethodId = this.confirmation.id;
this.stripePaymentHandler(paymentMethodId, this.amount).then((paymentIntent) => { this.stripePaymentHandler(paymentMethodId, this.amount).then(
paymentIntent => {
if (paymentIntent.error) { if (paymentIntent.error) {
this.set('paymentError', paymentIntent.error); this.set("paymentError", paymentIntent.error);
} } else {
else {
// console.log('ok done'); // console.log('ok done');
} }
}); }
}, );
}, }
}
}); });

View File

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

View File

@ -7,8 +7,8 @@ export default Ember.Controller.extend({
data: { paymentMethodId, amount }, data: { paymentMethodId, amount },
method: "post" method: "post"
}).catch(() => { }).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() {
export default function () { this.route("patrons", function() {
this.route('patrons', function() {
this.route("show", { path: ":pid" }); 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 { .discourse-patrons-section-columns {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
@ -33,7 +32,7 @@
} }
} }
#card-element{ #card-element {
padding: 20px 0; padding: 20px 0;
} }

View File

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

View File

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