From d384cf3636aed4540bb0c9433c7f4f487709d975 Mon Sep 17 00:00:00 2001 From: Dennis Chen <41879777+chennisden@users.noreply.github.com> Date: Thu, 25 Jul 2024 15:31:25 -0700 Subject: [PATCH] Remove unused EmailAuthComponent.tsx file (#188) --- .../components/auth/EmailAuthComponent.tsx | 95 ------------------- 1 file changed, 95 deletions(-) delete mode 100644 frontend/src/components/auth/EmailAuthComponent.tsx diff --git a/frontend/src/components/auth/EmailAuthComponent.tsx b/frontend/src/components/auth/EmailAuthComponent.tsx deleted file mode 100644 index 58a5a6ed..00000000 --- a/frontend/src/components/auth/EmailAuthComponent.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import { faEnvelope } from "@fortawesome/free-solid-svg-icons"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import TCButton from "components/files/TCButton"; -import { humanReadableError } from "constants/backend"; -import { useAlertQueue } from "hooks/alerts"; -import { useAuthentication } from "hooks/auth"; -import { useRef, useState } from "react"; -import { Col, Form, InputGroup, Overlay, Row, Tooltip } from "react-bootstrap"; -import { CheckCircle } from "react-bootstrap-icons"; -const isValidEmail = (email: string) => { - return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); -}; - -const EmailAuthComponent = () => { - const [email, setEmail] = useState(""); - const [isDisabled, setIsDisabled] = useState(false); - const [isSuccess, setIsSuccess] = useState(false); - const { api } = useAuthentication(); - const { addAlert } = useAlertQueue(); - - const target = useRef(null); - - const handleSubmit = async (e: React.FormEvent) => { - e.preventDefault(); - - setIsDisabled(true); - const login_url = window.location.href; - - try { - await api.post("/users/login", { - email, - login_url, - // 7 days - lifetime: 60 * 60 * 24 * 7, - }); - setIsSuccess(true); - } catch (error) { - addAlert(humanReadableError(error), "error"); - } finally { - setIsDisabled(false); - } - }; - - return isSuccess ? ( - - - - - -

- Verification Email Sent! -

- -
- - - Check your email for a login link. - - - -
- ) : ( -
- - { - setEmail(e.target.value); - }} - value={email} - disabled={isDisabled} - /> - - Sign In - - - 3 && !isValidEmail(email)} - target={target.current} - > - {(props) => Invalid email} - - -
- ); -}; - -export default EmailAuthComponent;