68 lines
2.2 KiB
PHP
68 lines
2.2 KiB
PHP
<?php
|
|
|
|
use App\Enums\Portal;
|
|
use Livewire\Volt\Component;
|
|
|
|
new class extends Component
|
|
{
|
|
public string $activePortal = '';
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->activePortal = session('admin_portal_filter', '');
|
|
}
|
|
|
|
public function switchPortal(string $portal): void
|
|
{
|
|
if ($portal === '') {
|
|
session()->forget('admin_portal_filter');
|
|
} else {
|
|
$valid = Portal::tryFrom($portal);
|
|
if ($valid === null) {
|
|
return;
|
|
}
|
|
session(['admin_portal_filter' => $valid->value]);
|
|
}
|
|
|
|
$this->activePortal = $portal;
|
|
$this->redirect($this->redirectTarget(), navigate: false);
|
|
}
|
|
|
|
public function with(): array
|
|
{
|
|
return [
|
|
'portals' => Portal::cases(),
|
|
];
|
|
}
|
|
|
|
private function redirectTarget(): string
|
|
{
|
|
return (string) request()->headers->get('referer', route('dashboard'));
|
|
}
|
|
}; ?>
|
|
|
|
<div class="px-1 py-2">
|
|
<div class="mb-1 text-xs font-medium text-zinc-500 dark:text-zinc-400 uppercase tracking-wider px-2">
|
|
{{ __('Portal-Filter') }}
|
|
</div>
|
|
<div class="flex flex-col gap-1">
|
|
<button
|
|
wire:click="switchPortal('')"
|
|
class="flex items-center gap-2 rounded px-2 py-1.5 text-sm transition-colors {{ $activePortal === '' ? 'bg-zinc-200 dark:bg-zinc-700 font-medium' : 'hover:bg-zinc-100 dark:hover:bg-zinc-800' }}"
|
|
>
|
|
<span class="h-2 w-2 rounded-full bg-zinc-400"></span>
|
|
{{ __('Alle Portale') }}
|
|
</button>
|
|
@foreach($portals as $portal)
|
|
@if($portal !== \App\Enums\Portal::Both)
|
|
<button
|
|
wire:click="switchPortal('{{ $portal->value }}')"
|
|
class="flex items-center gap-2 rounded px-2 py-1.5 text-sm transition-colors {{ $activePortal === $portal->value ? 'bg-zinc-200 dark:bg-zinc-700 font-medium' : 'hover:bg-zinc-100 dark:hover:bg-zinc-800' }}"
|
|
>
|
|
<span class="h-2 w-2 rounded-full {{ $portal === \App\Enums\Portal::Presseecho ? 'bg-green-500' : 'bg-red-500' }}"></span>
|
|
{{ $portal->label() }}
|
|
</button>
|
|
@endif
|
|
@endforeach
|
|
</div>
|
|
</div>
|