Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions packages/web/src/components/board/poll-display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export function PollDisplay({ postId, poll, onRefresh }: PollDisplayProps) {
};

const canVote = !poll.isExpired;
const showResults = poll.hasVoted || poll.isExpired;

const handleShowVoters = (option: PollOption) => {
setSelectedOption(option);
Expand All @@ -179,10 +180,12 @@ export function PollDisplay({ postId, poll, onRefresh }: PollDisplayProps) {
<Clock className="h-3 w-3" />
{formatExpiresAt(poll.expiresAt)}
</span>
<span className="inline-flex items-center gap-1">
<Users className="h-3 w-3" />
{poll.totalVotes}명 참여
</span>
{showResults && (
<span className="inline-flex items-center gap-1">
<Users className="h-3 w-3" />
{poll.totalVotes}명 참여
</span>
)}
{poll.isAnonymous && (
<span className="inline-flex items-center gap-1">
<Lock className="h-3 w-3" />
Expand Down Expand Up @@ -211,7 +214,7 @@ export function PollDisplay({ postId, poll, onRefresh }: PollDisplayProps) {
}`}
>
{/* Progress bar background */}
{option.percentage > 0 && (
{showResults && option.percentage > 0 && (
<div
className="absolute inset-0 bg-primary/5 transition-all"
style={{ width: `${option.percentage}%` }}
Expand All @@ -220,7 +223,7 @@ export function PollDisplay({ postId, poll, onRefresh }: PollDisplayProps) {

{/* Content */}
<div className="relative">
<div className="flex items-center justify-between gap-2 mb-2">
<div className="flex items-center justify-between gap-2">
<div className="flex items-center gap-2">
{option.voted && (
<Check className="h-4 w-4 text-primary shrink-0" />
Expand All @@ -229,14 +232,16 @@ export function PollDisplay({ postId, poll, onRefresh }: PollDisplayProps) {
{poll.pollType === 'date' ? formatPollDate(option.optionText) : option.optionText}
</span>
</div>
<span className="text-sm font-semibold tabular-nums">
{option.voteCount}표 ({option.percentage}%)
</span>
{showResults && (
<span className="text-sm font-semibold tabular-nums">
{option.voteCount}표 ({option.percentage}%)
</span>
)}
</div>

{/* Progress bar */}
{option.percentage > 0 && (
<div className="h-1.5 w-full rounded-full bg-border overflow-hidden">
{showResults && option.percentage > 0 && (
<div className="h-1.5 w-full rounded-full bg-border overflow-hidden mt-2">
<div
className="h-full bg-primary transition-all duration-300"
style={{ width: `${option.percentage}%` }}
Expand All @@ -245,7 +250,7 @@ export function PollDisplay({ postId, poll, onRefresh }: PollDisplayProps) {
)}

{/* Voters (non-anonymous only) */}
{!poll.isAnonymous && option.voters.length > 0 && (
{showResults && !poll.isAnonymous && option.voters.length > 0 && (
<div className="flex items-center justify-between gap-2 mt-2.5">
<div className="flex flex-wrap gap-2">
{option.voters.slice(0, 5).map((voter) => (
Expand Down Expand Up @@ -305,6 +310,12 @@ export function PollDisplay({ postId, poll, onRefresh }: PollDisplayProps) {
</div>
)}

{!showResults && canVote && (
<div className="text-center text-xs text-muted-foreground">
투표 후 결과를 확인할 수 있습니다
</div>
)}

{poll.isExpired && !poll.hasVoted && (
<div className="text-center text-sm text-muted-foreground py-2">
마감된 투표입니다
Expand Down
Loading