Files
Toiminnanohjaus/resources/views/components/jobs/customer-picker.blade.php
petriandClaude Opus 5.5 b3d8e66477 Add quick job intake for phones
Phase 1, item 5:
- New page /jobs/quick (Pikavastaanotto): customer (search or quick
  add), name, short description, service unit, responsible person and
  starting status (Alustava or Prospekti) in one column. The job is
  created with CreateCustomerJob, so numbering, reference checks and
  history are the same as on the full form.
- After saving, the form clears for the next job (responsible person
  and status stay), and a status message with the job number and links
  to the job and its edit page takes focus.
- The customer search of the job form moves to a PicksCustomer trait and
  an <x-jobs.customer-picker> component shared by both pages.
- Menu link and a list button for users who may open jobs; nav items
  accept several route patterns.
- PHPStan ignores unused-trait only for Livewire Concerns, which are
  used from excluded single-file components.
- Spec and CLAUDE.md updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-23 19:07:25 +02:00

82 lines
3.2 KiB
PHP

{{--
Customer choice of a job page using the PicksCustomer trait: a search
field whose results are buttons, the number of matches announced, and
"Lisää uusi asiakas" for a name not found. Once chosen, the customer is
shown as text with a "Vaihda asiakas" button.
--}}
@props([
'customerId',
'customerName',
'search',
'results',
'errorKey' => 'form.customer_id',
])
<div {{ $attributes->class('space-y-2') }}>
@if ($customerId !== '')
<p class="text-sm font-semibold text-gray-700 dark:text-dark-300">{{ __('jobs.fields.customer') }}</p>
<div class="flex flex-wrap items-center gap-3">
<span class="font-medium break-words">{{ $customerName }}</span>
<x-button
id="change-customer"
wire:click="clearCustomer"
subtle
color="black"
sm
:text="__('jobs.customer_picker.change')"
:aria-label="__('jobs.customer_picker.change').': '.$customerName"
/>
</div>
@else
<x-input
id="customer-search"
wire:model.live.debounce.300ms="customerSearch"
type="search"
icon="magnifying-glass"
:label="__('jobs.customer_picker.search')"
:hint="__('jobs.customer_picker.search_description')"
autocomplete="off"
required
/>
@error($errorKey)
<p class="text-sm text-red-700 dark:text-red-400">{{ $message }}</p>
@enderror
@if (mb_strlen(trim($search)) >= 2)
<p role="status" aria-live="polite" class="text-sm text-zinc-600 dark:text-zinc-300">
{{ trans_choice('jobs.customer_picker.results', count($results), ['count' => count($results)]) }}
</p>
<ul class="space-y-1">
@foreach ($results as $customer)
<li wire:key="customer-result-{{ $customer->id }}">
<button
type="button"
wire:click="selectCustomer({{ $customer->id }})"
class="w-full rounded-md px-3 py-2 text-left text-sm hover:bg-zinc-100 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-700 dark:hover:bg-zinc-700"
aria-label="{{ __('jobs.customer_picker.choose', ['name' => $customer->name]) }}"
>
<span class="font-medium">{{ $customer->name }}</span>
@if ($customer->businessId !== null)
<span class="text-zinc-600 dark:text-zinc-300">{{ $customer->businessId }}</span>
@endif
</button>
</li>
@endforeach
</ul>
@can('customers.use')
<x-button
wire:click="createCustomer"
subtle
color="black"
sm
icon="plus"
:text="__('jobs.customer_picker.create', ['name' => trim($search)])"
/>
@endcan
@endif
@endif
</div>