/**
 * Admin notices.
 *
 * @package northmill-online-shared
 */

/* global northmill_online_shared_admin_general_admin_notices */

jQuery( document ).on(
	'ready',
	function () {
		new NMF_Admin_Notices();
	}
);

class NMF_Admin_Notices {
	constructor() {
		jQuery( document ).on( 'click', '.is-dismissible.northmill-admin-notice .notice-dismiss', this.on_dismiss );
	}

	on_dismiss( event ) {
		const $dismiss_btn = jQuery( event.currentTarget );
		const $notice      = $dismiss_btn.closest( '.northmill-admin-notice' );
		NMS_AJAX.post(
			northmill_online_shared_admin_general_admin_notices.closed_ajax,
			{
				notice_key: $notice.data( 'notice-key' ),
			}
		);
	}
}
