mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-08 22:56:06 +00:00
Move select-options-formatting logic to helper
This commit is contained in:
@@ -143,4 +143,13 @@ module CheckoutHelper
|
||||
def checkout_step?(step)
|
||||
checkout_step == step.to_s
|
||||
end
|
||||
|
||||
def stripe_card_options(cards)
|
||||
cards.map do |cc|
|
||||
[
|
||||
"#{cc.brand} #{cc.last_digits} #{I18n.t(:card_expiry_abbreviation)}:#{cc.month.to_s.rjust(2, '0')}/#{cc.year}",
|
||||
cc.id
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
%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),
|
||||
options_for_select(stripe_card_options(@saved_credit_cards) + [[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-cards-target": "stripeelements"}
|
||||
|
||||
Reference in New Issue
Block a user