From db73e87cdc44c33ad425c70d7ac4c64560bf32b1 Mon Sep 17 00:00:00 2001 From: rever-tecnologia Date: Tue, 16 Dec 2025 10:14:34 -0300 Subject: [PATCH] debug(checklist): adiciona logs para investigar templateDescription MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- convex/checklistTemplates.ts | 49 +++++++++++++++++++ .../tickets/ticket-checklist-card.tsx | 14 +++++- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/convex/checklistTemplates.ts b/convex/checklistTemplates.ts index 09301b8..c9329b5 100644 --- a/convex/checklistTemplates.ts +++ b/convex/checklistTemplates.ts @@ -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 } + }, +}) diff --git a/src/components/tickets/ticket-checklist-card.tsx b/src/components/tickets/ticket-checklist-card.tsx index 4c5ddab..8b078d8 100644 --- a/src/components/tickets/ticket-checklist-card.tsx +++ b/src/components/tickets/ticket-checklist-card.tsx @@ -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])