Skip to content

Commit

Permalink
GetNomePlayer funcional e iniciando implementacao do getImagem
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdlm committed Oct 18, 2021
1 parent 95276bd commit 83ae422
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
3 changes: 3 additions & 0 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default function Home(props) {
pointsBarTypeTwo={props.pointsBarTypeTwo}
pointsBarTypeTree={props.pointsBarTypeTree}
isLogged={props.isLogged}
playerName={props.playerName}
>
<Background>
<Head>
Expand Down Expand Up @@ -78,6 +79,7 @@ export const getServerSideProps = async (ctx) => {
pointsBarTypeTwo,
pointsBarTypeTree,
isLogged,
playerName,
} = ctx.req.cookies;
return {
props: {
Expand All @@ -89,6 +91,7 @@ export const getServerSideProps = async (ctx) => {
pointsBarTypeTwo: Number(pointsBarTypeTwo),
pointsBarTypeTree: Number(pointsBarTypeTree),
isLogged: Number(isLogged),
playerName: String(playerName),
},
};
};
3 changes: 3 additions & 0 deletions pages/quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export default function QuizPage(props) {
pointsBarTypeTwo={props.pointsBarTypeTwo}
pointsBarTypeTree={props.pointsBarTypeTree}
isLogged={props.isLogged}
playerName={props.playerName}
>
<Background>
<QuizContainer>
Expand Down Expand Up @@ -240,6 +241,7 @@ export const getServerSideProps = async (ctx) => {
pointsBarTypeTwo,
pointsBarTypeTree,
isLogged,
playerName,
} = ctx.req.cookies;
return {
props: {
Expand All @@ -251,6 +253,7 @@ export const getServerSideProps = async (ctx) => {
pointsBarTypeTwo: Number(pointsBarTypeTwo),
pointsBarTypeTree: Number(pointsBarTypeTree),
isLogged: Number(isLogged),
playerName: String(playerName),
},
};
};
3 changes: 2 additions & 1 deletion src/components/Facebook/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import FacebookLogin from "react-facebook-login";
import { ExperienceContext } from "../../contexts/ExperienceContext";

export default function Facebook({ handleStatusLogged }) {
const { handleIsLogged } = useContext(ExperienceContext);
const { handleIsLogged, changePlayerName } = useContext(ExperienceContext);
const changeStatus = () => {
handleStatusLogged(1);
};
Expand All @@ -29,6 +29,7 @@ export default function Facebook({ handleStatusLogged }) {
});
handleIsLogged();
changeStatus();
changePlayerName(response.name);
};

const componentClicked = () => console.log("clicked");
Expand Down
14 changes: 9 additions & 5 deletions src/components/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Header.Stats = styled.div`
`;

Header.StatsPicture = styled.div`
overflow: hidden;
width: 5rem;
height: 5rem;
background-color: white;
Expand Down Expand Up @@ -111,9 +112,10 @@ function HeaderComplete() {
experienceToNextLevel,
titleUser,
handleTitles,
name,
playerName,
playerImage,
} = useContext(ExperienceContext);
const namePart = name.split(" ");
const namePart = playerName.split(" ");
useEffect(() => {
handleTitles();
}, []);
Expand All @@ -129,10 +131,12 @@ function HeaderComplete() {
initial="hidden"
animate="show"
>
<Header.StatsPicture />
<Header.StatsPicture>
<img src={playerImage} style={{ maxWidth: "100%" }} />
</Header.StatsPicture>
<Header.StatsInfo>
<p className="fullNamePlayer">William Mota</p>
<p className="firstNamePlayer">William</p>
<p className="fullNamePlayer">{playerName}</p>
<p className="firstNamePlayer">{namePart[0]}</p>
<p className="levelPlayer">{`Level ${level}`}</p>
<p className="experiencePlayer">{`xp ${currentExperience}`}</p>
</Header.StatsInfo>
Expand Down
15 changes: 12 additions & 3 deletions src/contexts/ExperienceContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ export function ExperienceProvider({ children, ...rest }) {
rest.pointsBarTypeTree ?? 0
);
const [isLogged, setIsLogged] = useState(rest.isLogged ?? 0);
const name = "William Mota";
const [playerName, setPlayerName] = useState(rest.playerName ?? "No Name");
const [playerImage, setPlayerImage] = useState(
"https://st2.depositphotos.com/1009634/7235/v/950/depositphotos_72350117-stock-illustration-no-user-profile-picture-hand.jpg"
);

console.log(rest.isLogged);

function handleIsLogged() {}
function changePlayerName(name) {
setPlayerName(name);
}

function handlePointsStats(type) {
switch (type) {
Expand Down Expand Up @@ -65,6 +70,7 @@ export function ExperienceProvider({ children, ...rest }) {
Cookies.set("pointsBarTypeTwo", pointsBarTypeTwo);
Cookies.set("pointsBarTypeTree", pointsBarTypeTree);
Cookies.set("isLogged", isLogged);
Cookies.set("playerName", playerName);
}, [
level,
currentExperience,
Expand All @@ -74,6 +80,7 @@ export function ExperienceProvider({ children, ...rest }) {
pointsBarTypeTwo,
pointsBarTypeTree,
isLogged,
playerName,
]);

// console.log(typeof Cookies.get("pointsBarType"));
Expand Down Expand Up @@ -122,7 +129,7 @@ export function ExperienceProvider({ children, ...rest }) {
completeQuestion,
levelUp,
experienceToNextLevel,
name,
playerName,
titleUser,
handleTitles,
handlePointsStats,
Expand All @@ -134,6 +141,8 @@ export function ExperienceProvider({ children, ...rest }) {
pointsBarTypeTree,
isLogged,
handleIsLogged,
changePlayerName,
playerImage,
}}
>
{children}
Expand Down

0 comments on commit 83ae422

Please sign in to comment.