import React, { useState, useRef } from "react"; import { generateId } from "../utils.js"; const TYPE_META = { beitrag: { label: "Beitrag", color: "#1a4e8a", bg: "#e8f0fa" }, ankuendigung: { label: "Ankündigung", color: "#b5621e", bg: "#fdf0e8" }, event: { label: "Event", color: "#2d6a4f", bg: "#e8f5ee" }, }; function canWriteCheck(currentUser, data) { const myUser = (data.users || []).find(u => u.id === currentUser?.id); const myRole = (data.appRoles|| []).find(r => r.id === (currentUser?.appRoleId || myUser?.appRoleId)); return currentUser?.role === "admin" || myRole?.permissions === null || (myRole?.permissions || []).includes("pinnwand-schreiben"); } // ─── Poll bar ───────────────────────────────────────────────────────────────── function PollBlock({ poll, postId, currentUserId, onVote }) { if (!poll) return null; const total = Object.keys(poll.votes || {}).length; const myVote = poll.votes?.[currentUserId]; const hasVoted = !!myVote; return (