diff options
author | 2021-01-03 05:47:07 +0300 | |
---|---|---|
committer | 2021-01-03 05:47:07 +0300 | |
commit | d664ddc9b84b25922239e3bbc253b35ea54f2533 (patch) | |
tree | f1892f7e9b0880826b28a503aea312a97b0ea3a2 /src/components/OAuth2Button.tsx | |
parent | Adds EsLint (diff) |
Fixes Preexisting Linting Issues
Fixes all errors, and most warnings generated by eslint. Most were fixed
by eslint automatically such as indentation and quotes.
Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'src/components/OAuth2Button.tsx')
-rw-r--r-- | src/components/OAuth2Button.tsx | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/src/components/OAuth2Button.tsx b/src/components/OAuth2Button.tsx index c364369..4fa3f61 100644 --- a/src/components/OAuth2Button.tsx +++ b/src/components/OAuth2Button.tsx @@ -1,7 +1,7 @@ /** @jsx jsx */ import { css, jsx } from "@emotion/react"; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faDiscord } from "@fortawesome/free-brands-svg-icons"; import colors from "../colors"; @@ -40,49 +40,49 @@ span { `; function doLogin(disableFunction: (newState: boolean) => void) { - disableFunction(true); + disableFunction(true); - const redirectURI = encodeURIComponent(document.location.protocol + "//" + document.location.host + "/callback"); + const redirectURI = encodeURIComponent(document.location.protocol + "//" + document.location.host + "/callback"); - const windowRef = window.open( - `https://discord.com/api/oauth2/authorize?client_id=${OAUTH2_CLIENT_ID}&response_type=code&scope=identify&redirect_uri=${redirectURI}&prompt=none`, - "Discord_OAuth2", - "height=700,width=500,location=no,menubar=no,resizable=no,status=no,titlebar=no,left=300,top=300" - ) + const windowRef = window.open( + `https://discord.com/api/oauth2/authorize?client_id=${OAUTH2_CLIENT_ID}&response_type=code&scope=identify&redirect_uri=${redirectURI}&prompt=none`, + "Discord_OAuth2", + "height=700,width=500,location=no,menubar=no,resizable=no,status=no,titlebar=no,left=300,top=300" + ); - const interval = setInterval(() => { - if (windowRef?.closed) { - clearInterval(interval); - disableFunction(false); - } - }, 500) + const interval = setInterval(() => { + if (windowRef?.closed) { + clearInterval(interval); + disableFunction(false); + } + }, 500); - window.onmessage = (code: MessageEvent) => { - if (code.data.source) { - // React DevTools has a habit of sending messages, ignore them. - return; - } + window.onmessage = (code: MessageEvent) => { + if (code.data.source) { + // React DevTools has a habit of sending messages, ignore them. + return; + } - if (code.isTrusted) { - windowRef?.close(); + if (code.isTrusted) { + windowRef?.close(); - console.log("Code received:", code.data); + console.log("Code received:", code.data); - disableFunction(false); - clearInterval(interval); + disableFunction(false); + clearInterval(interval); - window.onmessage = null; - } - }; + window.onmessage = null; + } + }; } -function OAuth2Button() { - const [disabled, setDisabled] = useState<boolean>(false); +function OAuth2Button(): JSX.Element { + const [disabled, setDisabled] = useState<boolean>(false); - return <button disabled={disabled} onClick={() => doLogin(setDisabled)} css={buttonStyling}> - <span css={{marginRight: "10px"}}><FontAwesomeIcon icon={faDiscord} css={{fontSize: "2em", marginTop: "3px"}}/></span> - <span>Sign in with Discord</span> - </button>; + return <button disabled={disabled} onClick={() => doLogin(setDisabled)} css={buttonStyling}> + <span css={{marginRight: "10px"}}><FontAwesomeIcon icon={faDiscord} css={{fontSize: "2em", marginTop: "3px"}}/></span> + <span>Sign in with Discord</span> + </button>; } export default OAuth2Button; |