fix(checklist): corrige acentuação e adiciona modal de exclusão

- Corrige acentuações: Opções, Não, Descrição, Obrigatório, máx
- Adiciona modal de confirmação para exclusão de itens do checklist
- Remove uso de confirm() nativo

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
rever-tecnologia 2025-12-15 16:35:58 -03:00
parent f1833be1ea
commit 10078c7aa7
6 changed files with 82 additions and 27 deletions

View file

@ -67,11 +67,11 @@ function normalizeTemplateItems(items: DraftItem[]) {
}
const invalid = normalized.find((item) => item.text.length > 240)
if (invalid) {
throw new Error("Item do checklist muito longo (max. 240 caracteres).")
throw new Error("Item do checklist muito longo (máx. 240 caracteres).")
}
const invalidQuestion = normalized.find((item) => item.type === "question" && item.options.length < 2)
if (invalidQuestion) {
throw new Error(`A pergunta "${invalidQuestion.text}" precisa ter pelo menos 2 opcoes.`)
throw new Error(`A pergunta "${invalidQuestion.text}" precisa ter pelo menos 2 opções.`)
}
return normalized
}
@ -228,7 +228,7 @@ function TemplateEditorDialog({
<div className="flex items-center justify-between gap-2">
<div className="space-y-0.5">
<p className="text-sm font-semibold text-neutral-900">Itens</p>
<p className="text-xs text-muted-foreground">Defina o que precisa ser feito. Itens obrigatorios bloqueiam o encerramento.</p>
<p className="text-xs text-muted-foreground">Defina o que precisa ser feito. Itens obrigatórios bloqueiam o encerramento.</p>
</div>
<Button
type="button"
@ -260,7 +260,7 @@ function TemplateEditorDialog({
setItems((prev) => prev.map((row) => (row.id === item.id ? { ...row, required: Boolean(checked) } : row)))
}
/>
Obrigatorio
Obrigatório
</label>
<label className="flex items-center gap-2 text-sm text-neutral-700">
<Checkbox
@ -272,7 +272,7 @@ function TemplateEditorDialog({
? {
...row,
type: checked ? "question" : "checkbox",
options: checked ? (row.options.length > 0 ? row.options : ["Sim", "Nao"]) : [],
options: checked ? (row.options.length > 0 ? row.options : ["Sim", "Não"]) : [],
}
: row
)
@ -299,14 +299,14 @@ function TemplateEditorDialog({
onChange={(e) =>
setItems((prev) => prev.map((row) => (row.id === item.id ? { ...row, description: e.target.value } : row)))
}
placeholder="Descricao (opcional)"
placeholder="Descrição (opcional)"
className="h-8 text-xs"
/>
{item.type === "question" && (
<div className="space-y-2 rounded-lg border border-dashed border-cyan-200 bg-cyan-50/50 p-2">
<div className="flex items-center justify-between gap-2">
<p className="text-xs font-medium text-cyan-700">Opcoes de resposta</p>
<p className="text-xs font-medium text-cyan-700">Opções de resposta</p>
<Button
type="button"
variant="ghost"

View file

@ -13,6 +13,7 @@ import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { Checkbox } from "@/components/ui/checkbox"
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog"
import { Input } from "@/components/ui/input"
import { Progress } from "@/components/ui/progress"
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
@ -98,6 +99,8 @@ export function TicketChecklistCard({
const [applyingTemplate, setApplyingTemplate] = useState(false)
const [completingAll, setCompletingAll] = useState(false)
const [onlyPending, setOnlyPending] = useState(false)
const [deleteTarget, setDeleteTarget] = useState<TicketChecklistItem | null>(null)
const [deleting, setDeleting] = useState(false)
const handleAdd = async () => {
if (!actorId || !canEdit || isResolved) return
@ -470,21 +473,7 @@ export function TicketChecklistCard({
size="icon"
className="h-9 w-9 text-slate-500 hover:bg-red-50 hover:text-red-700"
title="Remover"
onClick={async () => {
if (!actorId) return
const ok = confirm("Remover este item do checklist?")
if (!ok) return
try {
await removeChecklistItem({
ticketId: ticket.id as Id<"tickets">,
actorId,
itemId: item.id,
})
toast.success("Item removido.")
} catch (error) {
toast.error(error instanceof Error ? error.message : "Falha ao remover item.")
}
}}
onClick={() => setDeleteTarget(item)}
>
<Trash2 className="size-4" />
</Button>
@ -525,6 +514,46 @@ export function TicketChecklistCard({
</div>
) : null}
</CardContent>
<Dialog open={Boolean(deleteTarget)} onOpenChange={(open) => !open && setDeleteTarget(null)}>
<DialogContent className="max-w-md">
<DialogHeader>
<DialogTitle>Remover item do checklist</DialogTitle>
<DialogDescription>
Tem certeza que deseja remover o item <strong>&quot;{deleteTarget?.text}&quot;</strong> do checklist?
</DialogDescription>
</DialogHeader>
<DialogFooter className="gap-3">
<Button type="button" variant="outline" onClick={() => setDeleteTarget(null)} disabled={deleting}>
Cancelar
</Button>
<Button
type="button"
variant="destructive"
disabled={deleting}
onClick={async () => {
if (!actorId || !deleteTarget) return
setDeleting(true)
try {
await removeChecklistItem({
ticketId: ticket.id as Id<"tickets">,
actorId,
itemId: deleteTarget.id,
})
toast.success("Item removido.")
setDeleteTarget(null)
} catch (error) {
toast.error(error instanceof Error ? error.message : "Falha ao remover item.")
} finally {
setDeleting(false)
}
}}
>
{deleting ? "Removendo..." : "Remover"}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</Card>
)
}