+ {/* Vote Counter */}
+ {phase === "voting" && (
+
+
+ Votes remaining: {remainingVotes} / {votesPerUser}
+
+
+ )}
+
+ {/* Anonymous Toggle */}
+ {phase === "input" && (
+
+ setIsAnonymous(!isAnonymous)}>
+ {isAnonymous ? (
+ <>
+
+ Posting Anonymously
+ >
+ ) : (
+ <>
+
+ Posting as {userName}
+ >
+ )}
+
+
+ )}
+
+ {/* Columns */}
+
+ {CATEGORIES.map(({ key, label, color, bgColor }) => (
+
+
+
+ {label}
+ {sortedItems(key).length}
+
+
+
+ {/* Add Item Input */}
+ {phase === "input" && (
+
+ {addingToCategory === key ? (
+
+ ) : (
+
setAddingToCategory(key)}
+ >
+
+ Add item
+
+ )}
+
+ )}
+
+ {/* Items List */}
+
+ {sortedItems(key).map((item, index) => {
+ const userVotesOnItem = getUserVotesOnItem(item.id);
+ const isSelected = selectedItemId === item.id;
+
+ return (
+
+ phase === "discussion" && setSelectedItemId(isSelected ? null : item.id)
+ }
+ >
+
+
+ {item.content}
+
+
+
+ {item.isAnonymous ? "Anonymous" : item.authorName || "Unknown"}
+
+
+ {/* Vote Controls */}
+ {(phase === "voting" || phase === "discussion") && (
+
+
+
+ 0 ? "text-blue-600" : ""}`}
+ onClick={(e) => {
+ e.stopPropagation();
+ if (phase === "voting") {
+ if (userVotesOnItem > 0) {
+ handleUnvote(item.id);
+ } else if (remainingVotes > 0) {
+ handleVote(item.id);
+ }
+ }
+ }}
+ disabled={phase !== "voting"}
+ >
+
+ {item.voteCount}
+
+
+
+ {phase === "voting"
+ ? userVotesOnItem > 0
+ ? "Click to remove vote"
+ : remainingVotes > 0
+ ? "Click to vote"
+ : "No votes remaining"
+ : `${item.voteCount} votes`}
+
+
+
+ )}
+
+ {/* Discussion indicator */}
+ {phase === "discussion" && (
+
+
+
+ )}
+
+ {/* Delete button (only for author in input phase) */}
+ {phase === "input" && item.authorId === userId && (
+
{
+ e.stopPropagation();
+ handleDeleteItem(item.id);
+ }}
+ >
+
+
+ )}
+
+
+
+
+ );
+ })}
+
+
+ {sortedItems(key).length === 0 && (
+ No items yet
+ )}
+
+
+ ))}
+
+
+ {/* Discussion Panel */}
+ {phase === "discussion" && selectedItemId && (
+
+
+ Discussion Notes
+
+
+
+
+ )}
+
+