Skip to content

Commit

Permalink
Se usa modal de coins en userPanel
Browse files Browse the repository at this point in the history
  • Loading branch information
hendaniel committed Sep 7, 2020
1 parent 5e8172b commit 0f74a9d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/components/User/UserPanel.jsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
import React, { useEffect, useContext } from "react";
import { coin } from "../../assets/index";
import { UserContext } from "../../providers/UserProvider";
import { CoinsModal } from "../Modals/index";
import { useModal } from "../../hooks/index";

import "./user.scss";

const UserPanel = () => {
const { user } = useContext(UserContext);

const [coinsModal, toggleCoinsModal] = useModal();

useEffect(() => {
if (!user) return;
}, [user]);

const openCoinsModal = () => {
toggleCoinsModal();
};

const { name, points } = user;
return (
<div className="user-panel">
<div>{name}</div>
<div className="coins-user">
<img src={coin} alt="Coins" />
<span className="points">{points}</span>
<>
{coinsModal && (
<CoinsModal isShowing={coinsModal} hide={toggleCoinsModal} />
)}
<div className="user-panel">
<div>{name}</div>
<div className="coins-user">
<img src={coin} onClick={openCoinsModal} alt="Coins" />
<span className="points">{points}</span>
</div>
</div>
</div>
</>
);
};
export default UserPanel;
5 changes: 5 additions & 0 deletions src/components/User/user.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@
color: gray;
}
}
img {
&:hover {
cursor: pointer;
}
}
}

0 comments on commit 0f74a9d

Please sign in to comment.