Skip to content

Commit

Permalink
Fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
otaliptus committed Dec 25, 2023
1 parent f7c9b62 commit e51db48
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
26 changes: 14 additions & 12 deletions app/frontend/src/components/CommentCard.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
import React from 'react'
import userlogo from '../user.jpg'
import ReportIcon from '@mui/icons-material/Report'
import DeleteIcon from '@mui/icons-material/Delete';
import DeleteIcon from '@mui/icons-material/Delete'
import { deleteComment } from '../services/commentService'

const CommentCard = ({ comment, onUpvote, onDownvote, currentUser }) => {
const isCurrentUserCreator = comment.creatorUser.username === currentUser.username

const handleDeleteComment = async (commentId) => {
try {
await deleteComment(commentId)
window.location.reload()
} catch (error) {
console.error('Error deleting post:', error)
}
}
try {
await deleteComment(commentId)
window.location.reload()
} catch (error) {
console.error('Error deleting post:', error)
}
}

return (
<div key={comment.commentId} className='card compact bg-neutral-200 text-zinc-800 shadow-xl m-4 p-4'>
<div className='flex-col'>
<div className='flex flex-row mb-2'>
<p className='text-zinc-700 m-2 mb-4 w-full'>{comment.content}</p>
{isCurrentUserCreator ? <button className='text-black rounded mb-4' onClick={() => handleDeleteComment(comment.commentId)}>
<DeleteIcon sx={{ color: '#404040' }} />
</button> : (
{isCurrentUserCreator ? (
<button className='text-black rounded mb-4' onClick={() => handleDeleteComment(comment.commentId)}>
<DeleteIcon sx={{ color: '#404040' }} />
</button>
) : (
<button className='text-black rounded mb-4'>
<ReportIcon sx={{ color: '#404040' }} />
</button>
Expand Down Expand Up @@ -59,4 +61,4 @@ const CommentCard = ({ comment, onUpvote, onDownvote, currentUser }) => {
</div>
)
}
export default CommentCard
export default CommentCard
8 changes: 4 additions & 4 deletions app/frontend/src/components/PostCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TextWithAnnotations from '../components/TextWithAnnotation'
import CloseIcon from '@mui/icons-material/Close'
import { createAnnotation, getAnnotationsByTarget } from '../services/AnnotationService'
import { v4 as uuidv4 } from 'uuid'
import DeleteIcon from '@mui/icons-material/Delete';
import DeleteIcon from '@mui/icons-material/Delete'

const PostCard = ({ post, currentUser, onUpvote, onDownvote }) => {
const isCurrentUserCreator = currentUser && post.creatorUser.username === currentUser.username
Expand Down Expand Up @@ -249,7 +249,7 @@ const PostCard = ({ post, currentUser, onUpvote, onDownvote }) => {
</div>
</div>
</div>
);
};
)
}

export default PostCard;
export default PostCard
17 changes: 8 additions & 9 deletions app/frontend/src/services/userService.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,13 @@ export const getFollowings = (sessionId) => {
}

export const followUser = (sessionId, userId) => {
return axiosInstance.put(`/user/follow-user/${userId}`, {
headers: { Cookie: `SESSIONID=${sessionId}` }
});
};
return axiosInstance.put(`/user/follow-user/${userId}`, {
headers: { Cookie: `SESSIONID=${sessionId}` }
})
}

export const unfollowUser = (sessionId, userId) => {
return axiosInstance.put(`/user/unfollow-user/${userId}`, {
headers: { Cookie: `SESSIONID=${sessionId}` }
});
};

return axiosInstance.put(`/user/unfollow-user/${userId}`, {
headers: { Cookie: `SESSIONID=${sessionId}` }
})
}

0 comments on commit e51db48

Please sign in to comment.