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

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

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

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

        $(Wick.Checkout.el.voucherRemove).unbind('click');
    }

    init();
});
