diff --git a/src/components/automations/automation-editor-dialog.tsx b/src/components/automations/automation-editor-dialog.tsx index e7d9f6e..063e21a 100644 --- a/src/components/automations/automation-editor-dialog.tsx +++ b/src/components/automations/automation-editor-dialog.tsx @@ -15,7 +15,7 @@ import { Checkbox } from "@/components/ui/checkbox" import { DialogClose, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" -import { Select, SelectContent, SelectEmptyState, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" +import { Select, SelectContent, SelectEmptyState, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/components/ui/select" import { Separator } from "@/components/ui/separator" import { Switch } from "@/components/ui/switch" import { Textarea } from "@/components/ui/textarea" @@ -295,14 +295,6 @@ export function AutomationEditorDialog({ setSaving(false) }, [initialState]) - const subcategoryOptions = useMemo(() => { - const list = - categories?.flatMap((cat) => - cat.secondary.map((sub) => ({ id: sub.id, name: sub.name, categoryId: sub.categoryId })) - ) ?? [] - return list.sort((a, b) => a.name.localeCompare(b.name, "pt-BR")) - }, [categories]) - const handleAddCondition = () => { setConditions((prev) => [ ...prev, @@ -767,19 +759,26 @@ export function AutomationEditorDialog({ - - {subcategoryOptions.length === 0 ? ( + + {(categories ?? []).length === 0 ? ( ) : ( - subcategoryOptions.map((sub) => ( - - {sub.name} - - )) + (categories ?? []).map((cat) => + cat.secondary.length > 0 ? ( + + {cat.name} + {cat.secondary.map((sub) => ( + + {sub.name} + + ))} + + ) : null + ) )}