debug(checklist): adiciona logs para investigar templateDescription
Adiciona: - Query debugTemplateAndTicketChecklist para verificar dados no backend - Console.log no frontend para verificar dados recebidos Esses logs serao removidos apos identificar o problema. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
58cda4f6ea
commit
db73e87cdc
2 changed files with 62 additions and 1 deletions
|
|
@ -325,3 +325,52 @@ export const remove = mutation({
|
|||
return { ok: true }
|
||||
},
|
||||
})
|
||||
|
||||
// DEBUG: Query para verificar dados do template e checklist de um ticket
|
||||
export const debugTemplateAndTicketChecklist = query({
|
||||
args: {
|
||||
tenantId: v.string(),
|
||||
viewerId: v.id("users"),
|
||||
templateId: v.id("ticketChecklistTemplates"),
|
||||
ticketId: v.optional(v.id("tickets")),
|
||||
},
|
||||
handler: async (ctx, { tenantId, viewerId, templateId, ticketId }) => {
|
||||
await requireStaff(ctx, viewerId, tenantId)
|
||||
|
||||
const template = await ctx.db.get(templateId)
|
||||
if (!template || template.tenantId !== tenantId) {
|
||||
return { error: "Template nao encontrado" }
|
||||
}
|
||||
|
||||
const templateData = {
|
||||
id: String(template._id),
|
||||
name: template.name,
|
||||
description: template.description,
|
||||
hasDescription: Boolean(template.description),
|
||||
descriptionType: typeof template.description,
|
||||
itemsCount: template.items?.length ?? 0,
|
||||
}
|
||||
|
||||
let ticketData = null
|
||||
if (ticketId) {
|
||||
const ticket = await ctx.db.get(ticketId)
|
||||
if (ticket && ticket.tenantId === tenantId) {
|
||||
ticketData = {
|
||||
id: String(ticket._id),
|
||||
checklistCount: ticket.checklist?.length ?? 0,
|
||||
checklistItems: (ticket.checklist ?? []).map((item) => ({
|
||||
id: item.id,
|
||||
text: item.text.substring(0, 50),
|
||||
templateId: item.templateId ? String(item.templateId) : null,
|
||||
templateDescription: item.templateDescription,
|
||||
hasTemplateDescription: Boolean(item.templateDescription),
|
||||
description: item.description,
|
||||
hasDescription: Boolean(item.description),
|
||||
})),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { template: templateData, ticket: ticketData }
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"use client"
|
||||
|
||||
import { useMemo, useState } from "react"
|
||||
import { useEffect, useMemo, useState } from "react"
|
||||
import { useMutation, useQuery } from "convex/react"
|
||||
import { CheckCheck, ListChecks, Plus, RotateCcw, Trash2 } from "lucide-react"
|
||||
import { toast } from "sonner"
|
||||
|
|
@ -49,6 +49,18 @@ export function TicketChecklistCard({
|
|||
const isResolved = ticket.status === "RESOLVED"
|
||||
|
||||
const checklist = useMemo(() => ticket.checklist ?? [], [ticket.checklist])
|
||||
|
||||
// DEBUG: Verificar dados do checklist
|
||||
useEffect(() => {
|
||||
if (checklist.length > 0) {
|
||||
console.log("[DEBUG] Checklist items:", checklist.map(item => ({
|
||||
id: item.id,
|
||||
text: item.text.substring(0, 30),
|
||||
templateDescription: item.templateDescription,
|
||||
description: item.description,
|
||||
})))
|
||||
}
|
||||
}, [checklist])
|
||||
const requiredTotal = useMemo(() => checklist.filter((item) => (item.required ?? true)).length, [checklist])
|
||||
const requiredDone = useMemo(() => countRequiredDone(checklist), [checklist])
|
||||
const requiredPending = useMemo(() => countRequiredPending(checklist), [checklist])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue