import { useState } from 'react' import { useAnnouncementStore } from '../../state/announcementStore' import Modal from '../common/Modal' /** Reachable only by whoever can_manage_announcements() allows (every Super * Admin, or an Admin individually flagged — see AdminUsersModal). Shows * what's currently live regardless of whether *this* viewer has dismissed * it themselves — that flag is personal, not a proxy for "is it still * showing to everyone else." */ export default function AnnouncementComposerModal({ onClose }: { onClose: () => void }) { const current = useAnnouncementStore((s) => s.current) const post = useAnnouncementStore((s) => s.post) const retireCurrent = useAnnouncementStore((s) => s.retireCurrent) const [message, setMessage] = useState('') const [busy, setBusy] = useState(false) const runAction = async (action: () => Promise) => { setBusy(true) try { await action() } finally { setBusy(false) } } const handlePost = () => { const trimmed = message.trim() if (!trimmed) return runAction(async () => { await post(trimmed) setMessage('') }) } return (
{current ? (

{current.message}

) : (

Nothing is currently showing.

)}