mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Rename stripe cards controller
This commit is contained in:
@@ -3,14 +3,16 @@
|
||||
:javascript
|
||||
angular.module('Darkswarm').value("stripeObject", Stripe("#{Stripe.publishable_key}"))
|
||||
|
||||
%div{"data-controller": "stripe"}
|
||||
%div{"data-controller": "stripe-cards"}
|
||||
- if @saved_credit_cards.length > 0
|
||||
.checkout-input
|
||||
%label
|
||||
= t('split_checkout.step2.form.stripe.use_saved_card')
|
||||
= select_tag :card, options_for_select(@saved_credit_cards.map {|cc| [ "#{cc.brand} #{cc.last_digits} #{I18n.t(:card_expiry_abbreviation)}:#{cc.month.to_s.rjust(2, '0')}/#{cc.year}", cc.id ] } + [[t('split_checkout.step2.form.stripe.create_new_card'), ""]], @selected_card), { "data-action": "change->stripe#onSelectCard", "data-stripe-target": "select" }
|
||||
= select_tag :card,
|
||||
options_for_select(@saved_credit_cards.map {|cc| [ "#{cc.brand} #{cc.last_digits} #{I18n.t(:card_expiry_abbreviation)}:#{cc.month.to_s.rjust(2, '0')}/#{cc.year}", cc.id ] } + [[t('split_checkout.step2.form.stripe.create_new_card'), ""]], @selected_card),
|
||||
{ "data-action": "change->stripe-cards#onSelectCard", "data-stripe-cards-target": "select" }
|
||||
|
||||
.checkout-input{"data-stripe-target": "stripeelements"}
|
||||
.checkout-input{"data-stripe-cards-target": "stripeelements"}
|
||||
- if @saved_credit_cards.length == 0
|
||||
%label
|
||||
= t('split_checkout.step2.form.stripe.use_new_card')
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Controller } from "stimulus";
|
||||
|
||||
// Handles form elements for selecting previously saved Stripe cards from a list of cards
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["stripeelements", "select"];
|
||||
|
||||
@@ -3,21 +3,21 @@
|
||||
*/
|
||||
|
||||
import { Application } from "stimulus";
|
||||
import stripe_controller from "../../../app/webpacker/controllers/stripe_controller";
|
||||
import stripe_cards_controller from "../../../app/webpacker/controllers/stripe_cards_controller";
|
||||
|
||||
describe("StripeController", () => {
|
||||
describe("StripeCardsController", () => {
|
||||
beforeEach(() => {
|
||||
document.body.innerHTML = `<div data-controller="stripe">
|
||||
<select data-action="change->stripe#onSelectCard" id="select">
|
||||
document.body.innerHTML = `<div data-controller="stripe-cards">
|
||||
<select data-action="change->stripe-cards#onSelectCard" id="select">
|
||||
<option value="">Blank</option>
|
||||
<option value="1">Card #1</option>
|
||||
<option value="2">Card #2</option>
|
||||
</select>
|
||||
<div data-stripe-target="stripeelements" id="stripeelements" />
|
||||
<div data-stripe-cards-target="stripeelements" id="stripeelements" />
|
||||
</div>`;
|
||||
|
||||
const application = Application.start();
|
||||
application.register("stripe", stripe_controller);
|
||||
application.register("stripe-cards", stripe_cards_controller);
|
||||
});
|
||||
describe("#connect", () => {
|
||||
it("initialize with the right display state", () => {
|
||||
Reference in New Issue
Block a user