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]>
106 lines
3.4 KiB
PHP
106 lines
3.4 KiB
PHP
<?php
|
|
|
|
use App\Modules\Customers\Application\Contracts\CustomerQueries;
|
|
use App\Modules\Customers\Application\UseCases\RegisterCustomer;
|
|
use App\Modules\Customers\Application\UseCases\UpdateCustomer;
|
|
use App\Modules\Customers\Domain\Enums\CustomerType;
|
|
use App\Modules\Customers\Domain\Exceptions\CustomerNotFound;
|
|
use App\Modules\Customers\Presentation\Livewire\Forms\CustomerForm;
|
|
use App\Modules\Shared\Domain\Exceptions\DomainException;
|
|
use Livewire\Attributes\Locked;
|
|
use Livewire\Component;
|
|
|
|
/**
|
|
* Create page (no route parameter) and edit page (with {customer}).
|
|
*/
|
|
new class extends Component
|
|
{
|
|
#[Locked]
|
|
public ?int $customerId = null;
|
|
|
|
public CustomerForm $form;
|
|
|
|
public function mount(CustomerQueries $customerQueries, ?int $customer = null): void
|
|
{
|
|
$this->authorize('customers.use');
|
|
|
|
if ($customer === null) {
|
|
return;
|
|
}
|
|
|
|
$summary = $customerQueries->findSummary($customer);
|
|
|
|
abort_if($summary === null, 404);
|
|
|
|
$this->customerId = $summary->id;
|
|
$this->form->fillFromSummary($summary);
|
|
}
|
|
|
|
public function save(RegisterCustomer $registerCustomer, UpdateCustomer $updateCustomer): void
|
|
{
|
|
$this->authorize('customers.use');
|
|
|
|
$data = $this->form->toData();
|
|
|
|
try {
|
|
if ($this->customerId === null) {
|
|
$registerCustomer->execute($data);
|
|
session()->flash('status', __('customers.created', ['name' => $data->name]));
|
|
} else {
|
|
$updateCustomer->execute($this->customerId, $data);
|
|
session()->flash('status', __('customers.updated', ['name' => $data->name]));
|
|
}
|
|
} catch (CustomerNotFound) {
|
|
abort(404);
|
|
} catch (DomainException $exception) {
|
|
$this->form->showDomainError($exception);
|
|
|
|
return;
|
|
}
|
|
|
|
$this->redirectRoute('customers.index', navigate: true);
|
|
}
|
|
|
|
public function render(): mixed
|
|
{
|
|
return $this->view()->title(__($this->customerId === null ? 'customers.create_title' : 'customers.edit_title'));
|
|
}
|
|
};
|
|
?>
|
|
|
|
<div class="mx-auto max-w-2xl space-y-6 p-4 sm:p-6">
|
|
<h1 class="text-2xl font-semibold">
|
|
{{ __($customerId === null ? 'customers.create_title' : 'customers.edit_title') }}
|
|
</h1>
|
|
|
|
<form wire:submit="save" class="space-y-6" novalidate>
|
|
<x-input
|
|
wire:model="form.name"
|
|
:label="__('customers.fields.name')"
|
|
autocomplete="organization"
|
|
required
|
|
/>
|
|
|
|
<x-radio.group
|
|
wire:model.live="form.type"
|
|
:label="__('customers.fields.type')"
|
|
:options="collect(CustomerType::cases())->map(fn (CustomerType $type) => ['label' => __('customers.types.'.$type->value), 'value' => $type->value])->all()"
|
|
/>
|
|
|
|
@if ($form->type === CustomerType::Company->value)
|
|
{{-- No inputmode="numeric": the iOS number pad has no hyphen for 1234567-8. --}}
|
|
<x-input
|
|
wire:model="form.business_id"
|
|
:label="__('customers.fields.business_id')"
|
|
:hint="__('customers.fields.business_id_description')"
|
|
autocomplete="off"
|
|
/>
|
|
@endif
|
|
|
|
<div class="flex flex-wrap gap-3">
|
|
<x-button submit :text="__('customers.save')" />
|
|
<x-button :href="route('customers.index')" wire:navigate subtle color="black" :text="__('customers.cancel')" />
|
|
</div>
|
|
</form>
|
|
</div>
|