diff --git a/app/Http/Controllers/Frontdesk/ServiceQueueController.php b/app/Http/Controllers/Frontdesk/ServiceQueueController.php index db38e5b..b4412fc 100644 --- a/app/Http/Controllers/Frontdesk/ServiceQueueController.php +++ b/app/Http/Controllers/Frontdesk/ServiceQueueController.php @@ -81,12 +81,30 @@ class ServiceQueueController extends Controller ]); try { - $queue->consoleAction($owner, $counterUuid, $validated); - } catch (RequestException) { - return back()->with('error', 'Queue action failed. Try again.'); + $result = $queue->consoleAction($owner, $counterUuid, $validated); + } catch (RequestException $e) { + $message = $e->response?->json('message') + ?: $e->response?->json('error') + ?: 'Queue action failed. Try again.'; + + return back()->with('error', is_string($message) ? $message : 'Queue action failed. Try again.'); } - return back()->with('success', 'Queue updated.'); + $success = match ($validated['action']) { + 'transfer' => sprintf( + 'Handed off %s to %s. Ticket number unchanged.', + (string) ($result['ticket_number'] ?? 'ticket'), + (string) data_get($result, 'queue.name', 'next queue'), + ), + 'call_next' => ! empty($result['ticket_number']) + ? "Called {$result['ticket_number']}." + : 'No tickets waiting in that queue.', + 'available' => 'Counter marked available.', + 'offline' => 'Counter went offline.', + default => 'Queue updated.', + }; + + return back()->with('success', $success); } protected function integrationEnabled(\App\Models\Organization $organization): bool diff --git a/app/Services/Queue/QueueClient.php b/app/Services/Queue/QueueClient.php index 52867d5..63ab626 100644 --- a/app/Services/Queue/QueueClient.php +++ b/app/Services/Queue/QueueClient.php @@ -108,9 +108,13 @@ class QueueClient /** * @param array $payload + * @return array */ - public function consoleAction(string $owner, string $counterUuid, array $payload): void + public function consoleAction(string $owner, string $counterUuid, array $payload): array { - $this->http($owner)->post($this->base().'/counters/'.$counterUuid.'/console', $payload)->throw(); + $response = $this->http($owner)->post($this->base().'/counters/'.$counterUuid.'/console', $payload); + $response->throw(); + + return (array) ($response->json('data') ?? []); } } diff --git a/resources/views/frontdesk/service-queues/console.blade.php b/resources/views/frontdesk/service-queues/console.blade.php index a41f932..5a3d170 100644 --- a/resources/views/frontdesk/service-queues/console.blade.php +++ b/resources/views/frontdesk/service-queues/console.blade.php @@ -3,7 +3,16 @@ $current = $state['current_ticket'] ?? null; $queues = $state['queues'] ?? []; $waiting = $state['waiting_by_queue'] ?? []; - $transferQueues = $state['transfer_queues'] ?? []; + $transferQueues = collect($state['transfer_queues'] ?? []); + $handoffQueues = $transferQueues + ->filter(fn ($q) => ($q['uuid'] ?? '') !== ($current['queue']['uuid'] ?? '')) + ->values(); + $statusLabel = match ($current['status'] ?? null) { + 'called' => 'Called', + 'serving' => 'Serving', + 'on_hold' => 'On hold', + default => $current['status'] ?? null, + }; @endphp @@ -13,67 +22,103 @@

{{ $counter['name'] ?? 'Counter' }}

{{ $counter['branch'] ?? '' }} · Ladill Queue console

-
-
@csrf
-
@csrf
+
+ @if (! empty($counter['status'])) + {{ $counter['status'] }} + @endif +
+
@csrf
+
@csrf
+
+ @if (session('success')) +

{{ session('success') }}

+ @endif + @if (session('error')) +

{{ session('error') }}

+ @endif + @if ($current)

Current customer

-

{{ $current['ticket_number'] }}

-

{{ $current['queue']['name'] ?? '' }}

-

{{ $current['customer_name'] ?? 'Walk-in customer' }}

+
+
+

{{ $current['ticket_number'] }}

+

{{ $current['queue']['name'] ?? '' }}

+

{{ $current['customer_name'] ?? 'Walk-in customer' }}

+
+ @if ($statusLabel) + {{ $statusLabel }} + @endif +
+
@foreach ([ - 'recall' => 'Recall', - 'start' => 'Start serving', - 'hold' => 'Hold', - 'skip' => 'Skip', - 'complete' => 'Complete', - 'no_show' => 'No show', - ] as $action => $label) + 'recall' => ['Recall', 'btn-secondary'], + 'start' => ['Start serving', 'btn-primary'], + 'hold' => ['Hold', 'btn-secondary'], + 'skip' => ['Skip', 'btn-secondary'], + 'complete' => ['Complete', 'btn-primary'], + 'no_show' => ['No show', 'btn-secondary'], + ] as $action => [$label, $btnClass])
@csrf - +
@endforeach
- @if (count($transferQueues) > 1) -
+ + @if ($handoffQueues->isNotEmpty()) + @csrf - - - +
+

Hand off to another queue

+

Sends this visitor to the next service while keeping ticket {{ $current['ticket_number'] }}.

+
+
+
+ + +
+
+ + +
+ +
@endif
@else -
- No active customer — call the next ticket from a queue below. +
+

No active customer

+

Call the next waiting ticket from a queue below.

@endif
@foreach ($queues as $queue) + @php $waitingTickets = $waiting[$queue['uuid']] ?? []; @endphp
-

{{ $queue['name'] }}

+
+

{{ $queue['name'] }}

+

{{ count($waitingTickets) }} waiting

+
@csrf @@ -82,9 +127,9 @@
    - @forelse ($waiting[$queue['uuid']] ?? [] as $ticket) -
  • - {{ $ticket['ticket_number'] }} + @forelse ($waitingTickets as $ticket) +
  • + {{ $ticket['ticket_number'] }} {{ $ticket['customer_name'] ?? 'Walk-in' }}
  • @empty