Improve conditional rendering and authentication logic in views

- Updated multiple views to conditionally render actions based on authentication state for a better user experience.
- Added login links where actions require authentication.
This commit is contained in:
HolgerHatGarKeineNode
2025-11-23 17:42:46 +01:00
parent a1036e3ec0
commit 454c8e53a5
10 changed files with 255 additions and 207 deletions

View File

@@ -86,13 +86,15 @@ class extends Component {
</flux:table.cell>
<flux:table.cell>
<div class="flex gap-2">
@auth
@if(auth()->check())
<flux:button size="xs"
:href="route('cities.edit',['city' => $city, 'country' => $country])"
icon="pencil">
{{ __('Edit') }}
</flux:button>
@endauth
@elseif(!auth()->check())
<flux:link :href="route('login')">{{ __('Log in') }}</flux:link>
@endif
</div>
</flux:table.cell>
</flux:table.row>

View File

@@ -3,30 +3,36 @@
use Livewire\Volt\Component;
new class extends Component {
public $currentRoute = '';
public $country = 'de';
public $currentRouteName;
public $currentRouteParams;
public string $currentCountry = 'de';
public function mount(): void
{
$this->currentRoute = request()->route()->getName();
$this->country = request()->route('country');
$this->currentCountry = request()->route('country', 'de');
$this->currentRouteName = request()->route()->getName();
$this->currentRouteParams = request()->route()->parameters();
}
public function updatedCountry()
public function updatedCurrentCountry()
{
$this->redirectRoute($this->currentRoute, ['country' => $this->country]);
$this->currentRouteParams['country'] = $this->currentCountry;
$this->redirectRoute($this->currentRouteName, $this->currentRouteParams);
}
}; ?>
<div>
<flux:select variant="listbox" searchable placeholder="{{ __('Wähle dein Land...') }}" wire:model.live.debounce="country">
<flux:select variant="listbox" searchable placeholder="{{ __('Wähle dein Land...') }}"
wire:model.live.debounce="currentCountry">
<x-slot name="search">
<flux:select.search class="px-4" placeholder="{{ __('Suche dein Land...') }}"/>
</x-slot>
@foreach(\WW\Countries\Models\Country::all() as $country)
<flux:select.option value="{{ str($country->iso_code)->lower() }}">
<div class="flex items-center space-x-2">
<img alt="{{ str($country->iso_code)->lower() }}" src="{{ asset('vendor/blade-flags/country-'.str($country->iso_code)->lower().'.svg') }}" width="24" height="12"/>
<img alt="{{ str($country->iso_code)->lower() }}"
src="{{ asset('vendor/blade-flags/country-'.str($country->iso_code)->lower().'.svg') }}"
width="24" height="12"/>
<span>{{ $country->name }}</span>
</div>
</flux:select.option>

View File

@@ -115,6 +115,7 @@ class extends Component {
<flux:table.cell>
<div class="flex flex-col space-y-2">
@if(auth()->check() && $course->created_by === auth()->id())
<div>
<flux:button
:disabled="$course->created_by !== auth()->id()"
@@ -135,6 +136,9 @@ class extends Component {
{{ __('Neues Event erstellen') }}
</flux:button>
</div>
@elseif(!auth()->check())
<flux:link :href="route('login')">{{ __('Log in') }}</flux:link>
@endif
</div>
</flux:table.cell>
</flux:table.row>

View File

@@ -154,7 +154,7 @@ class extends Component {
</div>
</a>
</div>
<div class="flex items-center gap-2">
<div class="flex flex-col sm:flex-row items-start gap-2">
<flux:button :href="route_with_country('meetups.edit', ['meetup' => $meetup])"
size="xs" variant="ghost" icon="pencil">
{{ __('Bearbeiten') }}

View File

@@ -139,6 +139,7 @@ class extends Component {
</flux:table.cell>
<flux:table.cell>
@if(auth()->check() && $lecturer->created_by === auth()->id())
<flux:button
:disabled="$lecturer->created_by !== auth()->id()"
:href="$lecturer->created_by === auth()->id() ? route_with_country('lecturers.edit', ['lecturer' => $lecturer]) : null"
@@ -147,6 +148,9 @@ class extends Component {
icon="pencil">
{{ __('Bearbeiten') }}
</flux:button>
@elseif(!auth()->check())
<flux:link :href="route('login')">{{ __('Log in') }}</flux:link>
@endif
</flux:table.cell>
</flux:table.row>
@endforeach

View File

@@ -161,6 +161,7 @@ class extends Component {
<flux:table.cell>
<div class="flex flex-col space-y-2">
@if(auth()->check() && $meetup->belongsToMe)
<div>
<flux:button
:disabled="!$meetup->belongsToMe"
@@ -171,11 +172,15 @@ class extends Component {
</flux:button>
</div>
<div>
<flux:button :href="route_with_country('meetups.events.create', ['meetup' => $meetup])"
<flux:button
:href="route_with_country('meetups.events.create', ['meetup' => $meetup])"
size="xs" variant="filled" icon="calendar">
{{ __('Neues Event erstellen') }}
</flux:button>
</div>
@elseif(!auth()->check())
<flux:link :href="route('login')">{{ __('Log in') }}</flux:link>
@endif
</div>
</flux:table.cell>
</flux:table.row>

View File

@@ -157,6 +157,8 @@ class extends Component {
</flux:text>
</div>
<div class="flex flex-col md:flex-row gap-8">
<div class="md:w-2/3">
<!-- Event Details -->
<flux:card class="max-w-3xl">
<flux:heading size="xl" class="mb-4">
@@ -318,3 +320,21 @@ class extends Component {
</flux:button>
</div>
</div>
<div class="md:w-1/3">
<div class="flex flex-col sm:flex-row items-center space-x-0 sm:space-x-4 space-y-4 sm:space-y-0 mb-8">
<flux:avatar class="[:where(&)]:size-32 [:where(&)]:text-base" size="xl"
src="{{ $event->meetup->getFirstMediaUrl('logo') }}"/>
<div class="space-y-2">
<flux:heading size="xl" class="mb-4">{{ $event->meetup->name }}</flux:heading>
<flux:subheading class="text-gray-600 dark:text-gray-400">
{{ $event->meetup->city->name }}, {{ $event->meetup->city->country->name }}
</flux:subheading>
<flux:button class="cursor-pointer"
x-copy-to-clipboard="'{{ route('ics', ['meetup' => $event->meetup]) }}'"
icon="calendar-date-range">{{ __('Kalender-Stream-URL kopieren') }}</flux:button>
</div>
</div>
</div>
</div>
</div>

View File

@@ -37,7 +37,7 @@ class extends Component {
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
<!-- Left Column: Meetup Details -->
<div class="space-y-6">
<div class="flex items-center space-x-4">
<div class="flex flex-col sm:flex-row items-center space-x-0 sm:space-x-4 space-y-4 sm:space-y-0">
<flux:avatar class="[:where(&)]:size-32 [:where(&)]:text-base" size="xl"
src="{{ $meetup->getFirstMediaUrl('logo') }}"/>
<div class="space-y-2">
@@ -196,10 +196,10 @@ class extends Component {
</div>
</div>
<!-- Events Section -->
{{-- Events Section --}}
@if($events->isNotEmpty())
<div class="mt-16">
<div class="flex items-center space-x-4 mb-6">
<div class="flex flex-col sm:flex-row items-center sm:space-x-4 space-y-4 sm:space-y-0 mb-6">
<flux:heading size="xl">{{ __('Kommende Veranstaltungen') }}</flux:heading>
@if(auth()->user() && auth()->user()->meetups()->find($meetup->id)?->exists)
<flux:button :href="route_with_country('meetups.events.create', ['meetup' => $meetup])"

View File

@@ -80,13 +80,15 @@ class extends Component {
</flux:table.cell>
<flux:table.cell>
<div class="flex gap-2">
@auth
@if(auth()->check())
<flux:button size="xs"
:href="route('venues.edit', ['venue' => $venue, 'country' => $country])"
icon="pencil">
{{ __('Edit') }}
</flux:button>
@endauth
@elseif(!auth()->check())
<flux:link :href="route('login')">{{ __('Log in') }}</flux:link>
@endif
</div>
</flux:table.cell>
</flux:table.row>

View File

@@ -43,6 +43,11 @@ Volt::route('welcome', 'welcome')->name('welcome');
Route::get('stream-calendar', \App\Http\Controllers\DownloadMeetupCalendar::class)
->name('ics');
Route::middleware(['auth'])
->get('dashboard', function () {
return redirect('/de/dashboard'); // Zu /de weiterleiten
});
Route::middleware([])
->prefix('/{country:code}')
->group(function () {