Skip to content

Commit

Permalink
Login google funcionando
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdlm committed Oct 22, 2021
1 parent ce289e7 commit 37fca60
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 77 deletions.
17 changes: 0 additions & 17 deletions pages/api/db.js

This file was deleted.

5 changes: 3 additions & 2 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import React, { useContext, useEffect, useState } from "react";
import GoogleLogIn from "../src/components/GoogleLogIn";
import Facebook from "../src/components/Facebook";
import ModalComplete from "../src/components/Modal";
import { ContainerLogin } from "../src/components/ContainerLogin";

export default function Home(props) {
const [screenState, setScreenState] = React.useState(props.isLogged);
Expand Down Expand Up @@ -57,10 +58,10 @@ export default function Home(props) {
<LogOnScreen />
)} */}
{screenState !== 1 && (
<>
<ContainerLogin>
<GoogleLogIn handleStatusLogged={handleStatusLogged} />
<Facebook handleStatusLogged={handleStatusLogged} />
</>
</ContainerLogin>
)}
{screenState === 1 && (
<>
Expand Down
6 changes: 0 additions & 6 deletions pages/quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import {
function ResultWidget({ results }) {
const router = useRouter();

// setCurrentExperience(amountExp);
// console.log(`AmountExp: ${amountExp}`);
return (
<Widget style={{ margin: "0 auto" }}>
<Widget.Header>RESULTADO</Widget.Header>
Expand Down Expand Up @@ -112,7 +110,6 @@ function QuestionWidget({
const { completeQuestion } = useContext(ExperienceContext);
const { handlePointsStats } = useContext(ExperienceContext);
const { handleRounds } = useContext(ExperienceContext);
// console.log(question.type);
React.useEffect(() => {
handleRounds();
}, []);
Expand Down Expand Up @@ -144,9 +141,6 @@ function QuestionWidget({
onSubmit={(event) => {
event.preventDefault();
setIsClicked(false);
{
console.log(event.type);
}
setIsQuestionSubmited(true);
addResult(isCorrect);
setTimeout(() => {
Expand Down
Binary file removed public/icons/lock.png
Binary file not shown.
Binary file removed public/icons/scroll.png
Binary file not shown.
3 changes: 0 additions & 3 deletions public/icons/scroll.svg

This file was deleted.

Binary file removed public/icons/swords (1).png
Binary file not shown.
3 changes: 0 additions & 3 deletions public/icons/swords.svg

This file was deleted.

26 changes: 26 additions & 0 deletions src/components/ContainerLogin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import styled from "styled-components";

export const ContainerLogin = styled.div`
display: flex;
width: 100%;
height: 100%;
justify-content: center;
margin-top: 50vh;
flex-direction: column;
.googleBtn {
margin-bottom: 0.5rem;
}
.googleBtn span {
display: block;
margin-left: 10%;
text-transform: uppercase;
}
button {
margin-bottom: 3rem;
display: block;
margin: 0 auto;
width: 20rem;
}
`;
39 changes: 6 additions & 33 deletions src/components/Facebook/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,12 @@ export default function Facebook({ handleStatusLogged }) {
changePlayerName(response.name);
};

const FbContent = (
<div
style={{
width: "400px",
margin: "auto",
background: "#f4f4f4",
padding: "20px",
}}
>
<img src={state.picture} alt={state.name} />
<h2>Welcome {state.name}</h2>
Email: {state.email}
</div>
);

return (
<>
<div
style={{
width: "100%",
height: "100%",
display: "flex",
justifyContent: "center",
marginTop: "50vh",
}}
>
<FacebookLogin
appId="632902014369254"
// autoLoad={true}
fields="name,email,picture"
callback={responseFacebook}
/>
</div>
</>
<FacebookLogin
appId="632902014369254"
// autoLoad={true}
fields="name,email,picture"
callback={responseFacebook}
/>
);
}
19 changes: 6 additions & 13 deletions src/components/GoogleLogIn/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import GoogleLogin from "react-google-login";
import React, { useContext } from "react";
import { ExperienceContext } from "../../contexts/ExperienceContext";
import styled from "styled-components";

export default function GoogleLogIn({ handleStatusLogged }) {
const { handleIsLogged } = useContext(ExperienceContext);
const { handleIsLogged, changePlayerName, changePlayerImage } =
useContext(ExperienceContext);
const changeStatus = () => {
handleStatusLogged(1);
};
Expand All @@ -14,29 +14,22 @@ export default function GoogleLogIn({ handleStatusLogged }) {
} = response;
handleIsLogged();
changeStatus();
changePlayerImage(imageUrl);
changePlayerName(name);
};

const responseGoogleFailed = (response) => {
console.log("falha resposta google");
console.log(response);
};
return (
// <div
// style={{
// width: "100%",
// height: "100%",
// display: "flex",
// justifyContent: "center",
// marginTop: "50vh",
// }}
// >
<GoogleLogin
className="googleBtn"
clientId="279991950987-fa92c6k1lffqtegplfqd9r1p8dos5kn6.apps.googleusercontent.com"
buttonText="Login"
// buttonText="LOGIN WITH GOOGLE"
onSuccess={responseGoogleSucess}
onFailed={responseGoogleFailed}
cookiePolicy={"single_host_origin"}
/>
// </div>
);
}

0 comments on commit 37fca60

Please sign in to comment.