import {checkVoucherCode, voucherRemove} from './components/voucher/voucher';

var Wick = window.Wick || {};
Wick.MergeCheckout = {
    el: {
        $voucherFormBtn: $('#form-checkout-voucher .voucher__btn'),
        orderSummary: '.checkout-widget_order-summary',
        voucherRemove: '.checkout-widget__voucher-remove',
    },
};

$(document).ready(function () {
    function init() {
        if (!$('.page_checkout').length) {
            return;
        }

        Wick.MergeCheckout.el.$voucherFormBtn.on('click', checkVoucherCode);
        $(Wick.MergeCheckout.el.orderSummary).on('click', Wick.MergeCheckout.el.voucherRemove, voucherRemove);

        $(Wick.MergeCheckout.el.voucherRemove).unbind('click');

    }

    init();
});
