forked from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from Arquisoft/Mejorar-IU
Mejorar UI
- Loading branch information
Showing
15 changed files
with
282 additions
and
197 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.footer{ | ||
border-top: 3px solid var(--borders); | ||
width: 100%; | ||
} |
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,81 +1,75 @@ | ||
// src/components/Login.js | ||
import React, { useState } from 'react'; | ||
import axios from 'axios'; | ||
import {useNavigate} from "react-router-dom"; | ||
import './Login.css'; | ||
|
||
import React, { useState } from "react"; | ||
import axios from "axios"; | ||
import { useNavigate } from "react-router-dom"; | ||
import "./Login.css"; | ||
|
||
const Login = () => { | ||
const [username, setUsername] = useState(''); | ||
const [password, setPassword] = useState(''); | ||
const [error, setError] = useState(''); | ||
const [username, setUsername] = useState(""); | ||
const [password, setPassword] = useState(""); | ||
const [error, setError] = useState(""); | ||
const [loginSuccess, setLoginSuccess] = useState(false); | ||
//const [createdAt, setCreatedAt] = useState(''); | ||
const [openSnackbar, setOpenSnackbar] = useState(false); | ||
const navigate = useNavigate(); | ||
|
||
const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000'; | ||
const apiEndpoint = | ||
process.env.REACT_APP_API_ENDPOINT || "http://localhost:8000"; | ||
|
||
const loginUser = async () => { | ||
try { | ||
const response = await axios.post(`${apiEndpoint}/login`, { username, password }); | ||
console.log(response); | ||
// Extract data from the response | ||
//const { createdAt: userCreatedAt } = response.data; | ||
const token = response.data; | ||
|
||
//setCreatedAt(userCreatedAt); | ||
setLoginSuccess(true); | ||
await axios | ||
.post(`${apiEndpoint}/login`, { username, password }) | ||
.then((response) => { | ||
const token = response.data; | ||
|
||
setOpenSnackbar(true); | ||
localStorage.setItem('token', token); | ||
setLoginSuccess(true); | ||
|
||
localStorage.setItem('username', username); | ||
setOpenSnackbar(true); | ||
localStorage.setItem("token", token); | ||
|
||
} catch (error) { | ||
//console.log(error); | ||
setError(error.response.data.error); | ||
} | ||
localStorage.setItem("username", username); | ||
}) | ||
.catch((err) => { | ||
setError(err.message); | ||
}); | ||
}; | ||
|
||
return ( | ||
<div className="login-container"> | ||
{loginSuccess ? ( | ||
navigate("/home") | ||
) : ( | ||
<> | ||
<h1 className="login-header">Login</h1> | ||
<input | ||
className="login-input" | ||
type="text" | ||
placeholder="Username" | ||
value={username} | ||
onChange={(e) => setUsername(e.target.value)} | ||
/> | ||
<input | ||
className="login-input" | ||
type="password" | ||
placeholder="Password" | ||
value={password} | ||
onChange={(e) => setPassword(e.target.value)} | ||
/> | ||
<button className="login-button" onClick={loginUser}> | ||
Login | ||
</button> | ||
{openSnackbar && ( | ||
<div className="login-snackbar"> | ||
Login successful | ||
</div> | ||
)} | ||
{error && ( | ||
<div className="login-error"> | ||
Error: {error} | ||
</div> | ||
)} | ||
</> | ||
)} | ||
<div className="main"> | ||
<div className="login-container"> | ||
{loginSuccess ? ( | ||
navigate("/home") | ||
) : ( | ||
<> | ||
<h1 className="login-header">Identifícate</h1> | ||
<label for="login-username">Introduce tu nombre:</label> | ||
<input | ||
className="login-input" | ||
type="text" | ||
placeholder="Username" | ||
value={username} | ||
onChange={(e) => setUsername(e.target.value)} | ||
/> | ||
<label for="login-password">Introduce tu contraseña:</label> | ||
<input | ||
className="login-input" | ||
type="password" | ||
placeholder="Password" | ||
value={password} | ||
onChange={(e) => setPassword(e.target.value)} | ||
/> | ||
<button className="login-button" onClick={loginUser}> | ||
Login | ||
</button> | ||
{openSnackbar && ( | ||
<div className="login-snackbar">Login successful</div> | ||
)} | ||
{error && <div className="login-error">Error: {error}</div>} | ||
</> | ||
)} | ||
</div> | ||
) | ||
} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Login; |
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,43 +1,42 @@ | ||
.logo { | ||
font-family: oswald, sans-serif; | ||
width: 100%; | ||
font-size: 5rem; | ||
font-weight: 700; | ||
margin: 0; | ||
text-shadow: 4px 4px 0 var(--shadow); | ||
nav .logo{ | ||
margin-left: 3rem; | ||
} | ||
|
||
nav { | ||
width: 80vw; | ||
display: flex; | ||
flex-wrap: wrap; | ||
border: 3px solid var(--borders); | ||
border-radius: 1rem; | ||
padding: 1rem; | ||
width: 100%; | ||
display: grid; | ||
grid-auto-flow: column; | ||
border-bottom: 3px solid var(--borders); | ||
justify-content: space-between; | ||
align-items: center; | ||
} | ||
|
||
nav * { | ||
margin: 1rem; | ||
justify-content: center; | ||
-webkit-box-shadow: 10px 10px 5px 0px var(--shadow); | ||
-moz-box-shadow: 10px 10px 5px 0px var(--shadow); | ||
box-shadow: 10px 10px 5px 0px var(--shadow); | ||
} | ||
|
||
nav ul { | ||
display: flex; | ||
justify-content: center; | ||
flex-direction: row; | ||
.menuItems *, .rightItems * { | ||
height: 100%; | ||
} | ||
|
||
nav li { | ||
display: flex; | ||
flex-direction: row; | ||
.rightItems{ | ||
display: grid; | ||
grid-auto-flow: column; | ||
column-gap: 2rem; | ||
align-items: center; | ||
} | ||
|
||
.disconnect{ | ||
margin-left: auto; | ||
} | ||
|
||
.theme-toggle{ | ||
width: 5%; | ||
height: 10%; | ||
margin-left: 90%; | ||
background-size: contain; | ||
} | ||
|
||
.disconnect{ | ||
margin-left: 70%; | ||
.progressBar{ | ||
background-color: var(--shadow); | ||
height: 1rem; | ||
border-radius: 1rem; | ||
margin-top: 0.5rem; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.register-container{ | ||
display: grid; | ||
grid-template-columns: 1fr; | ||
gap: 1rem; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.register-container label{ | ||
margin-top: 1rem; | ||
} | ||
|
||
.register-button{ | ||
box-shadow: none; | ||
} |
Oops, something went wrong.