From 65399f816aeb801ace04e36b378a47806c904a11 Mon Sep 17 00:00:00 2001 From: Rizal Fadil Date: Mon, 21 Aug 2023 10:26:34 +0000 Subject: [PATCH] Add uim.js --- .../mix/custom/authentication/sign-in/uim.js | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 resources/mix/custom/authentication/sign-in/uim.js diff --git a/resources/mix/custom/authentication/sign-in/uim.js b/resources/mix/custom/authentication/sign-in/uim.js new file mode 100644 index 0000000..1dbfe81 --- /dev/null +++ b/resources/mix/custom/authentication/sign-in/uim.js @@ -0,0 +1,60 @@ +"use strict"; +var KTSigninGeneral = function () { + var t, e, r; + return { + init: function () { + t = document.querySelector("#kt_sign_in_form"), e = document.querySelector("#kt_sign_in_submit"), r = FormValidation.formValidation(t, { + fields: { + email: { + validators: { + notEmpty: {message: "User ID is required"} + } + }, password: {validators: {notEmpty: {message: "The password is required"}}} + }, + plugins: { + trigger: new FormValidation.plugins.Trigger, + bootstrap: new FormValidation.plugins.Bootstrap5({ + rowSelector: ".fv-row", + eleInvalidClass: "", + eleValidClass: "" + }) + } + }), e.addEventListener("click", (function (i) { + i.preventDefault(), r.validate().then((function (r) { + "Valid" == r ? (e.setAttribute("data-kt-indicator", "on"), e.disabled = !0, axios.post(e.closest("form").getAttribute("action"), new FormData(t)).then((function (e) { + if (e) { + t.reset(); + const e = t.getAttribute("data-kt-redirect-url"); + e && (location.href = e) + } else Swal.fire({ + text: "Sorry, the email or password is incorrect, please try again.", + icon: "error", + buttonsStyling: !1, + confirmButtonText: "Ok, got it!", + customClass: {confirmButton: "btn btn-primary"} + }) + })).catch((function (t) { + Swal.fire({ + text: "Sorry, looks like there are some errors detected, please try again.", + icon: "error", + buttonsStyling: !1, + confirmButtonText: "Ok, got it!", + customClass: {confirmButton: "btn btn-primary"} + }) + })).then((() => { + e.removeAttribute("data-kt-indicator"), e.disabled = !1 + }))) : Swal.fire({ + text: "Sorry, looks like there are some errors detected, please try again.", + icon: "error", + buttonsStyling: !1, + confirmButtonText: "Ok, got it!", + customClass: {confirmButton: "btn btn-primary"} + }) + })) + })) + } + } +}(); +KTUtil.onDOMContentLoaded((function () { + KTSigninGeneral.init() +}));