forked from b00tc4mp/isdi-parttime-202309
-
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.
add Profile and Upload page b00tc4mp#382
- Loading branch information
Abel Prieto
committed
Mar 2, 2024
1 parent
e629cda
commit cb1ee75
Showing
9 changed files
with
158 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
77 changes: 77 additions & 0 deletions
77
staff/abel-prieto/PROYECT/HiInit/src/components/Password.jsx
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,6 +1,83 @@ | ||
import { useState } from 'react' | ||
|
||
function Password() { | ||
// FIELDS STATE | ||
const [showPassword, setShowPassword] = useState(true) | ||
const [showNewPassword, setShowNewPassword] = useState(false) | ||
const [showRepeatNewPass, setShowRepeatNewPass] = useState(false) | ||
|
||
function showInputNewPassword() { | ||
setShowNewPassword(true) | ||
} | ||
|
||
function showInputRepeatNewPassword() { | ||
setShowRepeatNewPass(true) | ||
} | ||
|
||
function handleSubmit(event) { | ||
event.preventDefault() | ||
|
||
const password = event.target.querySelector('#password').value | ||
const newPassword = event.target.querySelector('#new-password').value | ||
const repeatNewPassword = event.target.querySelector('#repeat-new-password').value | ||
|
||
try { | ||
logic.loginUser(password, newPassword, repeatNewPassword) | ||
.then(() => onSuccess()) | ||
.catch(error => { | ||
const clientError = document.querySelector('#client-error') | ||
|
||
clientError.innerText = error.message | ||
clientError.style.color = 'red' | ||
|
||
return | ||
}) | ||
} catch (error) { | ||
alert(error.message) | ||
} | ||
|
||
document.body.addEventListener('keydown', function () { | ||
const clientError = document.querySelector('#client-error') | ||
|
||
clientError.innerText = 'Change Password - Entry your data account: ' | ||
clientError.style.color = '#EBDBB2' | ||
}) | ||
} | ||
|
||
return <> | ||
<div> | ||
<p>~$</p> | ||
|
||
<span> | ||
<form onSubmit={handleSubmit}> | ||
<p id="client-error">Change Password - Entry your data account: </p> | ||
|
||
{showPassword && ( | ||
<div className="fields"> | ||
<label htmlFor="password"><p style={{ color: '#18E3C8' }}>Password: </p></label> | ||
<input type="password" id="password" contentEditable="true" autoComplete="off" onChange={showInputNewPassword} /> | ||
</div> | ||
)} | ||
|
||
{showNewPassword && ( | ||
<div className="fields"> | ||
<label htmlFor="new-password"><p style={{ color: '#18E3C8' }}>New password: </p></label> | ||
<input type="password" id="new-password" contentEditable="true" autoComplete="off" onChange={showInputRepeatNewPassword} /> | ||
</div> | ||
)} | ||
|
||
{showRepeatNewPass && ( | ||
<div className="fields"> | ||
<label htmlFor="repeat-new-password"><p style={{ color: '#18E3C8' }}>Repeat password: </p></label> | ||
<input type="password" id="repeat-new-password" contentEditable="true" autoComplete="off" /> | ||
</div> | ||
)} | ||
|
||
<button className="button-form">Send</button> | ||
</form> | ||
</span> | ||
</div > | ||
</> | ||
} | ||
|
||
export default Password |
Empty file.
Empty file.
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