presseportale/resources/views/livewire/customer/company-switcher.blade.php
Kevin Adametz 31da9ea8b6
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (push) Waiting to run
livewire: Volt entfernt — Komponenten als Livewire-4-Single-File-Components, Route::livewire(), Livewire::test(); livewire/volt deinstalliert
- 83 Komponenten: Livewire\Volt\Component → Livewire\Component
- 73 Routen (admin, auth, customer): Volt::route() → Route::livewire()
- 88 Testdateien: Volt::test/actingAs → Livewire::test/actingAs
- VoltServiceProvider gelöscht; composer remove livewire/volt
- config/livewire.php auf v4-Schlüssel (component_layout, component_placeholder,
  component_locations, make_command: SFC ohne ⚡). Der alte Schlüssel layout war
  wirkungslos; alle gerouteten Komponenten setzen ihr Layout selbst.
- CLAUDE.md, AGENTS.md, boost.json, .cursorrules, Skill volt-development
- Roadmap: erledigt; Larastan erfasst SFCs weiterhin nicht (Blade-Dateien)

Suite 2.325 grün, einer übersprungen; Larastan und Pint ohne Meldung;
route:cache und view:cache laufen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 13:59:36 +00:00

96 lines
3.4 KiB
PHP

<?php
use App\Services\Customer\CustomerCompanyContext;
use Livewire\Component;
new class extends Component
{
public string $activeCompany = 'all';
public function mount(CustomerCompanyContext $context): void
{
$companyId = $context->selectedCompanyId(auth()->user());
$this->activeCompany = $companyId === null ? 'all' : (string) $companyId;
}
public function updatedActiveCompany(CustomerCompanyContext $context): void
{
if ($this->activeCompany === 'all') {
$context->select(auth()->user(), null);
} elseif (is_numeric($this->activeCompany)) {
$context->select(auth()->user(), (int) $this->activeCompany);
}
$this->redirect($this->redirectTarget(), navigate: false);
}
public function with(CustomerCompanyContext $context): array
{
$user = auth()->user();
$selectedCompanyId = $context->selectedCompanyId($user);
$companies = $context->switcherCompaniesFor($user, $selectedCompanyId, 51);
$visibleCompanies = $companies->take(50)->values();
return [
'companies' => $visibleCompanies,
'hasMoreCompanies' => $companies->count() > 50,
'selectedCompany' => $selectedCompanyId === null
? null
: $visibleCompanies->firstWhere('id', $selectedCompanyId),
'context' => $context,
'user' => $user,
];
}
private function redirectTarget(): string
{
return (string) request()->headers->get('referer', route('me.dashboard'));
}
}; ?>
<div class="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-end">
@if ($companies->isNotEmpty())
<span class="badge hub dot hidden sm:inline-flex">{{ __('Aktive Firma') }}</span>
<div class="min-w-0 sm:w-72">
<flux:select wire:model.live="activeCompany" size="sm">
<option value="all">{{ __('Alle Firmen') }}</option>
@foreach ($companies as $company)
<option value="{{ $company->id }}">
{{ $company->name }} · {{ $context->roleLabelFor($company, $user) }}
</option>
@endforeach
@if ($hasMoreCompanies)
<option value="all" disabled>{{ __('Weitere Firmen über „Firmen" öffnen') }}</option>
@endif
</flux:select>
</div>
<div class="hidden max-w-48 truncate text-[11px] uppercase tracking-[0.6px] font-semibold text-[color:var(--color-ink-3)] lg:block">
@if ($selectedCompany)
{{ $selectedCompany->portal?->label() ?? __('Portal unbekannt') }}
@else
{{ __('Aggregierte Sicht') }}
@endif
</div>
@if ($selectedCompany)
<flux:button
size="sm"
variant="filled"
icon="building-office"
href="{{ route('me.press-kits.show', $selectedCompany->id) }}"
wire:navigate
>
{{ __('Firma öffnen') }}
</flux:button>
@else
<flux:button size="sm" variant="filled" icon="building-office" href="{{ route('me.press-kits.index') }}" wire:navigate>
{{ __('Firmen') }}
</flux:button>
@endif
@else
<span class="badge warn dot">{{ __('Keine Firma zugeordnet') }}</span>
@endif
</div>