Skip to content

Commit

Permalink
Merge pull request #42 from ftri4-velocirabbit/miguel/lastMinute
Browse files Browse the repository at this point in the history
added ability to follow and unfollow from search results
  • Loading branch information
dukelee11 authored Oct 8, 2021
2 parents d2ae2f8 + dea35f0 commit cba5711
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion client/common/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Typography from '@mui/material/Typography';
export default function Footer() {

return (
<Box id='footer' sx={{ bgcolor: '#817f70'}}>
<Box id='footer' sx={{ bgcolor: '#f1ede3' }}>
<Stack direction='row'>
<Typography id='copywrite' sx={{ flexGrow: 1 }}>&copy; Recommendation&trade;</Typography>
<Stack>
Expand Down
4 changes: 3 additions & 1 deletion client/friends/Friends.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export default function Friends({
onKeyPress={searchOnKeyPress}
size="small"
color="warning"
sx={{color:'warning.main'}}
sx={{ color: 'warning.main' }}
/>
{!showSearchResult && <>
<Followers
Expand All @@ -143,7 +143,9 @@ export default function Friends({
</>}
{showSearchResult && <SearchResult
users={userSearchResult}
followedUsers={followedUsers}
followUser={followUser}
unfollowUser={unfollowUser}
/>}
</div>
);
Expand Down
31 changes: 21 additions & 10 deletions client/friends/SearchResult.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,31 @@ import Button from '@mui/material/Button';

export default function SearchResult({
users,
followedUsers,
followUser,
unfollowUser,
}) {
return (
<Stack spacing={2} mt={3}>
{users.map(user => (
<Stack key={user.username} direction='row'>
<Typography mr={2}>{user.name}</Typography>
<Button
variant="contained"
size="small"
onClick={() => followUser(user.name, user.username)}
>Follow</Button>
</Stack>
))}
{users.map(user => {
const isFollowingUser = !!followedUsers.find(userItem => userItem.username === user.username);

return (
<Stack key={user.username} direction='row'>
<Typography mr={2}>{user.name}</Typography>
{!isFollowingUser && <Button
variant="contained"
size="small"
onClick={() => followUser(user.name, user.username)}
>Follow</Button>}
{isFollowingUser && <Button
variant="contained"
size="small"
onClick={() => unfollowUser(user.username)}
>Unfollow</Button>}
</Stack>
);
})}
</Stack>
);
}
1 change: 1 addition & 0 deletions client/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ body,
html,
#root {
height: 100%;
background-color: #f2f2f2;
}

#root {
Expand Down
2 changes: 1 addition & 1 deletion server/models/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { Pool } = require('pg');
const { PG_URI } = require('./connection.json');

let pool;
if (process.env.NODE_ENV !== 'test') { //'production') {
if (process.env.NODE_ENV === 'production') { //'test') {
pool = new Pool({
connectionString: PG_URI,
max: 5,
Expand Down

0 comments on commit cba5711

Please sign in to comment.