import React, { useState } from 'react' import { router, usePage } from '@inertiajs/react' import SeoHead from '../../components/seo/SeoHead' import useWebShare from '../../hooks/useWebShare' function normalizeText(value) { return String(value || '').trim().toLowerCase() } const MEMBER_ROLE_COLORS = { owner: { badge: 'border-amber-300/25 bg-amber-400/10 text-amber-100', icon: 'fa-crown', iconColor: 'text-amber-300' }, admin: { badge: 'border-sky-300/25 bg-sky-400/10 text-sky-100', icon: 'fa-shield-halved', iconColor: 'text-sky-300' }, editor: { badge: 'border-violet-300/25 bg-violet-400/10 text-violet-100', icon: 'fa-pen-nib', iconColor: 'text-violet-300' }, contributor: { badge: 'border-emerald-300/25 bg-emerald-400/10 text-emerald-100', icon: 'fa-star', iconColor: 'text-emerald-300' }, } const POST_TYPE_ICONS = { announcement: { icon: 'fa-bullhorn', bar: 'from-sky-400/80 to-sky-300/30', bg: 'bg-sky-400/10', border: 'border-sky-300/20', text: 'text-sky-200' }, update: { icon: 'fa-rotate', bar: 'from-emerald-400/80 to-emerald-300/30', bg: 'bg-emerald-400/10', border: 'border-emerald-300/20', text: 'text-emerald-200' }, event: { icon: 'fa-calendar-days', bar: 'from-violet-400/80 to-violet-300/30', bg: 'bg-violet-400/10', border: 'border-violet-300/20', text: 'text-violet-200' }, news: { icon: 'fa-newspaper', bar: 'from-amber-400/80 to-amber-300/30', bg: 'bg-amber-400/10', border: 'border-amber-300/20', text: 'text-amber-200' }, discussion: { icon: 'fa-comments', bar: 'from-rose-400/80 to-rose-300/30', bg: 'bg-rose-400/10', border: 'border-rose-300/20', text: 'text-rose-200' }, tutorial: { icon: 'fa-graduation-cap', bar: 'from-teal-400/80 to-teal-300/30', bg: 'bg-teal-400/10', border: 'border-teal-300/20', text: 'text-teal-200' }, } function formatCompactNumber(value) { return Number(value ?? 0).toLocaleString() } function formatDateLabel(value) { if (!value) return null const date = new Date(value) if (Number.isNaN(date.getTime())) return null return date.toLocaleDateString('en-US', { month: 'long', year: 'numeric' }) } function websiteLabel(url) { if (!url) return null try { const parsed = new URL(url.startsWith('http') ? url : `https://${url}`) return parsed.hostname } catch { return String(url).replace(/^https?:\/\//, '') } } const SECTION_TABS = [ { id: 'overview', label: 'Overview', icon: 'fa-compass' }, { id: 'artworks', label: 'Artworks', icon: 'fa-images' }, { id: 'collections', label: 'Collections', icon: 'fa-layer-group' }, { id: 'posts', label: 'Posts', icon: 'fa-newspaper' }, { id: 'projects', label: 'Projects', icon: 'fa-diagram-project' }, { id: 'releases', label: 'Releases', icon: 'fa-rocket' }, { id: 'challenges', label: 'Challenges', icon: 'fa-trophy' }, { id: 'events', label: 'Events', icon: 'fa-calendar-days' }, { id: 'activity', label: 'Activity', icon: 'fa-bolt' }, { id: 'members', label: 'Members', icon: 'fa-users' }, { id: 'about', label: 'About', icon: 'fa-id-card' }, ] function sectionHref(baseUrl, tab) { return tab === 'overview' ? baseUrl : `${baseUrl}/${tab}` } function GroupTabs({ baseUrl, activeSection }) { return (
) } function GroupHero({ group, recruitment, trustSignals, following, followersCount, currentJoinRequest, shareLabel, onToggleFollow, onJoinRequest, onWithdrawJoinRequest, onShare, onReport, reportEndpoint, }) { const activeSignals = Array.isArray(trustSignals) ? trustSignals.slice(0, 3) : [] const joinDate = formatDateLabel(group.founded_at || group.created_at) const heroStats = [ { label: 'Followers', value: formatCompactNumber(followersCount) }, { label: 'Members', value: formatCompactNumber(group.counts?.members) }, { label: 'Artworks', value: formatCompactNumber(group.counts?.artworks) }, { label: 'Collections', value: formatCompactNumber(group.counts?.collections) }, ] return (