@extends('layouts.nova')
@php
$page_title = $page_title ?? 'Community Activity';
$page_meta_description = 'Track comments, replies, reactions, and mentions from across the Skinbase community in one live feed.';
$page_canonical = route('community.activity', array_filter([
'filter' => ($initialFilter ?? null) && ($initialFilter ?? 'all') !== 'all' ? $initialFilter : null,
'user_id' => $initialUserId ?? null,
], fn (mixed $value): bool => $value !== null && $value !== ''));
$useUnifiedSeo = true;
$headerBreadcrumbs = collect([
(object) ['name' => $page_title, 'url' => $page_canonical],
]);
$breadcrumbs = $headerBreadcrumbs;
$seo = \App\Support\Seo\SeoDataBuilder::fromArray(
app(\App\Support\Seo\SeoFactory::class)->fromViewData(get_defined_vars())
)->build();
$initialFilterLabel = match (($initialFilter ?? 'all')) {
'comments' => 'Comments',
'replies' => 'Replies',
'following' => 'Following',
'my' => 'My Activity',
default => 'All Activity',
};
$serverActivities = $props['initialActivities'] ?? [];
$serverMeta = $props['initialMeta'] ?? [];
$serverFilter = $props['initialFilter'] ?? 'all';
$serverUserId = $props['initialUserId'] ?? null;
$serverIsAuthenticated = (bool) ($props['isAuthenticated'] ?? false);
$serverResultsLabel = ((int) ($serverMeta['total'] ?? count($serverActivities))) > 0
? number_format((int) ($serverMeta['total'] ?? count($serverActivities))) . ' events'
: 'No recent activity';
$serverFilterTabs = [
['key' => 'all', 'label' => 'All Activity', 'auth_required' => false],
['key' => 'comments', 'label' => 'Comments', 'auth_required' => false],
['key' => 'replies', 'label' => 'Replies', 'auth_required' => false],
['key' => 'following', 'label' => 'Following', 'auth_required' => true],
['key' => 'my', 'label' => 'My Activity', 'auth_required' => true],
];
$buildFilterUrl = static function (string $filterKey, ?int $userId): string {
return route('community.activity', array_filter([
'filter' => $filterKey !== 'all' ? $filterKey : null,
'user_id' => $userId,
], static fn (mixed $value): bool => $value !== null && $value !== ''));
};
$describeActivity = static function (array $activity): array {
$type = (string) ($activity['type'] ?? 'activity');
$artworkTitle = (string) data_get($activity, 'artwork.title', 'an artwork');
$artworkUrl = data_get($activity, 'artwork.url');
$storyTitle = (string) data_get($activity, 'story.title', 'a story');
$storyUrl = data_get($activity, 'story.url');
$targetUsername = (string) (data_get($activity, 'target_user.username') ?: data_get($activity, 'target_user.name', 'another creator'));
$targetUrl = data_get($activity, 'target_user.profile_url');
$mentionedUsername = (string) (data_get($activity, 'mentioned_user.username') ?: data_get($activity, 'mentioned_user.name', 'someone'));
$mentionedUrl = data_get($activity, 'mentioned_user.profile_url');
$commentAuthor = (string) (data_get($activity, 'comment.author.name') ?: data_get($activity, 'comment.author.username', 'a creator'));
$commentAuthorUrl = data_get($activity, 'comment.author.profile_url');
$reactionLabel = trim((string) data_get($activity, 'reaction.emoji', '')) . ' ' . (string) data_get($activity, 'reaction.label', 'Like');
return match ($type) {
'upload' => $storyUrl || data_get($activity, 'story.title')
? ['verb' => 'published', 'subject' => $storyTitle, 'subject_url' => $storyUrl, 'context' => null, 'context_url' => null]
: ['verb' => 'published', 'subject' => $artworkTitle, 'subject_url' => $artworkUrl, 'context' => null, 'context_url' => null],
'favorite' => ['verb' => 'favorited', 'subject' => $artworkTitle, 'subject_url' => $artworkUrl, 'context' => null, 'context_url' => null],
'follow' => ['verb' => 'followed', 'subject' => '@' . ltrim($targetUsername, '@'), 'subject_url' => $targetUrl, 'context' => null, 'context_url' => null],
'award' => ['verb' => 'awarded', 'subject' => $artworkTitle, 'subject_url' => $artworkUrl, 'context' => null, 'context_url' => null],
'story_like' => ['verb' => 'liked', 'subject' => $storyTitle, 'subject_url' => $storyUrl, 'context' => null, 'context_url' => null],
'story_comment' => ['verb' => 'commented on', 'subject' => $storyTitle, 'subject_url' => $storyUrl, 'context' => null, 'context_url' => null],
'comment' => ['verb' => 'commented on', 'subject' => $artworkTitle, 'subject_url' => $artworkUrl, 'context' => null, 'context_url' => null],
'reply' => ['verb' => 'replied on', 'subject' => $artworkTitle, 'subject_url' => $artworkUrl, 'context' => null, 'context_url' => null],
'reaction' => ['verb' => 'reacted ' . trim($reactionLabel), 'subject' => $commentAuthor, 'subject_url' => $commentAuthorUrl, 'context' => $artworkTitle, 'context_url' => $artworkUrl],
'mention' => ['verb' => 'mentioned', 'subject' => '@' . ltrim($mentionedUsername, '@'), 'subject_url' => $mentionedUrl, 'context' => $artworkTitle, 'context_url' => $artworkUrl],
default => ['verb' => 'shared new activity on', 'subject' => $artworkTitle, 'subject_url' => $artworkUrl, 'context' => null, 'context_url' => null],
};
};
@endphp
@section('content')
@if (!empty($initialUserId))
@else
@endif
@vite(['resources/js/Pages/Community/CommunityActivityPage.jsx'])
@endsection