fix: normalize play next ticket context
This commit is contained in:
parent
8b1f83d7f5
commit
86848a141b
1 changed files with 7 additions and 4 deletions
|
|
@ -8,7 +8,7 @@ import { useMutation, useQuery } from "convex/react"
|
|||
import { api } from "@/convex/_generated/api"
|
||||
import { DEFAULT_TENANT_ID } from "@/lib/constants"
|
||||
import { useAuth } from "@/lib/auth-client"
|
||||
import type { TicketPlayContext, TicketQueueSummary } from "@/lib/schemas/ticket"
|
||||
import type { Ticket, TicketPlayContext, TicketQueueSummary } from "@/lib/schemas/ticket"
|
||||
import type { Id } from "@/convex/_generated/dataModel"
|
||||
import { mapTicketFromServer } from "@/lib/mappers/ticket"
|
||||
import { Badge } from "@/components/ui/badge"
|
||||
|
|
@ -54,11 +54,14 @@ export function PlayNextTicketCard({ context }: PlayNextTicketCardProps) {
|
|||
}
|
||||
: "skip"
|
||||
)?.[0]
|
||||
const nextTicketUi = nextTicketFromServer ? mapTicketFromServer(nextTicketFromServer as unknown) : null
|
||||
const nextTicketUi: Ticket | null = nextTicketFromServer ? mapTicketFromServer(nextTicketFromServer as unknown) : null
|
||||
const sanitizedNextTicket = nextTicketUi
|
||||
? ({ ...nextTicketUi, lastTimelineEntry: nextTicketUi.lastTimelineEntry ?? undefined } as Ticket)
|
||||
: null
|
||||
|
||||
const cardContext: TicketPlayContext | null =
|
||||
context ??
|
||||
(nextTicketUi
|
||||
(sanitizedNextTicket
|
||||
? {
|
||||
queue: {
|
||||
id: "default",
|
||||
|
|
@ -68,7 +71,7 @@ export function PlayNextTicketCard({ context }: PlayNextTicketCardProps) {
|
|||
paused: queueSummary.reduce((acc, item) => acc + item.paused, 0),
|
||||
breached: queueSummary.reduce((acc, item) => acc + item.breached, 0),
|
||||
},
|
||||
nextTicket: nextTicketUi,
|
||||
nextTicket: sanitizedNextTicket,
|
||||
}
|
||||
: null)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue