-
-
- {post.isWrite && (
-
-
-
-
- )}
-
+ {isVotePost ? (
+ <>
+ {/* 투표 게시글 UI */}
+
+
+ {post.pollQuestion}
+
+
- {/* 투표 게시글 */}
- {post.type === "vote" && post.pollOptions ? (
- <>
-
-
- {post.pollQuestion}
-
-
-
-
- {post.content}
-
-
-
- {post.pollOptions.map((option) => {
- const totalVotes = post.pollOptions!.reduce(
- (sum, opt) => sum + opt.votes,
- 0
- );
-
- const percentage =
- totalVotes > 0
- ? Math.round(
- (option.votes / totalVotes) * 100
- )
- : 0;
-
- const isVoted = post.userVote === option.id;
-
- return (
-
+ {post.content && (
+
+ {post.content}
+
+ )}
- );
- })}
-
- >
- ) : (
- <>
- {/* 내용 */}
-
{post.content}
-
- {/* 이미지 */}
- {post.imageUrl && (
-

- )}
-
- {/* 댓글 목록 */}
- {post.comments.length > 0 && (
-
- {post.comments.map((comment) => (
-
-
-
-
-
-
- {comment.author}
-
+
+ {post.pollOptions!.map((option) => {
+ const totalVotes = post.pollOptions!.reduce(
+ (sum, opt) => sum + (opt.votes ?? 0),
+ 0
+ );
+
+ const percentage =
+ totalVotes > 0
+ ? Math.round(
+ ((option.votes ?? 0) / totalVotes) *
+ 100
+ )
+ : option.percent ?? 0;
+
+ return (
+
+ );
+ })}
+
+ >
+ ) : (
+ <>
+ {/* 일반 게시글 내용 */}
+
{post.content}
+
+ {/* 이미지 */}
+ {post.imageUrl && (
+

+ )}
+
+ {/* 댓글 목록 */}
+ {post.comments.length > 0 && (
+
+ {post.comments.map((comment) => (
+
+
+
+
+
+
+ {comment.author}
+
- {formatDateOnly(comment.timestamp)}
+ {formatDateOnly(
+ comment.timestamp
+ )}
-
+
+ {comment.isWrite && (
+
+ )}
- {comment.isWrite && (
-
+
+
+ {comment.content}
+
+
+ {comment.imageUrl && (
+

)}
-
-
- {comment.content}
-
-
- {comment.imageUrl && (
-

- )}
+ ))}
+
+ )}
+
+ {/* 댓글 입력 */}
+
+ {commentImages[post.id] && (
+
+

+
- ))}
-
- )}
-
- {/* 댓글 입력 */}
-
- {commentImages[post.id] && (
-
-

+ {
+ const file = e.target.files?.[0];
+ if (file) {
+ const reader = new FileReader();
+ reader.onloadend = () => {
+ setCommentImages({
+ ...commentImages,
+ [post.id]:
+ reader.result as string,
+ });
+ };
+ reader.readAsDataURL(file);
+ }
+ }}
/>
-
- )}
-
- {
- const file = e.target.files?.[0];
- if (file) {
- const reader = new FileReader();
- reader.onloadend = () => {
- setCommentImages({
- ...commentImages,
- [post.id]: reader.result as string,
- });
- };
- reader.readAsDataURL(file);
- }
- }}
- />
-
-
-
- setCommentInputs({
- ...commentInputs,
- [post.id]: e.target.value,
- })
- }
- onKeyPress={(e) => {
- if (e.key === "Enter") {
- handleAddComment(team.id, post.id);
+
+ setCommentInputs({
+ ...commentInputs,
+ [post.id]: e.target.value,
+ })
}
- }}
- placeholder="댓글 입력..."
- className="flex-1 bg-transparent text-xs outline-none"
- />
+ onKeyPress={(e) => {
+ if (e.key === "Enter") {
+ handleAddComment(team.id, post.id);
+ }
+ }}
+ placeholder="댓글 입력..."
+ className="flex-1 bg-transparent text-xs outline-none"
+ />
-
+
+
-
- >
- )}
-
- ))}
+ >
+ )}
+
+ );
+ })}
+ {/* 게시글 추가 버튼 */}
- {/* 게시글 추가 다이얼로그 */}
+ {/* 게시글 추가/수정 다이얼로그 */}