/* global jQuery */
(function ($) {
  "use strict";

  $(function () {
    const $form = $("#adminEntityForm");
    const $feedback = $("#formFeedback");

    $form.on("submit", function (e) {
      e.preventDefault();

      if (!this.checkValidity()) {
        e.stopPropagation();
        $form.addClass("was-validated");
        $feedback
          .removeClass("d-none alert-success")
          .addClass("alert-danger")
          .text("Please review the highlighted fields and try again.");
        return;
      }

      $form.addClass("was-validated");
      $feedback
        .removeClass("d-none alert-danger")
        .addClass("alert-success")
        .text("Form is valid and ready for API submission.");
    });
  });
})(jQuery);
