Fix tenant event form package selector so it no longer renders empty-value options, handles loading/empty
states, and pulls data from the authenticated /api/v1/tenant/packages endpoint.
(resources/js/admin/pages/EventFormPage.tsx, resources/js/admin/api.ts)
- Harden tenant-admin auth flow: prevent PKCE state loss, scope out StrictMode double-processing, add SPA
routes for /event-admin/login and /event-admin/logout, and tighten token/session clearing semantics (resources/js/admin/auth/{context,tokens}.tsx, resources/js/admin/pages/{AuthCallbackPage,LogoutPage}.tsx,
resources/js/admin/router.tsx, routes/web.php)
This commit is contained in:
@@ -7,7 +7,9 @@ use App\Filament\Resources\EventResource\RelationManagers\EventPackagesRelationM
|
||||
use App\Models\Event;
|
||||
use App\Models\EventType;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\EventJoinTokenEvent;
|
||||
use App\Support\JoinTokenLayoutRegistry;
|
||||
use Carbon\Carbon;
|
||||
use BackedEnum;
|
||||
use Filament\Actions;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
@@ -149,36 +151,89 @@ class EventResource extends Resource
|
||||
->modalContent(function ($record) {
|
||||
$tokens = $record->joinTokens()
|
||||
->orderByDesc('created_at')
|
||||
->get()
|
||||
->map(function ($token) use ($record) {
|
||||
$layouts = JoinTokenLayoutRegistry::toResponse(function (string $layoutId, string $format) use ($record, $token) {
|
||||
return route('tenant.events.join-tokens.layouts.download', [
|
||||
'event' => $record->slug,
|
||||
'joinToken' => $token->getKey(),
|
||||
'layout' => $layoutId,
|
||||
'format' => $format,
|
||||
]);
|
||||
});
|
||||
->get();
|
||||
|
||||
return [
|
||||
'id' => $token->id,
|
||||
'label' => $token->label,
|
||||
'token' => $token->token,
|
||||
'url' => url('/e/' . $token->token),
|
||||
'usage_limit' => $token->usage_limit,
|
||||
'usage_count' => $token->usage_count,
|
||||
'expires_at' => optional($token->expires_at)->toIso8601String(),
|
||||
'revoked_at' => optional($token->revoked_at)->toIso8601String(),
|
||||
'is_active' => $token->isActive(),
|
||||
'created_at' => optional($token->created_at)->toIso8601String(),
|
||||
'layouts' => $layouts,
|
||||
'layouts_url' => route('tenant.events.join-tokens.layouts.index', [
|
||||
'event' => $record->slug,
|
||||
'joinToken' => $token->getKey(),
|
||||
]),
|
||||
];
|
||||
if ($tokens->isEmpty()) {
|
||||
return view('filament.events.join-link', [
|
||||
'event' => $record,
|
||||
'tokens' => collect(),
|
||||
]);
|
||||
}
|
||||
|
||||
$tokenIds = $tokens->pluck('id');
|
||||
$now = now();
|
||||
|
||||
$totals = EventJoinTokenEvent::query()
|
||||
->selectRaw('event_join_token_id, event_type, COUNT(*) as total')
|
||||
->whereIn('event_join_token_id', $tokenIds)
|
||||
->groupBy('event_join_token_id', 'event_type')
|
||||
->get()
|
||||
->groupBy('event_join_token_id');
|
||||
|
||||
$recent24h = EventJoinTokenEvent::query()
|
||||
->selectRaw('event_join_token_id, COUNT(*) as total')
|
||||
->whereIn('event_join_token_id', $tokenIds)
|
||||
->where('occurred_at', '>=', $now->copy()->subHours(24))
|
||||
->groupBy('event_join_token_id')
|
||||
->pluck('total', 'event_join_token_id');
|
||||
|
||||
$lastSeen = EventJoinTokenEvent::query()
|
||||
->whereIn('event_join_token_id', $tokenIds)
|
||||
->selectRaw('event_join_token_id, MAX(occurred_at) as last_at')
|
||||
->groupBy('event_join_token_id')
|
||||
->pluck('last_at', 'event_join_token_id');
|
||||
|
||||
$tokens = $tokens->map(function ($token) use ($record, $totals, $recent24h, $lastSeen) {
|
||||
$layouts = JoinTokenLayoutRegistry::toResponse(function (string $layoutId, string $format) use ($record, $token) {
|
||||
return route('tenant.events.join-tokens.layouts.download', [
|
||||
'event' => $record->slug,
|
||||
'joinToken' => $token->getKey(),
|
||||
'layout' => $layoutId,
|
||||
'format' => $format,
|
||||
]);
|
||||
});
|
||||
|
||||
$analyticsGroup = $totals->get($token->id, collect());
|
||||
$analytics = $analyticsGroup->mapWithKeys(function ($row) {
|
||||
return [$row->event_type => (int) $row->total];
|
||||
});
|
||||
|
||||
$successCount = (int) ($analytics['access_granted'] ?? 0) + (int) ($analytics['gallery_access_granted'] ?? 0);
|
||||
$failureCount = (int) ($analytics['invalid_token'] ?? 0)
|
||||
+ (int) ($analytics['token_expired'] ?? 0)
|
||||
+ (int) ($analytics['token_revoked'] ?? 0)
|
||||
+ (int) ($analytics['token_rate_limited'] ?? 0)
|
||||
+ (int) ($analytics['event_not_public'] ?? 0)
|
||||
+ (int) ($analytics['gallery_expired'] ?? 0);
|
||||
|
||||
$lastSeenAt = $lastSeen->get($token->id);
|
||||
|
||||
return [
|
||||
'id' => $token->id,
|
||||
'label' => $token->label,
|
||||
'token' => $token->token,
|
||||
'url' => url('/e/' . $token->token),
|
||||
'usage_limit' => $token->usage_limit,
|
||||
'usage_count' => $token->usage_count,
|
||||
'expires_at' => optional($token->expires_at)->toIso8601String(),
|
||||
'revoked_at' => optional($token->revoked_at)->toIso8601String(),
|
||||
'is_active' => $token->isActive(),
|
||||
'created_at' => optional($token->created_at)->toIso8601String(),
|
||||
'layouts' => $layouts,
|
||||
'layouts_url' => route('tenant.events.join-tokens.layouts.index', [
|
||||
'event' => $record->slug,
|
||||
'joinToken' => $token->getKey(),
|
||||
]),
|
||||
'analytics' => [
|
||||
'success_total' => $successCount,
|
||||
'failure_total' => $failureCount,
|
||||
'rate_limited_total' => (int) ($analytics['token_rate_limited'] ?? 0),
|
||||
'recent_24h' => (int) $recent24h->get($token->id, 0),
|
||||
'last_seen_at' => $lastSeenAt ? Carbon::parse($lastSeenAt)->toIso8601String() : null,
|
||||
],
|
||||
];
|
||||
});
|
||||
|
||||
return view('filament.events.join-link', [
|
||||
'event' => $record,
|
||||
'tokens' => $tokens,
|
||||
|
||||
Reference in New Issue
Block a user