Tests, UX improvements.
This commit is contained in:
parent
4e6f5d36b8
commit
0ae18f495e
63 changed files with 1384 additions and 2330 deletions
93
app/utils/activityText.js
Normal file
93
app/utils/activityText.js
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
const circleLabel = (c) => c ? c.charAt(0).toUpperCase() + c.slice(1) : c
|
||||
|
||||
const formatters = {
|
||||
member_joined: (m) => ({
|
||||
text: 'Joined Ghost Guild',
|
||||
icon: 'i-lucide-star'
|
||||
}),
|
||||
event_registered: (m) => ({
|
||||
text: `Registered for ${m.eventTitle || 'an event'}`,
|
||||
icon: 'i-lucide-calendar',
|
||||
link: m.eventSlug ? `/events/${m.eventSlug}` : null,
|
||||
linkText: m.eventTitle
|
||||
}),
|
||||
event_cancelled: (m) => ({
|
||||
text: `Cancelled registration for ${m.eventTitle || 'an event'}`,
|
||||
icon: 'i-lucide-calendar-x',
|
||||
link: m.eventSlug ? `/events/${m.eventSlug}` : null,
|
||||
linkText: m.eventTitle
|
||||
}),
|
||||
event_waitlisted: (m) => ({
|
||||
text: `Joined waitlist for ${m.eventTitle || 'an event'}`,
|
||||
icon: 'i-lucide-calendar-clock',
|
||||
link: null,
|
||||
linkText: null
|
||||
}),
|
||||
peer_support_enabled: (m) => ({
|
||||
text: m.topics?.length
|
||||
? `Enabled peer support (${m.topics.join(', ')})`
|
||||
: 'Enabled peer support',
|
||||
icon: 'i-lucide-users'
|
||||
}),
|
||||
peer_support_disabled: () => ({
|
||||
text: 'Disabled peer support',
|
||||
icon: 'i-lucide-users'
|
||||
}),
|
||||
circle_changed: (m) => ({
|
||||
text: `Changed circle from ${circleLabel(m.from)} to ${circleLabel(m.to)}`,
|
||||
icon: 'i-lucide-refresh-cw'
|
||||
}),
|
||||
contribution_changed: (m) => ({
|
||||
text: `Changed contribution from $${m.from}/mo to $${m.to}/mo`,
|
||||
icon: 'i-lucide-coins'
|
||||
}),
|
||||
email_changed: (m) => ({
|
||||
text: `Changed email address`,
|
||||
icon: 'i-lucide-mail'
|
||||
}),
|
||||
profile_updated: (m) => ({
|
||||
text: m.fields?.length
|
||||
? `Updated profile (${m.fields.join(', ')})`
|
||||
: 'Updated profile',
|
||||
icon: 'i-lucide-user-pen'
|
||||
}),
|
||||
subscription_created: (m) => ({
|
||||
text: m.tier ? `Started $${m.tier}/mo subscription` : 'Started subscription',
|
||||
icon: 'i-lucide-credit-card'
|
||||
}),
|
||||
subscription_cancelled: () => ({
|
||||
text: 'Cancelled subscription',
|
||||
icon: 'i-lucide-credit-card'
|
||||
}),
|
||||
status_changed: (m) => ({
|
||||
text: `Status changed from ${m.from} to ${m.to}${m.reason ? ` (${m.reason})` : ''}`,
|
||||
icon: 'i-lucide-shield'
|
||||
}),
|
||||
role_changed: (m) => ({
|
||||
text: `Role changed from ${m.from} to ${m.to}`,
|
||||
icon: 'i-lucide-shield'
|
||||
}),
|
||||
admin_profile_update: (m) => ({
|
||||
text: m.fields?.length
|
||||
? `Profile updated by admin (${m.fields.join(', ')})`
|
||||
: 'Profile updated by admin',
|
||||
icon: 'i-lucide-user-pen'
|
||||
}),
|
||||
slack_invited: (m) => ({
|
||||
text: `Slack invitation: ${m.status || 'sent'}`,
|
||||
icon: 'i-lucide-message-square'
|
||||
}),
|
||||
email_sent: (m) => ({
|
||||
text: m.subject ? `Email: ${m.subject}` : 'Email sent',
|
||||
icon: 'i-lucide-mail',
|
||||
emailBody: m.body || null
|
||||
})
|
||||
}
|
||||
|
||||
export function formatActivity(entry) {
|
||||
const formatter = formatters[entry.type]
|
||||
if (!formatter) {
|
||||
return { text: entry.type.replace(/_/g, ' '), icon: 'i-lucide-activity' }
|
||||
}
|
||||
return formatter(entry.metadata || {})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue