-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version 1.5.0 - System login/register OK Firts Update
- Loading branch information
1 parent
d4d078e
commit ed07939
Showing
10 changed files
with
416 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,89 @@ | ||
import React from 'react'; | ||
import React, { useState } from 'react'; | ||
|
||
export default function useFecth() { | ||
|
||
const [Type, setType] = useState('Ti') | ||
const [User, setUser] = useState(''); | ||
const [Password, setPassword] = useState(''); | ||
const [Nombre, setNombre] = useState(''); | ||
const [Apellido, setApellido] = useState(''); | ||
const [responce, setResponce] = useState(false); | ||
|
||
const inputUser = (event) => { | ||
setUser(event.target.value); | ||
} | ||
|
||
const inputPass = (event) => { | ||
setPassword(event.target.value); | ||
} | ||
|
||
//Change the type of document | ||
const changeType = (event) => { | ||
console.log(event.target.value); | ||
setType(event.target.value); | ||
} | ||
|
||
const inputNombre = (event) => { | ||
setNombre(event.target.value); | ||
} | ||
|
||
const inputApellido = (event) => { | ||
setApellido(event.target.value); | ||
} | ||
|
||
const login = () => { | ||
|
||
console.log('Login'); | ||
|
||
fetch('http://localhost:4000/', { | ||
method: "POST", | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
type: Type, | ||
id: User, | ||
pass: Password | ||
}) | ||
}) | ||
.then(res => res.json()) | ||
.then(res => { | ||
res.validate === true | ||
? //If | ||
window.localStorage.setItem('SessionID', User) | ||
: //Else | ||
setResponce(false) | ||
}) | ||
.catch(e => console.log(e)); | ||
|
||
} | ||
|
||
const register = () => { | ||
|
||
fetch('http://localhost:4000/', { | ||
method: "PUT", | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
type: Type, | ||
id: User, | ||
pass: Password, | ||
nombre: Nombre, | ||
apellido: Apellido | ||
}) | ||
}) | ||
.then(res => res.json()) | ||
.then(res => { | ||
res.register === 'Succesfull Register' | ||
? //If | ||
setResponce(true) | ||
:// Else | ||
setResponce(false) | ||
}) | ||
.catch(e => console.log(e)); | ||
} | ||
|
||
return { login, register, inputPass, inputUser, changeType, inputNombre, inputApellido } | ||
|
||
} |
Oops, something went wrong.
ed07939
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
sofia-plus-remake – ./
sofia-plus-remake-sena-tech.vercel.app
sofia-plus-remake-git-main-sena-tech.vercel.app
sofia-plus-remake.vercel.app