-
Notifications
You must be signed in to change notification settings - Fork 181
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
17 changed files
with
349 additions
and
111 deletions.
There are no files selected for viewing
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
18 changes: 17 additions & 1 deletion
18
src/routes/login/GithubLoginButton.js → src/common/component/GithubLoginButton.js
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,58 @@ | ||
import { useEffect } from "react"; | ||
import { useGoogleLogin } from "react-google-login"; | ||
|
||
import googleSvg from "../../assets/icons/google.svg?url"; | ||
import styled from "styled-components"; | ||
import Button from "./styled/Button"; | ||
import { useLoginMutation } from "../../app/services/auth"; | ||
import toast from "react-hot-toast"; | ||
const StyledSocialButton = styled(Button)` | ||
width: 100%; | ||
margin-bottom: 16px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 12px; | ||
color: #344054; | ||
border: 1px solid #d0d5dd; | ||
background: none !important; | ||
.icon { | ||
width: 24px; | ||
height: 24px; | ||
} | ||
`; | ||
export default function GoogleLoginButton({ clientId }) { | ||
const [login, { isSuccess, isLoading }] = useLoginMutation(); | ||
const { signIn, loaded } = useGoogleLogin({ | ||
onScriptLoadFailure: (wtf) => { | ||
console.error("google login script load failure", wtf); | ||
}, | ||
clientId, | ||
onSuccess: ({ tokenId, ...rest }) => { | ||
console.info("google oauth success", tokenId, rest); | ||
login({ | ||
id_token: tokenId, | ||
type: "google" | ||
}); | ||
}, | ||
onFailure: (wtf) => { | ||
console.error("google login failure", wtf); | ||
} | ||
}); | ||
useEffect(() => { | ||
if (isSuccess) { | ||
toast.success("Login Successfully"); | ||
// navigateTo("/"); | ||
} | ||
}, [isSuccess]); | ||
const handleGoogleLogin = () => { | ||
signIn(); | ||
}; | ||
// console.log("google login ", loaded); | ||
return ( | ||
<StyledSocialButton disabled={!loaded || isLoading} onClick={handleGoogleLogin}> | ||
<img className="icon" src={googleSvg} alt="google icon" /> | ||
{loaded ? `Sign in with Google` : `Initailizing`} | ||
</StyledSocialButton> | ||
); | ||
} |
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// import React from "react"; | ||
import styled from "styled-components"; | ||
const Styled = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
.title { | ||
font-weight: 600; | ||
font-size: 30px; | ||
line-height: 38px; | ||
color: #101828; | ||
margin-bottom: 12px; | ||
} | ||
.desc { | ||
text-align: center; | ||
font-weight: 400; | ||
font-size: 16px; | ||
line-height: 24px; | ||
color: #667085; | ||
&:not(:last-child) { | ||
margin-bottom: 24px; | ||
} | ||
} | ||
`; | ||
export default function EmailNextTip() { | ||
return ( | ||
<Styled> | ||
<div className="title">Magic link Sent</div> | ||
<p className="desc">Login to your email client, and continue next step</p> | ||
<p className="desc">You can close this window now.</p> | ||
</Styled> | ||
); | ||
} |
Oops, something went wrong.