diff --git a/src/components/tickets/ticket-checklist-card.tsx b/src/components/tickets/ticket-checklist-card.tsx index 7dc5cca..72b3b66 100644 --- a/src/components/tickets/ticket-checklist-card.tsx +++ b/src/components/tickets/ticket-checklist-card.tsx @@ -15,6 +15,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/com import { Checkbox } from "@/components/ui/checkbox" import { Input } from "@/components/ui/input" import { Progress } from "@/components/ui/progress" +import { ScrollArea } from "@/components/ui/scroll-area" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" type ChecklistTemplateRow = { @@ -52,7 +53,8 @@ export function TicketChecklistCard({ const requiredPending = useMemo(() => countRequiredPending(checklist), [checklist]) const allDone = useMemo(() => countAllDone(checklist), [checklist]) - const progress = requiredTotal > 0 ? Math.round((requiredDone / requiredTotal) * 100) : 100 + const totalItems = checklist.length + const progress = totalItems > 0 ? Math.round((allDone / totalItems) * 100) : 0 const addChecklistItem = useMutation(api.tickets.addChecklistItem) const updateChecklistItemText = useMutation(api.tickets.updateChecklistItemText) @@ -92,6 +94,7 @@ export function TicketChecklistCard({ const [selectedTemplateId, setSelectedTemplateId] = useState("") const [applyingTemplate, setApplyingTemplate] = useState(false) const [completingAll, setCompletingAll] = useState(false) + const [onlyPending, setOnlyPending] = useState(false) const handleAdd = async () => { if (!actorId || !canEdit || isResolved) return @@ -178,6 +181,10 @@ export function TicketChecklistCard({ } const canComplete = checklist.length > 0 && requiredPending > 0 && canEdit && !isResolved + const visibleChecklist = useMemo(() => { + return onlyPending ? checklist.filter((item) => !item.done) : checklist + }, [checklist, onlyPending]) + const isLargeChecklist = totalItems > 12 return ( @@ -188,14 +195,31 @@ export function TicketChecklistCard({ Checklist - {requiredTotal > 0 - ? `${requiredDone}/${requiredTotal} itens obrigatórios concluídos` - : checklist.length > 0 - ? `${allDone}/${checklist.length} itens concluídos` - : "Nenhum item cadastrado."} + {totalItems > 0 ? ( + <> + {allDone}/{totalItems} itens concluídos + {requiredTotal > 0 ? ` • ${requiredDone}/${requiredTotal} obrigatórios` : ""} + + ) : ( + "Nenhum item cadastrado." + )}
+ {allDone > 0 && !isResolved ? ( + + ) : null} {canEdit && !isResolved ? ( + +
+ ) : ( +

{ + if (!canEdit || isResolved) return + setEditingId(item.id) + setEditingText(item.text) + }} + > + {item.text} +

+ )} +
+ {required ? ( + + Obrigatório + + ) : ( + + Opcional + + )} + {templateLabel ? ( + + Template: {templateLabel} + + ) : null} +
+ + + + {canEdit && !isResolved ? ( +
+
- ) : ( -

{ - if (!canEdit || isResolved) return - setEditingId(item.id) - setEditingText(item.text) - }} - > - {item.text} -

- )} -
- {required ? ( - - Obrigatório - - ) : ( - - Opcional - - )} - {templateLabel ? ( - - Template: {templateLabel} - - ) : null} -
+ ) : null} - - - {canEdit && !isResolved ? ( -
- - -
- ) : null} - - ) - })} - + ) + }) + )} + + )} {canEdit && !isResolved ? (