Fix public display not showing queue stats and ticket data.
Deploy Ladill Queue / deploy (push) Successful in 43s
Deploy Ladill Queue / deploy (push) Successful in 43s
Server-render initial payload, poll with same-origin relative URLs, fall back to branch queues when none assigned, and improve contrast so stats remain visible if custom CSS is missing. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -27,10 +27,11 @@ class DisplayService
|
||||
public function payload(DisplayScreen $screen): array
|
||||
{
|
||||
$screen->loadMissing(['branch', 'organization']);
|
||||
$queueIds = $screen->service_queue_ids ?? [];
|
||||
$queueIds = $this->resolveQueueIds($screen);
|
||||
$queues = ServiceQueue::query()
|
||||
->whereIn('id', $queueIds)
|
||||
->where('is_active', true)
|
||||
->orderBy('name')
|
||||
->get();
|
||||
|
||||
$nowServing = Ticket::query()
|
||||
@@ -44,7 +45,9 @@ class DisplayService
|
||||
'ticket_number' => $t->ticket_number,
|
||||
'queue_name' => $t->serviceQueue?->name,
|
||||
'counter' => $t->counter?->name,
|
||||
]);
|
||||
])
|
||||
->values()
|
||||
->all();
|
||||
|
||||
$waiting = Ticket::query()
|
||||
->whereIn('service_queue_id', $queueIds)
|
||||
@@ -72,13 +75,37 @@ class DisplayService
|
||||
'queues' => $queues->map(fn (ServiceQueue $q) => [
|
||||
'name' => $q->name,
|
||||
'prefix' => $q->prefix,
|
||||
'is_paused' => $q->is_paused,
|
||||
]),
|
||||
'is_paused' => (bool) $q->is_paused,
|
||||
])->values()->all(),
|
||||
'announcements' => app(VoiceAnnouncementService::class)->pendingForBranch(
|
||||
(int) $screen->branch_id,
|
||||
array_map('intval', $screen->service_queue_ids ?? []),
|
||||
$queueIds,
|
||||
),
|
||||
'updated_at' => now()->toIso8601String(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<int>
|
||||
*/
|
||||
protected function resolveQueueIds(DisplayScreen $screen): array
|
||||
{
|
||||
$ids = array_values(array_unique(array_filter(array_map(
|
||||
fn ($id) => (int) $id,
|
||||
$screen->service_queue_ids ?? [],
|
||||
))));
|
||||
|
||||
if ($ids !== []) {
|
||||
return $ids;
|
||||
}
|
||||
|
||||
return ServiceQueue::query()
|
||||
->where('organization_id', $screen->organization_id)
|
||||
->when($screen->branch_id, fn ($query) => $query->where('branch_id', $screen->branch_id))
|
||||
->where('is_active', true)
|
||||
->orderBy('name')
|
||||
->pluck('id')
|
||||
->map(fn ($id) => (int) $id)
|
||||
->all();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user