var Wick = window.Wick || {};

Wick.BusinessType = {
    el: {
        radios: 'input[name="businessType"]',
        panels: '.radio-expanded-content',
        hiddenClass: 'd-none',
    },

    refreshPanels() {
        const $radios = $(this.el.radios);
        const $panels = $(this.el.panels);
        const $checked = $radios.filter(':checked');

        $panels.addClass(this.el.hiddenClass);
        if (!$checked.length) {
            return;
        }

        const selectedValue = $checked.val();
        $(`#${selectedValue}-fields`).removeClass(this.el.hiddenClass);
    },

    bindEvents() {
        $(document).on('change', this.el.radios, this.refreshPanels.bind(this));
    },

    init() {
        if (!$(this.el.radios).length) {
            return;
        }
        this.refreshPanels();
        this.bindEvents();
    },
};

$(document).ready(function () {
    Wick.BusinessType.init();
});
