Skip to content
Snippets Groups Projects
Commit 14922d0d authored by meskio's avatar meskio :tent:
Browse files

Toggle password visivility

parent ac9204d9
No related branches found
No related tags found
No related merge requests found
import React, { useState } from "react"; import React, { useState } from "react";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { Form, Button, Row } from "react-bootstrap"; import { Form, Button, Row, InputGroup } from "react-bootstrap";
import { FaEye, FaEyeSlash } from "react-icons/fa";
import Sender from "./Sender"; import Sender from "./Sender";
function SignIn(props) { function SignIn(props) {
...@@ -9,6 +10,7 @@ function SignIn(props) { ...@@ -9,6 +10,7 @@ function SignIn(props) {
const [password, setPassword] = useState(""); const [password, setPassword] = useState("");
const [noExpire, setNoExpire] = useState(Boolean(native)); const [noExpire, setNoExpire] = useState(Boolean(native));
const [badAuth, setBadAuth] = useState(false); const [badAuth, setBadAuth] = useState(false);
const [passVisible, setPassVisible] = useState(false);
const onError = (status) => { const onError = (status) => {
if (status === 400) { if (status === 400) {
...@@ -18,6 +20,10 @@ function SignIn(props) { ...@@ -18,6 +20,10 @@ function SignIn(props) {
return false; return false;
}; };
const togglePassVisible = () => {
setPassVisible(!passVisible);
};
return ( return (
<div> <div>
<Row className="justify-content-center"> <Row className="justify-content-center">
...@@ -39,13 +45,20 @@ function SignIn(props) { ...@@ -39,13 +45,20 @@ function SignIn(props) {
<Form.Group> <Form.Group>
<Form.Label>Contraseña</Form.Label> <Form.Label>Contraseña</Form.Label>
<Form.Control <InputGroup>
type="password" <Form.Control
placeholder="Contraseña" type={passVisible ? "input" : "password"}
value={password} placeholder="Contraseña"
onChange={(e) => setPassword(e.target.value)} value={password}
isInvalid={badAuth} onChange={(e) => setPassword(e.target.value)}
/> isInvalid={badAuth}
/>
<InputGroup.Append>
<InputGroup.Text onClick={togglePassVisible}>
{passVisible ? <FaEyeSlash /> : <FaEye />}
</InputGroup.Text>
</InputGroup.Append>
</InputGroup>
<Form.Control.Feedback type="invalid"> <Form.Control.Feedback type="invalid">
Nombre o contraseña invalidos. Nombre o contraseña invalidos.
</Form.Control.Feedback> </Form.Control.Feedback>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment