Skip to content

Commit

Permalink
Add user project feed
Browse files Browse the repository at this point in the history
Relates #13

Co-authored-by: Alexreid95 <[email protected]>
  • Loading branch information
hannahgooding and Alexreid95 committed May 27, 2020
1 parent ff1a850 commit d54d300
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 21 deletions.
2 changes: 1 addition & 1 deletion wip-app/src/components/ProjectFeed/ProjectFeed.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from "react";
import React from "react";
import ProjectCard from "../../components/ProjectCard/ProjectCard";
import { ProjectGrid } from "./ProjectFeed.style";

Expand Down
62 changes: 43 additions & 19 deletions wip-app/src/pages/UserPage/UserPage.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import React from "react";
import { getUser } from "../../utils/get-fetch";
import { getUser, getUserPageProjects } from "../../utils/get-fetch";
import { ProfileCard } from "./UserPage.style";
import ProjectFeed from "../../components/ProjectFeed/ProjectFeed";

const UserPage = (props) => {
const [userInfo, setUserInfo] = React.useState([]);
const [userProjects, setUserProjects] = React.useState([]);

React.useEffect(() => {
getUser().then((userInfo) => {
setUserInfo(userInfo);
});
}, []);

// email: "[email protected]"
// id: 2
// user_bio: "I love colours they are so nice"
// user_link_1: "www.facebook.com"
// user_link_2: "www.instagram.com"
// user_link_3: "www.twitter.com"
// user_vocation: "professional animator"
// username: "Jacko"
React.useEffect(() => {
getUserPageProjects().then((userProjects) => {
setUserProjects(userProjects);
});
}, []);

const {
username,
Expand All @@ -29,20 +29,44 @@ const UserPage = (props) => {
user_link_3,
} = userInfo;

console.log("userlink", user_link_1);

return (
<>
{userInfo !== [] ? (
{userInfo === [] || userProjects === [] ? (
<h1>Loading...</h1>
) : (
// this is not rendering
<>
<h1>{username}'s Profile</h1>
<p>{email}</p>
<a href={user_link_1}>Link 1</a>
<a href={user_link_2}>Link 2</a>
<a href={user_link_3}>Link 3</a>
<p>{user_bio}</p>
<p>{user_vocation}</p>
<ProfileCard>
<h1>{username}'s Profile</h1>
<p>{email}</p>
<a
href={"https://" + user_link_1}
target="_blank"
rel="noopener noreferrer"
>
Link 1
</a>
<a
href={"https://" + user_link_2}
target="_blank"
rel="noopener noreferrer"
>
Link 2
</a>
<a
href={"https://" + user_link_3}
target="_blank"
rel="noopener noreferrer"
>
Link 3
</a>
<p>{user_bio}</p>
<p>{user_vocation}</p>
</ProfileCard>
<ProjectFeed projects={userProjects} />
</>
) : (
<h1>Loading...</h1>
)}
</>
);
Expand Down
8 changes: 8 additions & 0 deletions wip-app/src/pages/UserPage/UserPage.style.js
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
import styled from "styled-components";

const ProfileCard = styled.section`
display: flex;
flex-direction: column;
align-items: center;
`;

export { ProfileCard };
10 changes: 9 additions & 1 deletion wip-app/src/utils/get-fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,12 @@ function explorePage() {
return getFetch(options);
}

export { feedPage, getUser, explorePage };
function getUserPageProjects() {
const options = {
endpoint: "userprojects",
errorMessage: "Project feed error",
};
return getFetch(options);
}

export { feedPage, getUser, explorePage, getUserPageProjects };

0 comments on commit d54d300

Please sign in to comment.