fix: harden ticket client data guards
This commit is contained in:
parent
5c5207ceb8
commit
a3d431efa8
9 changed files with 129 additions and 111 deletions
|
|
@ -132,12 +132,17 @@ export function CloseTicketDialog({
|
|||
const addComment = useMutation(api.tickets.addComment)
|
||||
const adjustWorkSummary = useMutation(api.tickets.adjustWorkSummary)
|
||||
|
||||
const closingTemplates = useQuery(
|
||||
const closingTemplateArgs =
|
||||
actorId && open ? { tenantId, viewerId: actorId, kind: "closing" as const } : undefined
|
||||
const closingTemplatesRemote = useQuery(
|
||||
actorId && open ? api.commentTemplates.list : "skip",
|
||||
actorId && open ? { tenantId, viewerId: actorId, kind: "closing" as const } : "skip"
|
||||
) as { id: string; title: string; body: string }[] | undefined
|
||||
closingTemplateArgs
|
||||
)
|
||||
const closingTemplates = Array.isArray(closingTemplatesRemote)
|
||||
? (closingTemplatesRemote as { id: string; title: string; body: string }[])
|
||||
: undefined
|
||||
|
||||
const templatesLoading = Boolean(actorId && open && closingTemplates === undefined)
|
||||
const templatesLoading = Boolean(actorId && open && !Array.isArray(closingTemplatesRemote))
|
||||
const templates = useMemo<ClosingTemplate[]>(() => {
|
||||
if (closingTemplates && closingTemplates.length > 0) {
|
||||
return closingTemplates.map((t) => ({ id: t.id, title: t.title, body: t.body }))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue