react-icons/fa#FaUserCircle JavaScript Examples

The following examples show how to use react-icons/fa#FaUserCircle. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Signup.jsx    From Next.js-Mongodb-Authentication-App with MIT License 5 votes vote down vote up
export default function Login() {
    const [user, { mutate }] = useUser();
    const [errorMsg, setErrorMsg] = useState("");
    const [loading, isLoading] = useState(false);

    useEffect(() => {
        // redirect to home if user is authenticated
        if (user) Router.replace("/");
    }, [user]);

    const handleSubmit = async (e) => {
        e.preventDefault();
        if (e.currentTarget.password.value !== e.currentTarget.cpassword.value) {
            setErrorMsg("Passwords does not match")
        } else {
            isLoading(true);
            const body = {
                email: e.currentTarget.email.value,
                name: e.currentTarget.name.value,
                password: e.currentTarget.password.value
            };
            const res = await fetch("/api/users", {
                method: "POST",
                headers: { "Content-Type": "application/json" },
                body: JSON.stringify(body)
            });
            if (res.status === 201) {
                const userObj = await res.json();
                // writing our user object to the state
                mutate(userObj);
            } else {
                isLoading(false);
                setErrorMsg(await res.text());
            }
        }
    };
    return (
        <>
            <div className="card-form d-flex justify-content-center">
                <form onSubmit={handleSubmit}>
                    <div className="mb-3">
                        {errorMsg ? <p style={{ color: "red" }}>{errorMsg}</p> : null}
                    </div>
                    <div class="mb-3">
                        <label for="Name" class="form-label"><FaUserCircle /> Name</label>
                        <input type="text" class="form-control" id="name" required />
                    </div>
                    <div class="mb-3">
                        <label for="email" class="form-label"><MdEmail /> Email address</label>
                        <input type="email" class="form-control" id="email" required />
                        <div id="emailHelp" class="form-text">We'll never share your email with anyone else.</div>
                    </div>
                    <div class="mb-3">
                        <label for="password" class="form-label"><RiLockPasswordFill /> Password</label>
                        <input type="password" class="form-control" id="password" required />
                    </div>
                    <div class="mb-3">
                        <label for="cpassword" class="form-label"><RiLockPasswordFill /> Confirm Password</label>
                        <input type="password" class="form-control" id="cpassword" required />
                    </div>
                    <div className="mb-3">
                        <p>Already registered ? <Link href="/login">Login</Link></p>
                    </div>
                    <button type="submit" class="btn btn-primary w-100 mb-3">{loading ? <div class="spinner-border" role="status" style={{ width: '1.5rem', height: '1.5rem' }}>
                        <span class="visually-hidden">Loading...</span>
                    </div> : <>Sign up</>}</button>
                </form>
            </div>
        </>
    );
}
Example #2
Source File: index.js    From atendimento-e-agilidade-medica-AAMed with MIT License 4 votes vote down vote up
export default function Logged({ match }) {
  document.title = "AAMed - Gerenciamento";

  let click = React.createRef();
  let changeColor = React.createRef();
  const id = match.params.id;
  //requisição do socket
  const [user, setUser] = useState([]);
  const [acceptUser, setAcceptUser] = useState([]);
  const [ok, setOk] = useState(null);

  const [socketAll, setSocketAll] = useState(null);
  const [solicitationUser, setSolicitationUser] = useState("");

  const [userAccept, setUserAccept] = useState(false);
  const [arrived, setArrived] = useState(false);
  const [userTreatment, setUserTreatment] = useState([]);

  const { push } = useHistory();

  useEffect(() => {
    const socket = socketio("http://localhost:3333", {
      query: { hospital_id: id },
    });
    setSocketAll(socket);
    socket.on("aviso", (data) => {
      setUser([...user, data]);
      setOk(true);
    });
    socket.on("filter", (data) => {
      if (
        match.params.id !== data.hospital_id &&
        solicitationUser !== data.user_accept
      ) {
        setUser(user.filter((users) => users.user._id !== data.user_accept)); //tirar  da tela so hospital q n aceitou
      } else {
        setUserAccept(true);
      }
    });
    socket.on("arrived_web", (data) => {
      data.arrived ? setArrived(true) : setArrived(false);
      setTest(acceptUser.filter((users) => users.user._id !== data.user._id));
      setUserTreatment([...userTreatment, data.user]);
    });
  }, [id, match.params.id, solicitationUser, user]);

  function handleClick() {
    const cc = changeColor.current;
    cc.classList.toggle("bgcolorClick");
  }

  async function handleLogout() {
    await api.get("/hospital/logout", { withCredentials: true });
    localStorage.removeItem("hptid");
    push("/");
  }

  async function accept(id, desc) {
    try {
      await api.post(
        `/solicitations/${id}/approvals`,
        { description: desc },
        {
          headers: { hospital_id: match.params.id },
          withCredentials: true,
        }
      );
      setSolicitationUser(id);
      socketAll.emit("accept", {
        hospital_id: match.params.id,
        user_accept: id,
      });
      setAcceptUser(user.filter((users) => users.user._id === id));

      setUser(user.filter((users) => users.user._id !== id));
    } catch (error) {
      console.log(error);
    }
  }

  function hasAttended(id) {
    setUserTreatment(userTreatment.filter((users) => users._id !== id));
  }

  function reject(id) {
    setUser(user.filter((users) => users.user._id !== id));
  }

  const [testUser, setTest] = useState([]);

  useEffect(() => {
    acceptUser.filter((users) => setTest([...testUser, users]));
  }, [acceptUser]);

  return (
    <div className="container-logged">
      <div className="flex">
        <img src={require("../../assets/hospital.jpg")} alt="" />
        <Link to="/profile" className="items">
          <FaUserCircle size={25} />
          <span>Perfil</span>
        </Link>
        <span className="config">
          <div ref={changeColor}>
            <IoMdSettings size={25} />
            <input type="checkbox" className="hidden" id="toggle" />
            <label
              htmlFor="toggle"
              className="click"
              onClick={handleClick}
              ref={click}
            >
              Configurações
            </label>
            <ul className="info-config">
              <Link to="/update">Atualizar</Link>
              <Link to={`/changepassword/${match.params.id}`}>
                Trocar senha
              </Link>
              <Link to="/deleteaccount">Excluir conta</Link>
            </ul>
          </div>
        </span>
        <Link to="/hospitals" className="items">
          <FaList size={25} />
          <span>Hospitais</span>
        </Link>
        <Link to={`/treatment/${id}`} className="items">
          <AiFillMedicineBox size={25} />
          <span>Atendimentos</span>
        </Link>
        <div onClick={handleLogout} className="items logout">
          <span className="click">Sair</span>
        </div>
      </div>
      <div className="treatments">
        <div className="espera">
          <h2>SOLICITAÇÕES</h2>
          {ok &&
            user.map((users, i) => (
              <div className="user-help" key={i}>
                <span>
                  <span style={{ fontWeight: "bold" }}>NOME:</span>{" "}
                  {users.user.name}
                </span>
                <span>
                  <span style={{ fontWeight: "bold" }}>CPF:</span>{" "}
                  {users.user.cpf}
                </span>
                <span>
                  <span style={{ fontWeight: "bold" }}>DESCRIÇÃO:</span>{" "}
                  {users.description}
                </span>
                <span>
                  <span style={{ fontWeight: "bold" }}>BIO:</span>{" "}
                  {users.user.bio}
                </span>
                <span>
                  <span style={{ fontWeight: "bold" }}>LOCALIZAÇÃO:</span>{" "}
                  {users.currentLocation}
                </span>
                <div>
                  <button
                    className="buttonAceitar"
                    onClick={() => accept(users.user._id, users.description)}
                  >
                    Aceitar
                  </button>
                  <button
                    className="buttonRecusar"
                    onClick={() => reject(users.user._id)}
                  >
                    Recusar
                  </button>
                </div>
              </div>
            ))}
        </div>
        <div className="caminho">
          <h2>A CAMINHO</h2>
          {userAccept &&
            testUser.map((users, i) => (
              <div className="user-help" key={i}>
                <span>
                  <span style={{ fontWeight: "bold" }}>NOME:</span>{" "}
                  {users.user.name}
                </span>
                <span>
                  <span style={{ fontWeight: "bold" }}>CPF:</span>{" "}
                  {users.user.cpf}
                </span>
                <span>
                  <span style={{ fontWeight: "bold" }}>DESCRIÇÃO:</span>{" "}
                  {users.description}
                </span>
                <span>
                  <span style={{ fontWeight: "bold" }}>BIO:</span>{" "}
                  {users.user.bio}
                </span>
                <span>
                  <span style={{ fontWeight: "bold" }}>LOCALIZAÇÃO:</span>{" "}
                  {users.currentLocation}
                </span>
                <div>
                  <button
                    onClick={() => {
                      setTest(
                        testUser.filter(
                          (usr) => usr.user._id !== users.user._id
                        )
                      );
                      setArrived(true);
                      setUserTreatment([...userTreatment, users.user]);
                      socketAll.emit("arrived_manually", {
                        user_id: users.user._id,
                        arrived: true,
                      });
                    }}
                  >
                    Compareceu
                  </button>
                  <button
                    onClick={() => {
                      socketAll.emit("not_here", {
                        user_id: users.user._id,
                        not_here: true,
                      });
                      setTest(
                        testUser.filter(
                          (usr) => usr.user._id !== users.user._id
                        )
                      );
                    }}
                  >
                    Faltou
                  </button>
                </div>
              </div>
            ))}
        </div>
        <div className="atendimento">
          <h2>EM ATENDIMENTO</h2>
          {arrived &&
            userTreatment.map((user, i) => (
              <div className="user-help" key={i}>
                <span>
                  <span style={{ fontWeight: "bold" }}>NOME:</span> {user.name}
                </span>
                <span>
                  <span style={{ fontWeight: "bold" }}>CPF:</span> {user.cpf}
                </span>
                <div>
                  <button onClick={() => hasAttended(user._id)}>
                    Atendido
                  </button>
                </div>
              </div>
            ))}
        </div>
      </div>
    </div>
  );
}