Skip to content

Commit

Permalink
added custom tags function and scroll to top on edit functionalities
Browse files Browse the repository at this point in the history
  • Loading branch information
SoumavaBanerjee committed Jan 29, 2021
1 parent 00a1c8f commit 9c8bf66
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/components/Form/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const Form = ({ currentId, setCurrentId }) => {
);

useEffect(() => {
console.log(post);
if (post) setPostData(post);
}, [post]);

Expand Down
12 changes: 9 additions & 3 deletions src/components/Posts/Post/Post.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ const Post = ({ post, setCurrentId }) => {
const dispatch = useDispatch();

const handleClickEdit = (event) => {
console.log(event.target.value);
window.scrollTo({
top: 0,
behavior: 'smooth',
});
setCurrentId(post._id);
};

Expand All @@ -26,7 +29,6 @@ const Post = ({ post, setCurrentId }) => {
};

const handleClickLike = (event) => {
console.log(event.target.value);
dispatch(likePost(post._id));
};

Expand All @@ -47,7 +49,11 @@ const Post = ({ post, setCurrentId }) => {
</div>
<div className={classes.details}>
<Typography variant="body2" color="textSecondary">
{post.tags.map((tag) => `#${tag} `)}
{post.tags.map((tag) => {
let hashTag = tag.trim();
if (hashTag.includes(' ')) return `#${hashTag.replaceAll(' ', '_')} `;
return `#${hashTag} `;
})}
</Typography>
</div>
<Typography className={classes.title} variant="h5" gutterBottom>
Expand Down

0 comments on commit 9c8bf66

Please sign in to comment.