export const pruebasRegistro = async (pacienteNuevo) => { const peticion = `/api/usuarios/previoAgregar`; //verifica si el usuario existe // const contactoEmergencia = `/api/usuarios/agregar_contacto_emergencia`; /*===== Encriptamos la informacion para enviarla al servidor ======*/ const datoEncriptado = await encriptar(pacienteNuevo, process.env.NEXT_PUBLIC_LLAVE); let respAgregado; try { respAgregado = await axios.post(peticion, { data: datoEncriptado }); if (respAgregado.status === 200) { Swal.fire({ icon: 'success', title: 'Registro exitoso', text: 'Se ha enviado un correo electrónico para verificar tu cuenta', confirmButtonText: 'Entendido', }); // window.open(window.location.protocol + "//" + window.location.host + '/login', '_self'); }else{ Swal.fire({ icon: 'error', title: 'Error', text: respAgregado.data, confirmButtonText: 'Entendido', }); } } catch (error) { console.log(error); } }
The function pruebasRegistro has a parameter pacienteNuevo, which is an object that contains the data of the new patient that will be registered. Then it makes a request to the server, this request is to verify if the patient exists in the system, if it does not exist then it is registered, if it exists it will notify the user that the patient exists.