Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env.example

This file was deleted.

110 changes: 110 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@reduxjs/toolkit": "^1.7.1",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"axios": "^0.24.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.6",
"react-scripts": "5.0.0",
"web-vitals": "^2.1.3"
},
Expand Down
51 changes: 29 additions & 22 deletions src/components/profile/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,44 @@ import axios from "axios";

import email from "../../assets/img/email.png";
import anonymous_avatar from "../../assets/img/anonymous.png";
import { useDispatch, useSelector } from "react-redux";
import { fetchProfileData } from "../../store/actions/profile.action"

function Profile() {
const [profile, setProfile] = useState({});
//const [profile, setProfile] = useState({});

useEffect(() => {
axios.get(`https://api.github.com/user`).then((response) => {
setProfile(response.data);
});
});
const dispatch = useDispatch()
const userData = useSelector((state) => state.profile.userData)

useEffect(() => {
dispatch(fetchProfileData())
// axios.get(`https://api.github.com/user`).then((response) => {
// setProfile(response.data);
// });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outdated code would rather be deleted :trash:

}, []);

const handleNavigateToProfile = () => {
window.location = profile.html_url;
window.location = Profile.html_url;
};


return (
<div className="profile-content-container">
<img
src={profile.avatar_url ? profile.avatar_url : anonymous_avatar}
src={userData.avatar_url ? userData.avatar_url : anonymous_avatar}
alt="avatar"
className="profile-avatar"
/>
<h3 onClick={handleNavigateToProfile} className="profile-name">
{profile.name} <br />
{profile.login && (
<span className="profile-login">@{profile.login}</span>
{userData.name} <br />
{userData.login && (
<span className="profile-login">@{userData.login}</span>
)}
</h3>
<div className="profile-info">
<span>{profile.bio}</span>
<span>{userData.bio}</span>
<div className="profile-social-items">
{profile.followers && (
{userData.followers && (
<span className="profile-social-item">
<svg
text="muted"
Expand All @@ -51,27 +58,27 @@ function Profile() {
></path>
</svg>
<span>
<b>{profile.followers}</b> followers
<b>{userData.followers}</b> followers
</span>
</span>
)}
{profile.following && (
{userData.following && (
<span className="profile-social-item">
<span>.</span>
<span>
<b>{profile.following}</b> following
<b>{userData.following}</b> following
</span>
</span>
)}
</div>
<div className="profile-info-items">
{profile.email && (
{userData.email && (
<span className="profile-info-item">
<img src={email} className="profile-info-icon" alt="email" />
<span>{profile.email}</span>
<span>{userData.email}</span>
</span>
)}
{profile.location && (
{userData.location && (
<span className="profile-info-item">
<svg
className="octicon octicon-location"
Expand All @@ -86,10 +93,10 @@ function Profile() {
d="M11.536 3.464a5 5 0 010 7.072L8 14.07l-3.536-3.535a5 5 0 117.072-7.072v.001zm1.06 8.132a6.5 6.5 0 10-9.192 0l3.535 3.536a1.5 1.5 0 002.122 0l3.535-3.536zM8 9a2 2 0 100-4 2 2 0 000 4z"
></path>
</svg>
<span>{profile.location}</span>
<span>{userData.location}</span>
</span>
)}
{profile.company && (
{userData.company && (
<span className="profile-info-item">
<svg
className="octicon octicon-organization"
Expand All @@ -104,7 +111,7 @@ function Profile() {
d="M1.5 14.25c0 .138.112.25.25.25H4v-1.25a.75.75 0 01.75-.75h2.5a.75.75 0 01.75.75v1.25h2.25a.25.25 0 00.25-.25V1.75a.25.25 0 00-.25-.25h-8.5a.25.25 0 00-.25.25v12.5zM1.75 16A1.75 1.75 0 010 14.25V1.75C0 .784.784 0 1.75 0h8.5C11.216 0 12 .784 12 1.75v12.5c0 .085-.006.168-.018.25h2.268a.25.25 0 00.25-.25V8.285a.25.25 0 00-.111-.208l-1.055-.703a.75.75 0 11.832-1.248l1.055.703c.487.325.779.871.779 1.456v5.965A1.75 1.75 0 0114.25 16h-3.5a.75.75 0 01-.197-.026c-.099.017-.2.026-.303.026h-3a.75.75 0 01-.75-.75V14h-1v1.25a.75.75 0 01-.75.75h-3zM3 3.75A.75.75 0 013.75 3h.5a.75.75 0 010 1.5h-.5A.75.75 0 013 3.75zM3.75 6a.75.75 0 000 1.5h.5a.75.75 0 000-1.5h-.5zM3 9.75A.75.75 0 013.75 9h.5a.75.75 0 010 1.5h-.5A.75.75 0 013 9.75zM7.75 9a.75.75 0 000 1.5h.5a.75.75 0 000-1.5h-.5zM7 6.75A.75.75 0 017.75 6h.5a.75.75 0 010 1.5h-.5A.75.75 0 017 6.75zM7.75 3a.75.75 0 000 1.5h.5a.75.75 0 000-1.5h-.5z"
></path>
</svg>
<span>{profile.company}</span>
<span>{userData.company}</span>
</span>
)}
</div>
Expand Down
Loading