From 3f83da992838f9a5bdf2abf0e1e650226828ac60 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 2 Jun 2023 00:20:19 +0100 Subject: [PATCH] Move voucher section out of main checkout form --- app/views/split_checkout/_payment.html.haml | 8 +++-- .../_voucher_section.cable_ready.haml | 35 +++++++++---------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/app/views/split_checkout/_payment.html.haml b/app/views/split_checkout/_payment.html.haml index a85fe0d922..fb626ae4f9 100644 --- a/app/views/split_checkout/_payment.html.haml +++ b/app/views/split_checkout/_payment.html.haml @@ -1,8 +1,10 @@ -= form_with url: checkout_update_path(checkout_step), model: @order, method: :put, data: { remote: "true" } do |f| - .medium-6 - %div.checkout-substep{"data-controller": "paymentmethod"} +.medium-6 + - if @order.distributor.vouchers.present? + %div.checkout-substep = render partial: "split_checkout/voucher_section", formats: [:cable_ready], locals: { order: @order, voucher_adjustment: @voucher_adjustment } + = form_with url: checkout_update_path(checkout_step), model: @order, method: :put, data: { remote: "true" } do |f| + %div.checkout-substep{"data-controller": "paymentmethod"} %div.checkout-title = t("split_checkout.step2.payment_method.title") diff --git a/app/views/split_checkout/_voucher_section.cable_ready.haml b/app/views/split_checkout/_voucher_section.cable_ready.haml index a005b5698b..059acfa00a 100644 --- a/app/views/split_checkout/_voucher_section.cable_ready.haml +++ b/app/views/split_checkout/_voucher_section.cable_ready.haml @@ -1,19 +1,18 @@ %div#voucher-section - - if order.distributor.vouchers.present? - .checkout-title - = t("split_checkout.step2.voucher.apply_voucher") - .checkout-input - .two-columns-inputs.voucher{"data-controller": "toggle-button-disabled"} - - if voucher_adjustment.present? - %span.button.voucher-added - %i.ofn-i_051-check-big - = t("split_checkout.step2.voucher.voucher", voucher_amount: voucher_adjustment.originator.display_value) - = link_to t("split_checkout.step2.voucher.remove_code"), voucher_adjustment_path(id: voucher_adjustment.id), method: "delete", data: { confirm: t("split_checkout.step2.voucher.confirm_delete") } - - # This might not be true, ie payment method including a fee which wouldn't be covered by voucher or tax implication raising total to be bigger than the voucher amount ? - - if voucher_adjustment.originator.amount > order.total - .checkout-input - %span.formError.standalone - = t("split_checkout.step2.voucher.warning_forfeit_remaining_amount") - - else - = text_field_tag "[order][voucher_code]", params.dig(:order, :voucher_code), data: { action: "input->toggle-button-disabled#inputIsChanged", }, placeholder: t("split_checkout.step2.voucher.placeholder") , class: "voucher" - = submit_tag t("split_checkout.step2.voucher.apply"), name: "apply_voucher", disabled: true, class: "button cancel voucher", "data-disable-with": false, data: { "toggle-button-disabled-target": "button" } + .checkout-title + = t("split_checkout.step2.voucher.apply_voucher") + .checkout-input + .two-columns-inputs.voucher{"data-controller": "toggle-button-disabled"} + - if voucher_adjustment.present? + %span.button.voucher-added + %i.ofn-i_051-check-big + = t("split_checkout.step2.voucher.voucher", voucher_amount: voucher_adjustment.originator.display_value) + = link_to t("split_checkout.step2.voucher.remove_code"), voucher_adjustment_path(id: voucher_adjustment.id), method: "delete", data: { confirm: t("split_checkout.step2.voucher.confirm_delete") } + - # This might not be true, ie payment method including a fee which wouldn't be covered by voucher or tax implication raising total to be bigger than the voucher amount ? + - if voucher_adjustment.originator.amount > order.total + .checkout-input + %span.formError.standalone + = t("split_checkout.step2.voucher.warning_forfeit_remaining_amount") + - else + = text_field_tag "[order][voucher_code]", params.dig(:order, :voucher_code), data: { action: "input->toggle-button-disabled#inputIsChanged", }, placeholder: t("split_checkout.step2.voucher.placeholder") , class: "voucher" + = submit_tag t("split_checkout.step2.voucher.apply"), name: "apply_voucher", disabled: true, class: "button cancel voucher", "data-disable-with": false, data: { "toggle-button-disabled-target": "button" }