presseportale/resources/views/livewire/admin/users/show.blade.php
Kevin Adametz 036a53499f Responsive-Härtung: Seiten-Header, Kontextleiste, Stat-Cards
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 14:08:08 +00:00

249 lines
14 KiB
PHP

<?php
use App\Models\User;
use Livewire\Attributes\Layout;
use Livewire\Attributes\Locked;
use Livewire\Attributes\Title;
use Livewire\Volt\Component;
new #[Layout('components.layouts.app'), Title('Benutzer anzeigen')] class extends Component
{
#[Locked]
public int $id;
public function mount(int $id): void
{
$this->id = $id;
if (! User::query()->whereKey($id)->exists()) {
session()->flash('error', __('Der angeforderte Benutzer wurde nicht gefunden.'));
$this->redirect(route('admin.users.index'), navigate: true);
return;
}
}
public function companyUserRoleLabel(?string $role): string
{
return match ($role ?? 'member') {
'owner' => __('Inhaber'),
'responsible' => __('Verantwortlich'),
'member' => __('Mitglied'),
default => (string) ($role ?? 'member'),
};
}
public function with(): array
{
$user = User::query()
->with([
'roles' => fn ($query) => $query->orderBy('name'),
'companies' => fn ($query) => $query
->select(['companies.id', 'companies.name', 'companies.slug', 'companies.email', 'companies.phone', 'companies.portal', 'companies.is_active'])
->withCount('contacts')
->orderBy('name'),
'companies.contacts' => fn ($query) => $query
->select(['contacts.id', 'contacts.company_id', 'contacts.portal', 'contacts.first_name', 'contacts.last_name', 'contacts.responsibility', 'contacts.email', 'contacts.phone'])
->orderBy('last_name')
->orderBy('first_name')
->limit(10),
'billingAddress',
])
->find($this->id);
return [
'user' => $user,
];
}
}; ?>
<div class="space-y-8">
@if (! $user)
<article class="panel">
<div class="p-10 flex flex-col items-center justify-center text-center">
<div class="w-14 h-14 rounded-[6px] flex items-center justify-center mb-3
bg-[color:var(--color-hub-soft)] border border-[color:var(--color-hub-soft-2)] text-[color:var(--color-hub)]">
<flux:icon.exclamation-triangle class="size-6" />
</div>
<div class="text-[16px] font-semibold text-[color:var(--color-ink)] mb-2">{{ __('Benutzer nicht gefunden') }}</div>
<flux:button variant="primary" href="{{ route('admin.users.index') }}" wire:navigate>
{{ __('Zurück zur Übersicht') }}
</flux:button>
</div>
</article>
@else
{{-- ============== PAGE HEADER ============== --}}
<header class="page-header">
<div class="min-w-0">
<div class="flex items-center gap-3 mb-3 flex-wrap">
<span class="badge hub dot">{{ __('Admin Backend') }}</span>
<span class="eyebrow muted">{{ __('Administration · Benutzer') }}</span>
<span class="badge hub">ID #{{ $user->id }}</span>
@if ($user->is_active)
<span class="badge ok dot">{{ __('Aktiv') }}</span>
@else
<span class="badge err dot">{{ __('Inaktiv') }}</span>
@endif
</div>
<h1 class="text-[30px] font-bold tracking-[-0.6px] leading-[1.15] m-0 text-[color:var(--color-ink)] break-words">
{{ $user->name }}
</h1>
<p class="text-[13px] leading-[1.55] mt-2 m-0 max-w-[640px] text-[color:var(--color-ink-2)]">{{ $user->email }}</p>
</div>
<div class="flex items-center gap-2 flex-shrink-0">
<flux:button variant="filled" icon="arrow-left" href="{{ route('admin.users.index') }}" wire:navigate>
{{ __('Zurück') }}
</flux:button>
<flux:button variant="primary" icon="pencil" href="{{ route('admin.users.edit', $user->id) }}" wire:navigate>
{{ __('Bearbeiten') }}
</flux:button>
</div>
</header>
{{-- ============== KPI-Reihe ============== --}}
<section class="grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4">
<x-portal.stat-card variant="muted" :label="__('Portal')" :value="$user->portal?->label() ?? '-'">
<x-slot:meta>{{ __('Zuordnung') }}</x-slot:meta>
</x-portal.stat-card>
<x-portal.stat-card variant="muted" :label="__('Typ')" :value="$user->registration_type?->label() ?? '-'">
<x-slot:meta>{{ __('Registrierung') }}</x-slot:meta>
</x-portal.stat-card>
@if ($user->is_active)
<x-portal.stat-card variant="ok" :label="__('Status')" :value="__('Aktiv')">
<x-slot:meta>{{ __('Login möglich') }}</x-slot:meta>
</x-portal.stat-card>
@else
<x-portal.stat-card variant="warn" :label="__('Status')" :value="__('Inaktiv')">
<x-slot:meta>{{ __('gesperrt') }}</x-slot:meta>
</x-portal.stat-card>
@endif
<x-portal.stat-card variant="primary" :label="__('Letzter Login')" :value="$user->last_login_at?->format('d.m.Y H:i') ?? __('Nie')">
<x-slot:meta>{{ $user->last_login_ip ?? __('keine IP') }}</x-slot:meta>
</x-portal.stat-card>
</section>
<article class="panel">
<div class="panel-head">
<span class="section-eyebrow">{{ __('Rollen') }}</span>
</div>
<div class="p-5 flex flex-wrap gap-2">
@forelse ($user->roles as $role)
<span class="badge hub">{{ $role->name }}</span>
@empty
<p class="text-[12.5px] text-[color:var(--color-ink-3)] m-0">{{ __('Keine Rollen hinterlegt') }}</p>
@endforelse
</div>
</article>
<article class="panel">
<div class="panel-head">
<span class="section-eyebrow">{{ __('Rechnungsadresse') }}</span>
</div>
<div class="p-5">
@if ($user->billingAddress)
<div class="space-y-1 text-[12.5px] text-[color:var(--color-ink)]">
<div class="font-semibold">{{ $user->billingAddress->name }}</div>
<div>{{ $user->billingAddress->address1 }}</div>
@if ($user->billingAddress->address2)
<div>{{ $user->billingAddress->address2 }}</div>
@endif
<div>{{ $user->billingAddress->postal_code }} {{ $user->billingAddress->city }}</div>
<div>{{ $user->billingAddress->country_code }}</div>
</div>
@else
<p class="text-[12.5px] text-[color:var(--color-ink-3)] m-0">{{ __('Keine Rechnungsadresse hinterlegt') }}</p>
@endif
</div>
</article>
<article class="panel">
<div class="panel-head">
<span class="section-eyebrow">{{ __('Verknüpfte Firmen und Kontakte') }}</span>
</div>
<div class="p-5 space-y-4">
<p class="text-[12.5px] text-[color:var(--color-ink-3)] m-0">
{{ __('Kontakte sind die Ansprechpartner der verknüpften Firmen (wie in der Bearbeiten-Ansicht).') }}
</p>
@forelse ($user->companies as $company)
<div class="rounded-[5px] border border-[color:var(--color-bg-rule)] bg-[color:var(--color-bg-elev)] p-4">
<div class="mb-3 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between">
<div class="min-w-0 flex-1">
@if (\Illuminate\Support\Facades\Route::has('admin.companies.show'))
<a href="{{ route('admin.companies.show', $company->id) }}" wire:navigate
class="text-[13px] font-semibold text-[color:var(--color-hub)] underline underline-offset-2 decoration-[color:var(--color-hub)]/40 hover:decoration-[color:var(--color-hub)]">
{{ $company->name }}
</a>
@else
<div class="text-[13px] font-semibold text-[color:var(--color-ink)]">{{ $company->name }}</div>
@endif
<div class="text-[11px] text-[color:var(--color-ink-3)] font-mono">{{ $company->slug }}</div>
<div class="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11.5px] text-[color:var(--color-ink-3)]">
@if ($company->email)
<span>{{ $company->email }}</span>
@endif
@if ($company->phone)
<span>{{ $company->phone }}</span>
@endif
</div>
</div>
<div class="flex flex-wrap items-center gap-2">
<span class="badge hub">{{ $this->companyUserRoleLabel($company->pivot?->role ?? 'member') }}</span>
<span class="badge hub">{{ $company->portal?->label() ?? '—' }}</span>
@if (! $company->is_active)
<span class="badge err dot">{{ __('Inaktiv') }}</span>
@endif
</div>
</div>
@if ($company->contacts->isNotEmpty())
<div class="space-y-2">
@foreach ($company->contacts as $contact)
<div class="flex flex-col gap-2 rounded-[4px] border border-[color:var(--color-bg-rule)] bg-[color:var(--color-bg-elev)] p-2 sm:flex-row sm:items-center sm:justify-between">
<div class="min-w-0">
<div class="text-[12.5px] font-medium text-[color:var(--color-ink)]">
{{ trim(($contact->first_name ?? '').' '.($contact->last_name ?? '')) ?: __('Kontakt ohne Name') }}
</div>
<div class="text-[11px] text-[color:var(--color-ink-3)]">
{{ $contact->responsibility ?? __('Keine Rolle hinterlegt') }}
</div>
<div class="mt-0.5 flex flex-wrap items-center gap-2 text-[11px] text-[color:var(--color-ink-3)]">
@if ($contact->email)
<a href="mailto:{{ $contact->email }}"
class="text-[color:var(--color-hub)] underline underline-offset-2 decoration-[color:var(--color-hub)]/40 hover:decoration-[color:var(--color-hub)]">{{ $contact->email }}</a>
@endif
@if ($contact->phone)
<span>{{ $contact->phone }}</span>
@endif
</div>
</div>
<div class="flex shrink-0 items-center gap-2">
<span class="badge hub">{{ $contact->portal?->label() ?? '—' }}</span>
@if (\Illuminate\Support\Facades\Route::has('admin.contacts.edit'))
<flux:button size="sm" variant="filled" icon="pencil"
href="{{ route('admin.contacts.edit', $contact->id) }}"
wire:navigate>
{{ __('Bearbeiten') }}
</flux:button>
@endif
</div>
</div>
@endforeach
@if ($company->contacts_count > $company->contacts->count())
<p class="text-[11.5px] text-[color:var(--color-ink-3)] m-0">
{{ __(':count weitere Kontakte werden hier nicht geladen. Öffne die Firma, um alle Kontakte zu sehen.', ['count' => $company->contacts_count - $company->contacts->count()]) }}
</p>
@endif
</div>
@else
<p class="text-[11.5px] text-[color:var(--color-ink-3)] m-0">{{ __('Keine Kontakte bei dieser Firma') }}</p>
@endif
</div>
@empty
<p class="text-[12.5px] text-[color:var(--color-ink-3)] m-0">{{ __('Keine Firmen verknüpft') }}</p>
@endforelse
</div>
</article>
@endif
</div>