import React from 'react' function typeMeta(type) { switch (type) { case 'upload': return { icon: 'fa-solid fa-image', label: 'Upload', tone: 'text-sky-200 bg-sky-400/12 border-sky-300/20' } case 'comment': return { icon: 'fa-solid fa-comment-dots', label: 'Comment', tone: 'text-amber-100 bg-amber-400/12 border-amber-300/20' } case 'reply': return { icon: 'fa-solid fa-reply', label: 'Reply', tone: 'text-orange-100 bg-orange-400/12 border-orange-300/20' } case 'like': return { icon: 'fa-solid fa-heart', label: 'Like', tone: 'text-rose-100 bg-rose-400/12 border-rose-300/20' } case 'favourite': return { icon: 'fa-solid fa-bookmark', label: 'Favourite', tone: 'text-pink-100 bg-pink-400/12 border-pink-300/20' } case 'follow': return { icon: 'fa-solid fa-user-plus', label: 'Follow', tone: 'text-emerald-100 bg-emerald-400/12 border-emerald-300/20' } case 'achievement': return { icon: 'fa-solid fa-trophy', label: 'Achievement', tone: 'text-yellow-100 bg-yellow-400/12 border-yellow-300/20' } case 'forum_post': return { icon: 'fa-solid fa-signs-post', label: 'Forum thread', tone: 'text-violet-100 bg-violet-400/12 border-violet-300/20' } case 'forum_reply': return { icon: 'fa-solid fa-comments', label: 'Forum reply', tone: 'text-indigo-100 bg-indigo-400/12 border-indigo-300/20' } default: return { icon: 'fa-solid fa-bolt', label: 'Activity', tone: 'text-slate-100 bg-white/6 border-white/10' } } } function profileName(actor) { if (!actor) return 'Creator' return actor.username ? `@${actor.username}` : actor.name || 'Creator' } function headline(activity) { switch (activity?.type) { case 'upload': return activity?.artwork?.title ? `Uploaded ${activity.artwork.title}` : 'Uploaded new artwork' case 'comment': return activity?.artwork?.title ? `Commented on ${activity.artwork.title}` : 'Posted a new comment' case 'reply': return activity?.artwork?.title ? `Replied on ${activity.artwork.title}` : 'Posted a reply' case 'like': return activity?.artwork?.title ? `Liked ${activity.artwork.title}` : 'Liked an artwork' case 'favourite': return activity?.artwork?.title ? `Favourited ${activity.artwork.title}` : 'Saved an artwork' case 'follow': return activity?.target_user ? `Started following @${activity.target_user.username || activity.target_user.name}` : 'Started following a creator' case 'achievement': return activity?.achievement?.name ? `Unlocked ${activity.achievement.name}` : 'Unlocked a new achievement' case 'forum_post': return activity?.forum?.thread?.title ? `Started forum thread ${activity.forum.thread.title}` : 'Started a new forum thread' case 'forum_reply': return activity?.forum?.thread?.title ? `Replied in ${activity.forum.thread.title}` : 'Posted a forum reply' default: return 'Shared new activity' } } function body(activity) { if (activity?.comment?.body) return activity.comment.body if (activity?.forum?.post?.excerpt) return activity.forum.post.excerpt if (activity?.achievement?.description) return activity.achievement.description return '' } function cta(activity) { if (activity?.comment?.url) return { href: activity.comment.url, label: 'Open comment' } if (activity?.artwork?.url) return { href: activity.artwork.url, label: 'View artwork' } if (activity?.forum?.post?.url) return { href: activity.forum.post.url, label: 'Open reply' } if (activity?.forum?.thread?.url) return { href: activity.forum.thread.url, label: 'Open thread' } if (activity?.target_user?.profile_url) return { href: activity.target_user.profile_url, label: 'View profile' } return null } function AchievementIcon({ achievement }) { const raw = String(achievement?.icon || '').trim() const className = raw.startsWith('fa-') ? raw : `fa-solid ${raw || 'fa-trophy'}` return (
) } export default function ActivityCard({ activity }) { const meta = typeMeta(activity?.type) const nextAction = cta(activity) const copy = body(activity) return (
{activity?.actor?.avatar_url ? ( {profileName(activity.actor)} ) : (
)}
{profileName(activity.actor)}
{activity?.actor?.badge?.label ? (
{activity.actor.badge.label}
) : null}
{activity?.time_ago || ''}
{meta.label}

{headline(activity)}

{copy ?

{copy}

: null}
{activity?.created_at ? new Date(activity.created_at).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' }) : ''}
{activity?.artwork ? (
{activity.artwork.thumb ? ( {activity.artwork.title} ) : (
)}
{activity.artwork.title}
{Number(activity.artwork.stats?.likes || 0).toLocaleString()} likes {Number(activity.artwork.stats?.views || 0).toLocaleString()} views {Number(activity.artwork.stats?.comments || 0).toLocaleString()} comments
) : null} {activity?.target_user ? (
{activity.target_user.avatar_url ? ( {activity.target_user.username ) : null}
Target creator
@{activity.target_user.username || activity.target_user.name}
) : null} {activity?.achievement ? (
Achievement unlocked
{activity.achievement.name}
{activity.achievement.description ?
{activity.achievement.description}
: null}
) : null} {activity?.forum?.thread ? (
Forum activity
{activity.forum.thread.title}
{activity.forum.thread.category_name}
) : null} {nextAction ? ( {nextAction.label} ) : null}
) }