-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
310 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React from "react"; | ||
import {useState} from 'react'; | ||
import { Link } from "react-router-dom"; | ||
import { Row, Col, Card, Button, ButtonGroup } from "react-bootstrap"; | ||
import { useQuery } from "@apollo/client"; | ||
import { useMutation } from "@apollo/client"; | ||
import { QUERY_USERS} from "../../utils/queries"; | ||
import { ADD_FRIEND } from "../../utils/mutations"; | ||
|
||
const FriendSearch = () => { | ||
const { loading, data } = useQuery(QUERY_USERS); | ||
const [addFriend] = useMutation(ADD_FRIEND); | ||
|
||
const [buttonText, setButtonText] = useState('Add Friend'); | ||
|
||
|
||
|
||
if (loading) { | ||
return <div>Loading...</div>; | ||
} | ||
|
||
const handleClick = async (event) => { | ||
|
||
try { | ||
await addFriend({ | ||
variables: { _id: event.target.value } | ||
}); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
{data.users.map((user) => ( | ||
<Col className="py-3" key={user.username}> | ||
|
||
<Card className="bg-black bg-gradient text-white shadow"> | ||
<div className="d-flex flex-column align-items-center px-3"> | ||
<img | ||
src={user.profileImage} | ||
alt="profilepic" | ||
style={{ borderRadius: "50%", width: "50%" }} | ||
className="my-3" | ||
></img> | ||
<h5>{user.username}</h5> | ||
<button | ||
className="btn w-100 display-block mb-2 btn-primary " | ||
value={user._id} | ||
onClick={handleClick} | ||
> | ||
<i className="bi bi-suit-heart-fill text-white"></i> {buttonText} | ||
</button> | ||
</div> | ||
</Card> | ||
|
||
</Col> | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
export default FriendSearch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from "react"; | ||
import { Container, Row, Col, Card } from "react-bootstrap"; | ||
import { Navbar } from "react-bootstrap"; | ||
import { NavLink } from "react-router-dom"; | ||
|
||
|
||
|
||
|
||
const ProfileNav = () => { | ||
|
||
return ( | ||
<Container> | ||
<Card className="bg-dark bg-gradient text-white shadow"> | ||
<Navbar className="flex-column" variant="dark" expand="md"> | ||
<NavLink to="/profile" className="nav-link"> | ||
Account | ||
</NavLink> | ||
<NavLink to="/profile/user-projects" className="nav-link"> | ||
Your Projects | ||
</NavLink> | ||
<NavLink to="/profile/user-comments" className="nav-link"> | ||
Your Comments | ||
</NavLink> | ||
</Navbar> | ||
</Card> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default ProfileNav; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from "react"; | ||
import { Navigate, useParams } from "react-router-dom"; | ||
import { Container, Row, Col } from "react-bootstrap"; | ||
import ProjectForm from "../components/ProjectForm"; | ||
import ProjectList from "../components/ProjectList"; | ||
import ProfileNav from "../components/ProfileNav"; | ||
//import ProfileError from "../components/ProfileError"; | ||
import { useQuery, useMutation } from "@apollo/client"; | ||
import { QUERY_USER, QUERY_ME, QUERY_USERS} from "../utils/queries"; | ||
import Auth from "../utils/auth"; | ||
import FriendSearch from "../components/FriendSearch"; | ||
|
||
const FriendTab = (props) => { | ||
const { username: userParam } = useParams(); | ||
const { loading, data } = useQuery(userParam ? QUERY_USER : QUERY_ME, { | ||
variables: { | ||
input: { | ||
username: userParam, | ||
}, | ||
}, | ||
}); | ||
|
||
const user = data?.me || data?.user || {}; | ||
|
||
// navigate to personal profile page if username is yours | ||
if (Auth.loggedIn() && Auth.getProfile().data.username === userParam) { | ||
return <Navigate to="/profile/user-projects:username" />; | ||
} | ||
|
||
if (loading) { | ||
return <div>Loading...</div>; | ||
} | ||
|
||
return ( | ||
<Container id="profile-info" className="py-3"> | ||
<Row> | ||
<Col > | ||
<Row xs={3} className="g-4"> | ||
<FriendSearch /> | ||
</Row> | ||
</Col> | ||
|
||
<Col xs={3}> | ||
<Row> | ||
<ProfileNav /> | ||
</Row> | ||
</Col> | ||
</Row> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default FriendTab; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.