(($) => {
  $(() => {
    const dismissNotice = (delay) => {
      return $.post(dcatl_ajax_obj.ajax_url, {
        action: 'dcatl_review_dismiss',
        nonce: dcatl_ajax_obj.nonce,
        delay,
      }).done(() => {
        $('.dcatl-notice-review').fadeOut(150, function () {
          $(this).remove();
        });
      });
    };

    $('.dcatl-review-write-btn').on('click', () => {
      dismissNotice('year');
    });

    $('.dcatl-review-done-btn').on('click', (event) => {
      event.preventDefault();
      dismissNotice('year');
    });

    $('.dcatl-review-dismiss-btn').on('click', (event) => {
      event.preventDefault();
      dismissNotice('month');
    });
  });
})(jQuery);
