import React, { useEffect, useState } from 'react' function actorLabel(item) { if (!item.actor) { return 'System' } return item.actor.username ? `@${item.actor.username}` : item.actor.name || 'User' } function timeLabel(dateString) { const date = new Date(dateString) if (Number.isNaN(date.getTime())) { return 'just now' } return date.toLocaleString() } export default function ActivityFeed() { const [items, setItems] = useState([]) const [loading, setLoading] = useState(true) const [error, setError] = useState('') useEffect(() => { let cancelled = false async function load() { try { setLoading(true) const response = await window.axios.get('/api/dashboard/activity') if (!cancelled) { setItems(Array.isArray(response.data?.data) ? response.data.data : []) } } catch (err) { if (!cancelled) { setError('Could not load activity right now.') } } finally { if (!cancelled) { setLoading(false) } } } load() return () => { cancelled = true } }, []) return (

Activity Feed

Recent actions
{loading ?

Loading activity...

: null} {error ?

{error}

: null} {!loading && !error && items.length === 0 ? (

No recent activity yet.

) : null} {!loading && !error && items.length > 0 ? (
{items.map((item) => (

{actorLabel(item)} {item.message}

{item.is_unread ? ( unread ) : null}

{timeLabel(item.created_at)}

))}
) : null}
) }