Align group profile summary contract
This commit is contained in:
@@ -1,10 +1,31 @@
|
||||
import React from 'react'
|
||||
import GroupBadgePill from './GroupBadgePill'
|
||||
import { formatProfileNumber } from '../../lib/profileFormatters'
|
||||
|
||||
export function normalizeGroupContribution(entry = {}) {
|
||||
const counts = entry?.counts || {}
|
||||
const role = entry?.role
|
||||
|
||||
return {
|
||||
...entry,
|
||||
roleLabel: typeof role === 'string' ? role : role?.label || null,
|
||||
trusted: entry?.trusted_indicator ?? entry?.trusted ?? false,
|
||||
counts: {
|
||||
...counts,
|
||||
credited_artworks: counts.credited_artworks ?? counts.artworks ?? 0,
|
||||
releases: counts.releases ?? 0,
|
||||
projects: counts.projects ?? 0,
|
||||
review_actions: counts.review_actions ?? 0,
|
||||
},
|
||||
role_labels: Array.isArray(entry?.role_labels) ? entry.role_labels : [],
|
||||
recent_release_titles: Array.isArray(entry?.recent_release_titles) ? entry.recent_release_titles : [],
|
||||
}
|
||||
}
|
||||
|
||||
export default function GroupProfileSummary({ contributions = [], href = null }) {
|
||||
if (!Array.isArray(contributions) || contributions.length === 0) return null
|
||||
|
||||
const featured = contributions.slice(0, 3)
|
||||
const featured = contributions.slice(0, 3).map(normalizeGroupContribution)
|
||||
|
||||
return (
|
||||
<section className="mx-auto mt-8 max-w-6xl px-4 sm:px-6 lg:px-8">
|
||||
@@ -27,7 +48,7 @@ export default function GroupProfileSummary({ contributions = [], href = null })
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="truncate text-base font-semibold text-white">{entry.group?.name}</div>
|
||||
{entry.role?.label ? <div className="mt-1 text-sm text-slate-400">{entry.role.label}</div> : null}
|
||||
{entry.roleLabel ? <div className="mt-1 text-sm text-slate-400">{entry.roleLabel}</div> : null}
|
||||
{entry.summary ? <div className="mt-2 text-sm text-slate-300">{entry.summary}</div> : null}
|
||||
</div>
|
||||
</div>
|
||||
@@ -35,12 +56,21 @@ export default function GroupProfileSummary({ contributions = [], href = null })
|
||||
<div className="mt-4 flex flex-wrap gap-2">
|
||||
{entry.trusted ? <GroupBadgePill label="Trusted contributor" tone="sky" /> : null}
|
||||
{entry.recent_release_titles?.length ? <GroupBadgePill label="Recent releases" tone="amber" /> : null}
|
||||
{entry.role_labels.map((label, index) => <GroupBadgePill key={`${label}-${index}`} label={label} tone="slate" />)}
|
||||
</div>
|
||||
|
||||
{entry.recent_release_titles.length ? (
|
||||
<div className="mt-3 text-xs text-slate-400">
|
||||
<span className="font-semibold text-slate-300">Recent releases:</span>{' '}
|
||||
{entry.recent_release_titles.join(', ')}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className="mt-4 flex flex-wrap gap-4 text-xs text-slate-400">
|
||||
<span>{Number(entry.counts?.artworks || 0).toLocaleString('en-US')} artworks</span>
|
||||
<span>{Number(entry.counts?.releases || 0).toLocaleString('en-US')} releases</span>
|
||||
<span>{Number(entry.counts?.projects || 0).toLocaleString('en-US')} projects</span>
|
||||
<span>{formatProfileNumber(entry.counts.credited_artworks)} artworks</span>
|
||||
<span>{formatProfileNumber(entry.counts.releases)} releases</span>
|
||||
<span>{formatProfileNumber(entry.counts.projects)} projects</span>
|
||||
<span>{formatProfileNumber(entry.counts.review_actions)} reviews</span>
|
||||
</div>
|
||||
</a>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user