From 0800213e805c40f934ca530f4310f341b7ddba9d Mon Sep 17 00:00:00 2001 From: HolgerHatGarKeineNode Date: Fri, 21 Nov 2025 12:31:32 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Enhance=20RSVP=20and=20attendee=20m?= =?UTF-8?q?anagement=20for=20meetup=20events?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/views/livewire/auth/login.blade.php | 2 +- resources/views/livewire/dashboard.blade.php | 20 +- .../meetups/landingpage-event.blade.php | 228 ++++++++++++++++-- 3 files changed, 224 insertions(+), 26 deletions(-) diff --git a/resources/views/livewire/auth/login.blade.php b/resources/views/livewire/auth/login.blade.php index ec0564d..af405d7 100644 --- a/resources/views/livewire/auth/login.blade.php +++ b/resources/views/livewire/auth/login.blade.php @@ -172,7 +172,7 @@ class extends Component { {{----}} - {{ __('Log in mit Nostr') }} + {{ __('Log in mit Nostr') }} diff --git a/resources/views/livewire/dashboard.blade.php b/resources/views/livewire/dashboard.blade.php index 8a45d3a..2e07008 100644 --- a/resources/views/livewire/dashboard.blade.php +++ b/resources/views/livewire/dashboard.blade.php @@ -73,17 +73,19 @@ new class extends Component {
@foreach($myUpcomingEvents as $event) -
- @else diff --git a/resources/views/livewire/meetups/landingpage-event.blade.php b/resources/views/livewire/meetups/landingpage-event.blade.php index dc25b2d..cfe3ea3 100644 --- a/resources/views/livewire/meetups/landingpage-event.blade.php +++ b/resources/views/livewire/meetups/landingpage-event.blade.php @@ -1,15 +1,27 @@ country = request()->route('country'); + $this->name = auth()->user()->name ?? ''; + $this->loadAttendees(); } public function with(): array @@ -18,13 +30,120 @@ new class extends Component { 'event' => $this->event->load('meetup'), ]; } + + private function getUserIdentifier(): string + { + return auth()->check() + ? 'id_'.auth()->id() + : 'anon_'.session()->getId(); + } + + private function loadAttendees(): void + { + $identifier = $this->getUserIdentifier(); + $attendees = collect($this->event->attendees ?? []); + $mightAttendees = collect($this->event->might_attendees ?? []); + + // Check if user is in attendees + $attendeeEntry = $attendees->first(fn($v) => str($v)->startsWith($identifier)); + if ($attendeeEntry) { + $this->name = str($attendeeEntry)->after('|')->toString(); + $this->willShowUp = true; + } + + // Check if user is in might_attendees + $mightAttendeeEntry = $mightAttendees->first(fn($v) => str($v)->startsWith($identifier)); + if ($mightAttendeeEntry) { + $this->name = str($mightAttendeeEntry)->after('|')->toString(); + $this->perhapsShowUp = true; + } + + $this->attendees = $this->mapAttendees($attendees); + $this->mightAttendees = $this->mapAttendees($mightAttendees); + } + + private function mapAttendees($collection): array + { + return $collection->map(function ($value) { + $isAnon = str($value)->contains('anon_'); + $id = $isAnon ? -1 : str($value)->before('|')->after('id_')->toInteger(); + + return [ + 'id' => $id, + 'user' => $id > 0 ? User::query() + ->select(['id', 'name', 'profile_photo_path']) + ->find($id) + ?->append('profile_photo_url') + ->toArray() : null, + 'name' => str($value)->after('|')->toString(), + ]; + })->toArray(); + } + + public function attend(): void + { + $this->validate(); + $this->removeFromLists(); + + $attendees = collect($this->event->attendees ?? []); + $entry = $this->getUserIdentifier().'|'.$this->name; + + if (!$attendees->contains($entry)) { + $attendees->push($entry); + $this->event->update(['attendees' => $attendees->toArray()]); + } + + $this->loadAttendees(); + } + + public function mightAttend(): void + { + $this->validate(); + $this->removeFromLists(); + + $mightAttendees = collect($this->event->might_attendees ?? []); + $entry = $this->getUserIdentifier().'|'.$this->name; + + if (!$mightAttendees->contains($entry)) { + $mightAttendees->push($entry); + $this->event->update(['might_attendees' => $mightAttendees->toArray()]); + } + + $this->loadAttendees(); + } + + public function cannotCome(): void + { + $this->removeFromLists(); + $this->loadAttendees(); + } + + private function removeFromLists(): void + { + $identifier = $this->getUserIdentifier(); + + $attendees = collect($this->event->attendees ?? []) + ->reject(fn($v) => str($v)->startsWith($identifier)); + + $mightAttendees = collect($this->event->might_attendees ?? []) + ->reject(fn($v) => str($v)->startsWith($identifier)); + + $this->event->update([ + 'attendees' => $attendees->toArray(), + 'might_attendees' => $mightAttendees->toArray(), + ]); + + $this->willShowUp = false; + $this->perhapsShowUp = false; + } }; ?>
- + {{ $event->meetup->name }} / @@ -35,24 +154,25 @@ new class extends Component { - + {{ $event->start->format('d.m.Y') }}
- +
{{ $event->start->format('H:i') }} Uhr
-
{{ $event->start->isoFormat('dddd, D. MMMM YYYY') }}
+
{{ $event->start->isoFormat('dddd, D. MMMM YYYY') }}
@if($event->location)
- +
{{ __('Ort') }}
{{ $event->location }}
@@ -72,35 +192,109 @@ new class extends Component { @if($event->link)
- + {{ __('Mehr Informationen') }}
@endif + +
+ {{ __('Teilnahme') }} + +
+ + @if(!auth()->check()) + + {{ __('Du bist nicht eingloggt und musst deshalb den Namen selbst eintippen.') }} + + {{ __('Log in') }} + + + @endif + + + + {{ __('Dein Name') }} + + @error('name') + {{ $message }} + @enderror + + + +
+ + {{ __('Ich komme') }} + + + + {{ __('Vielleicht') }} + + + @if($willShowUp || $perhapsShowUp) + + {{ __('Absagen') }} + + @endif +
+
+
+ - @if($event->attendees && count($event->attendees) > 0) + @if(count($attendees) > 0)
- {{ __('Zusagen') }} ({{ count($event->attendees) }}) + {{ __('Zusagen') }} ({{ count($attendees) }})
- @foreach($event->attendees as $attendee) - {{ $attendee }} + @foreach($attendees as $attendee) + @if($attendee['user']) +
+ + {{ $attendee['name'] }} +
+ @else + {{ $attendee['name'] }} + @endif @endforeach
@endif - @if($event->might_attendees && count($event->might_attendees) > 0) + @if(count($mightAttendees) > 0)
- {{ __('Vielleicht') }} ({{ count($event->might_attendees) }}) + {{ __('Vielleicht') }} ({{ count($mightAttendees) }})
- @foreach($event->might_attendees as $attendee) - {{ $attendee }} + @foreach($mightAttendees as $attendee) + @if($attendee['user']) +
+ + {{ $attendee['name'] }} +
+ @else + {{ $attendee['name'] }} + @endif @endforeach
@@ -110,8 +304,10 @@ new class extends Component {
- - + + {{ __('Zurück zum Meetup') }}