Files
Toiminnanohjaus/app/Modules/Users/Presentation/Livewire/⚡index.blade.php
T
petriandClaude Opus 5.5 90d6f5bd66 Replace Flux UI with TallStackUI 4
Rewrite the layout and all Customers and Users pages with TallStackUI
components and remove livewire/flux and its Boost skill.

Fix the TallStackUI accessibility gaps found by the axe tests:
- password reveal and theme switch have no accessible name: add
  <x-password-field> and keep the own theme toggle button
- select.native label is not tied to the control: add aria-label
- contrast: darker primary palette, soft-customized error colours and
  published alert/link colour classes; neutral buttons use subtle black
- follow the system theme by default (localStorage key dark-theme)

Load TallStackUI assets from the app URL so they work in the XAMPP
subfolder, add Finnish TallStackUI strings, and drop inputmode=numeric
from the business ID field so iOS keyboards show the hyphen.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-22 12:22:03 +02:00

136 lines
4.3 KiB
PHP

<?php
use App\Modules\Users\Application\Contracts\UserAccountQueries;
use App\Modules\Users\Application\DTOs\UserSummary;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Support\Carbon;
use Livewire\Attributes\Computed;
use Livewire\Attributes\Url;
use Livewire\Component;
use Livewire\WithPagination;
new class extends Component
{
use WithPagination;
#[Url(as: 'q', except: '')]
public string $search = '';
protected UserAccountQueries $userQueries;
public function boot(UserAccountQueries $userQueries): void
{
$this->userQueries = $userQueries;
}
public function mount(): void
{
$this->authorize('users.manage');
}
public function updatedSearch(): void
{
$this->resetPage();
}
/**
* @return LengthAwarePaginator<int, UserSummary>
*/
#[Computed]
public function users(): LengthAwarePaginator
{
return $this->userQueries->paginate($this->search);
}
public function statusOf(UserSummary $user): string
{
if (! $user->active) {
return __('users.status.inactive');
}
if ($user->employmentEndsOn === null) {
return __('users.status.active');
}
$endsOn = Carbon::parse($user->employmentEndsOn);
$today = now(config('app.business_timezone'))->toDateString();
return __($user->employmentEndsOn < $today ? 'users.status.ended_on' : 'users.status.ends_on', [
'date' => $endsOn->format('j.n.Y'),
]);
}
/**
* @return list<array{index: string, label: string, sortable: bool, align?: string}>
*/
public function headers(): array
{
return [
['index' => 'name', 'label' => __('users.fields.name'), 'sortable' => false],
['index' => 'email', 'label' => __('users.fields.email'), 'sortable' => false],
['index' => 'role', 'label' => __('users.fields.role'), 'sortable' => false],
['index' => 'status', 'label' => __('users.fields.status'), 'sortable' => false],
['index' => 'action', 'label' => __('users.actions'), 'sortable' => false, 'align' => 'right'],
];
}
public function render(): mixed
{
return $this->view()->title(__('users.title'));
}
};
?>
<div class="mx-auto max-w-5xl space-y-6 p-4 sm:p-6">
<div class="flex flex-wrap items-center justify-between gap-4">
<h1 class="text-2xl font-semibold">{{ __('users.title') }}</h1>
<x-button :href="route('users.create')" wire:navigate icon="plus" :text="__('users.new')" />
</div>
@if (session('status'))
<x-alert role="status" color="green" light icon="check-circle" :text="session('status')" />
@endif
<x-input
wire:model.live.debounce.300ms="search"
type="search"
icon="magnifying-glass"
:label="__('users.search')"
:hint="__('users.search_description')"
/>
<p role="status" aria-live="polite" aria-atomic="true" class="text-sm text-zinc-600 dark:text-zinc-300">
{{ trans_choice('users.result_count', $this->users->total(), ['count' => $this->users->total()]) }}
</p>
@if ($this->users->total() === 0)
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('users.empty') }}</p>
@else
<x-table :headers="$this->headers()" :rows="$this->users" paginate>
@interact('column_name', $user)
<span class="font-medium">{{ $user->name }}</span>
@endinteract
@interact('column_role', $user)
{{ __('users.roles.'.$user->role->value) }}
@if ($user->supervisorName)
<span class="block text-xs text-zinc-600 dark:text-zinc-300">
{{ __('users.fields.supervisor') }}: {{ $user->supervisorName }}
</span>
@endif
@endinteract
@interact('column_status', $user)
{{ $this->statusOf($user) }}
@endinteract
@interact('column_action', $user)
<x-link :href="route('users.edit', $user->id)" navigate>
{{ __('users.edit') }}<span class="sr-only">: {{ $user->name }}</span>
</x-link>
@endinteract
</x-table>
@endif
</div>