-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
Showing
8 changed files
with
123 additions
and
15 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import React from "react"; | ||
|
||
function Loading() { | ||
return <div>Loading</div>; | ||
return ( | ||
<div> | ||
<p className="text-white">Loading...</p> | ||
</div> | ||
); | ||
} | ||
|
||
export default Loading; |
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,16 +1,69 @@ | ||
import React from "react"; | ||
import { checkTokenValidity } from "../utils/fetchOpenSaucedApiData"; | ||
import { BiArrowBack, BiInfoCircle } from "react-icons/bi"; | ||
|
||
interface SignInProps { | ||
setRenderedPage: (page: string) => void; | ||
} | ||
|
||
function SignIn({ setRenderedPage }: SignInProps) { | ||
return <div> | ||
<h1>Sign In</h1> | ||
<p>Sign in with your PAT</p> | ||
<input type="text" /> | ||
<button onClick={() => setRenderedPage("home")}>Sign In</button> | ||
</div>; | ||
const [token, setToken] = React.useState(""); | ||
|
||
const authenticateUser = (token: string) => { | ||
if (token === "") { | ||
alert("Please enter a valid token"); | ||
return; | ||
} | ||
checkTokenValidity(token) | ||
.then((valid) => { | ||
if (valid) { | ||
chrome.storage.sync.set({ "os-access-token": token }, () => { | ||
setRenderedPage("home"); | ||
}); | ||
} else { | ||
alert("Token is invalid"); | ||
} | ||
}) | ||
.catch((err) => { | ||
console.log(err); | ||
alert("An error occurred while authenticating"); | ||
}); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<BiArrowBack | ||
className="text-orange cursor-pointer text-2xl" | ||
onClick={() => setRenderedPage("start")} | ||
/> | ||
<h1 className="text-white text-2xl font-bold my-2">Sign In</h1> | ||
<p className="mb-2 text-gray-300 text-sm"> | ||
Enter your Personal Access Token to sign in. | ||
<BiInfoCircle | ||
title="Learn how to obtain a Personal Access Token" | ||
className="inline-block ml-1 text-gray-400 align-middle cursor-pointer" | ||
onClick={() => | ||
window.open( | ||
"https://docs.opensauced.pizza/contributing/set-up-authentication/", | ||
"_blank" | ||
) | ||
} | ||
/> | ||
</p> | ||
<input | ||
type="text" | ||
className="p-1.5 rounded-md mb-2 outline-none" | ||
onChange={(e) => setToken(e.target.value)} | ||
/> | ||
<button | ||
className="bg-orange border-none rounded-md text-white font-bold py-2 px-4 cursor-pointer | ||
bg-gradient-to-r from-[#e67e22] to-[#d35400] mt-2" | ||
onClick={() => authenticateUser(token)} | ||
> | ||
Sign In | ||
</button> | ||
</div> | ||
); | ||
} | ||
|
||
export default SignIn; |
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