From 51c9cab79c2dabd95bd198545863352291f688aa Mon Sep 17 00:00:00 2001 From: esdrasrenan Date: Sat, 13 Dec 2025 21:14:51 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20cria=C3=A7=C3=A3o=20de=20template=20de?= =?UTF-8?q?=20checklist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Permite isArchived na mutation checklistTemplates.create\n- Troca Select por SearchableCombobox no campo Empresa --- convex/checklistTemplates.ts | 6 ++-- .../settings/checklist-templates-manager.tsx | 33 +++++++++++-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/convex/checklistTemplates.ts b/convex/checklistTemplates.ts index 7b2f728..c9c410a 100644 --- a/convex/checklistTemplates.ts +++ b/convex/checklistTemplates.ts @@ -167,8 +167,9 @@ export const create = mutation({ required: v.optional(v.boolean()), }), ), + isArchived: v.optional(v.boolean()), }, - handler: async (ctx, { tenantId, actorId, name, description, companyId, items }) => { + handler: async (ctx, { tenantId, actorId, name, description, companyId, items, isArchived }) => { await requireAdmin(ctx, actorId, tenantId) const normalizedName = normalizeTemplateName(name) @@ -185,6 +186,7 @@ export const create = mutation({ const normalizedItems = normalizeTemplateItems(items, {}) const normalizedDescription = normalizeTemplateDescription(description) + const archivedFlag = typeof isArchived === "boolean" ? isArchived : false const now = Date.now() return ctx.db.insert("ticketChecklistTemplates", { @@ -193,7 +195,7 @@ export const create = mutation({ description: normalizedDescription ?? undefined, companyId: companyId ?? undefined, items: normalizedItems, - isArchived: false, + isArchived: archivedFlag, createdAt: now, updatedAt: now, createdBy: actorId, diff --git a/src/components/settings/checklist-templates-manager.tsx b/src/components/settings/checklist-templates-manager.tsx index 70d2f0a..48280db 100644 --- a/src/components/settings/checklist-templates-manager.tsx +++ b/src/components/settings/checklist-templates-manager.tsx @@ -16,7 +16,7 @@ import { Checkbox } from "@/components/ui/checkbox" import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" +import { SearchableCombobox, type SearchableComboboxOption } from "@/components/ui/searchable-combobox" import { Switch } from "@/components/ui/switch" import { Textarea } from "@/components/ui/textarea" @@ -76,6 +76,15 @@ function TemplateEditorDialog({ const [items, setItems] = useState([{ id: crypto.randomUUID(), text: "", required: true }]) const [archived, setArchived] = useState(false) + const companyComboboxOptions = useMemo(() => { + const sortedCompanies = [...companies].sort((a, b) => a.name.localeCompare(b.name, "pt-BR")) + + return [ + { value: NO_COMPANY_VALUE, label: "Global (todas)" }, + ...sortedCompanies.map((company) => ({ value: String(company.id), label: company.name })), + ] + }, [companies]) + useEffect(() => { if (!open) return setName(template?.name ?? "") @@ -148,19 +157,15 @@ function TemplateEditorDialog({
- + setCompanyValue(nextValue ?? NO_COMPANY_VALUE)} + options={companyComboboxOptions} + placeholder="Selecionar empresa" + searchPlaceholder="Buscar empresa..." + triggerClassName="h-9 rounded-lg border border-slate-300 bg-white px-3 py-2 text-sm font-medium text-neutral-800 shadow-sm" + contentClassName="rounded-xl" + />