import React, { useState, useEffect, useRef } from 'react'; import { createPortal } from 'react-dom'; import { Calendar, Tag, ChevronRight, X, User } from "lucide-react"; import { colors } from "../../theme/colors"; import { API_BASE_URL } from '../../config/api'; import branding from '../../branding'; const AnnouncementModal = ({ announcement, onClose }) => { const dialogRef = useRef(null); useEffect(() => { const previousOverflow = document.body.style.overflow; const previousFocus = document.activeElement; const handleKeyDown = (event) => { if (event.key === 'Escape') onClose(); if (event.key !== 'Tab' || !dialogRef.current) return; const controls = dialogRef.current.querySelectorAll('button, a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])'); if (!controls.length) return; const first = controls[0]; const last = controls[controls.length - 1]; if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last.focus(); } else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus(); } }; document.body.style.overflow = 'hidden'; document.addEventListener('keydown', handleKeyDown); dialogRef.current?.focus(); return () => { document.body.style.overflow = previousOverflow; document.removeEventListener('keydown', handleKeyDown); previousFocus?.focus?.(); }; }, [onClose]); if (!announcement) return null; const getTagColor = (tag) => { const lowerTag = tag.toLowerCase(); if (lowerTag.includes('update') || lowerTag.includes('feature')) return colors.green; if (lowerTag.includes('alert') || lowerTag.includes('maintenance') || lowerTag.includes('downtime')) return colors.red; if (lowerTag.includes('technical') || lowerTag.includes('info')) return colors.blue; return colors.yellow; }; const formatDate = (dateString) => { try { const date = new Date(dateString); return date.toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit' }); } catch (e) { return dateString; } }; return createPortal(
Updates
Platform updates
Service changes and notes from the {branding.name} team.