<?php
/* @var \Magetop\Advancepreview\Block\AdvancePreview $block */
?>

<script>
    require([
        'jquery'
    ],function ($) {
        var customRegister = {
            version: '2.5.0',
            init : function () {
                $('#assistance_allowed_checkbox').parent('div').css('display','none');
                $('#advanced-preview-customer-types ul li input').click(function () {
                    var type = $(this).val();
                    // $('#assistance_allowed_checkbox').parent('div').css('display','none');
                    console.log(type);
                    // $('#custom-fields-b2c').css('display','block');
                    console.log(type);
                    if(type === '4' || type === '2') {
                        $('#custom-fields-big').css('display','block');
                        if(type === '2') {
                            $('#txt-register-is-seller').prop('checked',false);
                            $('#mgt-custom-additnation-filed-taxvat').css('display','block');
                        }
                    }
                    else {
                        $('#custom-fields-big').css('display','none');
                    }
                    $('#txt-customer-group').val(type);

                })
                $('#txt-register-is-seller').click(function () {
                    var isSeller = $(this).is(":checked");
                    // console.log("click clikc",isSeller)
                    var isSaleDisplay = isSeller ? 'none' : 'block';
                    $('#mgt-custom-additnation-filed-taxvat').css('display',isSaleDisplay);
                    if(isSeller) {
                        // $('#custom-customer-type-reseller').prop("checked",true);
                        // $('#mgt-custom-additnation-filed-taxvat').val('')
                        $('#custom-taxvat').val('');
                        $('#txt-customer-group').val(4);
                    }
                    else {
                        $('#custom-customer-type-big').prop("checked",true);
                        $('#txt-customer-group').val(2);
                    }
                })
            }
        }
        customRegister.init();
    })
</script>
