import Plugin from 'src/plugin-system/plugin.class';

export default class BcAquaNewsLetterForm extends Plugin {
    init() {
        this._form = this.el.querySelector('form');
        this._emailInput = this.el.querySelector('input[type="email"]');

        if (this._form) {
            this._form.addEventListener('submit', this._onSubmit.bind(this));
        }
    }

    _onSubmit() {
        event.preventDefault();
        setTimeout(() => {
            const successMessage = this.el.querySelector('.alert-info');

            if (successMessage && this._emailInput) {
                this._emailInput.value = '';
            }
        }, 1000);
    }
}