@extends('layouts.baseacceso') @section('titulo', 'Iniciar Sesion') @push('CSS') @endpush @section('contenido')
@endsection @push('JS') @endpush @push('JSOR') // Toggle para mostrar/ocultar contraseña $('#togglePassword').on("click", function(){ const passwordField = $("#password"); const passwordFieldType = passwordField.attr("type"); const toggleIcon = $(this).find('i'); if( passwordFieldType === "password" ){ passwordField.attr("type", "text"); toggleIcon.removeClass("bi-eye").addClass("bi-eye-slash"); } else{ passwordField.attr("type", "password"); toggleIcon.removeClass("bi-eye-slash").addClass("bi-eye"); } }); $("#frmAcceso").on("submit", function(e){ e.preventDefault(); cambiarEstadoBoton(true); $.ajax({ url: $(this).attr("action"), method: "POST", data: $(this).serialize(), success: function(response){ Swal.fire({ icon: "success", title: "¡Bienvenido!", text: "Acceso concedido correctamente", timer: 1500, showConfirmButton: false, timerProgressBar: true }).then(() => { window.location.href = response.redirect || "/dashboard"; }); }, error: function(xhr){ cambiarEstadoBoton(false); if( xhr.status == 422 ){ location.reload(); } else if( xhr.status == 401 ){ Swal.fire({ icon: "error", title: "Acceso denegado", text: "Las credenciales ingresadas son incorrectas", confirmButtonText: "Intentar de nuevo" }); } else{ Swal.fire({ icon: "error", title: "Error del sistema", text: "Ocurrió un problema, intenta más tarde", confirmButtonText: "Aceptar" }); } } }); }); @endpush