-
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.
- Loading branch information
1 parent
cf4ba01
commit 993902a
Showing
9 changed files
with
68 additions
and
10 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
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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { useState } from "react"; | ||
import TextField from "@mui/material/TextField"; | ||
import IconButton from "@mui/material/IconButton"; | ||
import DoneIcon from "@mui/icons-material/Done"; | ||
|
||
const Login = ({ setIsLoggedIn }: { setIsLoggedIn: (isLoggedIn: boolean) => void }) => { | ||
const [password, setPassword] = useState(""); | ||
const [hasError, setHasError] = useState(false); | ||
|
||
const submitPassword = async () => { | ||
if (await window.api.checkPassword(password)) { | ||
window.sessionStorage.setItem("loggedIn", "y"); | ||
setIsLoggedIn(true); | ||
} else { | ||
setHasError(true); | ||
} | ||
setPassword(""); | ||
}; | ||
|
||
return ( | ||
<div className="flex flex-row my-4"> | ||
<TextField | ||
label={hasError ? "Try again" : "Enter password"} | ||
spellCheck={true} | ||
onChange={(event) => setPassword(event.target.value)} | ||
className="w-1/2" | ||
error={hasError} | ||
onKeyDown={(event) => { | ||
if (event.key === "Enter") { | ||
submitPassword(); | ||
} | ||
}} | ||
/> | ||
<IconButton onClick={submitPassword}> | ||
<DoneIcon /> | ||
</IconButton> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Login; |