Registro correcto

Buen funcionamiento del registro del admin del sistema
This commit is contained in:
Traym17 2022-07-12 23:15:34 -06:00
parent 9804bd2842
commit de2418cc52
1 changed files with 16 additions and 22 deletions

View File

@ -1,25 +1,20 @@
import React, { useState } from 'react'; import React, { useRef, useState } from 'react';
import { InputText } from 'primereact/inputtext'; import { InputText } from 'primereact/inputtext';
import { Button } from 'primereact/button'; import { Button } from 'primereact/button';
const FormAdminSistema = () => { const FormAdminSistema = () => {
async function fetchP(){
var data = {
dni: "12687",
name: "hola",
last_name: "buuu",
email: "tmora4c@ucenfotec.ac.cr",
phone: 84664515,
password: "1203",
user_type: "1",
status: "2"
};
console.log(data);
let result=await fetch('https://pokeapi.co/api/v2/pokemon?limit=10&offset=0', {method:'GET'});
}
function registrarAdmin() { function registrarAdmin() {
var data2 = {
dni: document.getElementById('identificacion').value,
name: document.getElementById('nombre').value,
last_name: document.getElementById('apellidos').value,
email: document.getElementById('correo_electronico').value,
phone: document.getElementById('telefono').value,
password: document.getElementById('correo_electronico').value,
user_type: "1",
status: "2"
};
console.log(data2);
var data = { var data = {
dni: "12687", dni: "12687",
name: "hola", name: "hola",
@ -30,18 +25,17 @@ const FormAdminSistema = () => {
user_type: "1", user_type: "1",
status: "2" status: "2"
}; };
console.log(data);
fetch('http://localhost:4000/user/createAdminSystem/', { fetch('http://localhost:4000/user/createAdminSystem/', {
cache: 'no-cache', cache: 'no-cache',
method: 'POST', method: 'POST',
body: JSON.stringify(data), body: JSON.stringify(data2),
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
}) })
.then( .then(
function (response) { function (response) {
if (response.status != 200) if (response.status != 201)
console.log('Ocurrió un error con el servicio: ' + response.status); console.log('Ocurrió un error con el servicio: ' + response.status);
else else
return response.json(); return response.json();
@ -49,7 +43,7 @@ const FormAdminSistema = () => {
) )
.then( .then(
function (response) { function (response) {
console.log(response); console.log(response.message);
} }
) )
.catch( .catch(
@ -81,7 +75,7 @@ const FormAdminSistema = () => {
</div> </div>
<div className="field col-12"> <div className="field col-12">
<label htmlFor="telefono">Teléfono</label> <label htmlFor="telefono">Teléfono</label>
<InputText id="telefono" type="text" rows="4" /> <InputText id="telefono" type="number" rows="4" />
</div> </div>
<Button label="Registrar" onClick={registrarAdmin}></Button> <Button label="Registrar" onClick={registrarAdmin}></Button>
</div> </div>