var Wick = Wick || {};

Wick.SelectAddress = function () {

    const selectAddressVar = {
        $removeAddressBtn: $('.btn-remove-address'),
        $userAddressDelete: $('.user-address__delete'),
        $userAddressBlock: $('.user-address')
    };

    function init () {
        selectAddressVar.$removeAddressBtn.on('click', function() {
            $(this).closest(selectAddressVar.$userAddressBlock).find(selectAddressVar.$userAddressDelete).removeClass('d-none');
            $(this).closest(selectAddressVar.$userAddressBlock).find(selectAddressVar.$removeAddressBtn).addClass('d-none');


            $(this).closest(selectAddressVar.$userAddressBlock).find('.user-address__delete-action .btn-secondary').on('click', function() {
                $(this).closest(selectAddressVar.$userAddressBlock).find(selectAddressVar.$userAddressDelete).addClass('d-none');
                $(this).closest(selectAddressVar.$userAddressBlock).find(selectAddressVar.$removeAddressBtn).removeClass('d-none');
            });
        });
    }

  init();
}();
