mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-26 20:56:48 +00:00
33 lines
799 B
Ruby
33 lines
799 B
Ruby
# frozen_string_literal: true
|
|
|
|
class VoucherAdjustmentsController < BaseController
|
|
include CablecarResponses
|
|
|
|
def destroy
|
|
@order = current_order
|
|
|
|
@order.voucher_adjustments.find_by(id: params[:id])&.destroy
|
|
|
|
respond_to do |format|
|
|
format.cable_ready { render_voucher_section }
|
|
format.html { redirect_to checkout_step_path(:payment) }
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
# Using the power of cable_car we replace only the #voucher_section instead of reloading the page
|
|
def render_voucher_section
|
|
render(
|
|
status: :ok,
|
|
cable_ready: cable_car.replace(
|
|
"#voucher-section",
|
|
partial(
|
|
"split_checkout/voucher_section",
|
|
locals: { order: @order, voucher_adjustment: @order.voucher_adjustments.first }
|
|
)
|
|
)
|
|
)
|
|
end
|
|
end
|