From 3ecbf7068a179736fd631bab108e4f177843249c Mon Sep 17 00:00:00 2001 From: Eliezer Steinbock <3090527+elie222@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:59:03 +0200 Subject: [PATCH] Add radio group match/skip for smart category --- apps/web/app/(app)/automation/RuleForm.tsx | 54 ++++++++++++---------- apps/web/components/ui/radio-group.tsx | 44 ++++++++++++++++++ apps/web/package.json | 1 + apps/web/utils/condition.ts | 2 +- pnpm-lock.yaml | 46 +++++++++++++----- 5 files changed, 110 insertions(+), 37 deletions(-) create mode 100644 apps/web/components/ui/radio-group.tsx diff --git a/apps/web/app/(app)/automation/RuleForm.tsx b/apps/web/app/(app)/automation/RuleForm.tsx index 9d462495..4987ad64 100644 --- a/apps/web/app/(app)/automation/RuleForm.tsx +++ b/apps/web/app/(app)/automation/RuleForm.tsx @@ -28,7 +28,7 @@ import { SectionDescription, TypographyH3, } from "@/components/Typography"; -import { ActionType, CategoryFilterType, RuleType } from "@prisma/client"; +import { ActionType, type CategoryFilterType, RuleType } from "@prisma/client"; import { createRuleAction, updateRuleAction } from "@/utils/actions/rule"; import { type CreateRuleBody, @@ -57,6 +57,7 @@ import { useCategories } from "@/hooks/useCategories"; import { hasVariables } from "@/utils/template"; import { getEmptyConditions } from "@/utils/condition"; import { AlertError } from "@/components/Alert"; +import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; export function RuleForm({ rule }: { rule: CreateRuleBody & { id?: string } }) { const { @@ -311,6 +312,34 @@ export function RuleForm({ rule }: { rule: CreateRuleBody & { id?: string } }) { {watch(`conditions.${index}.type`) === RuleType.CATEGORY && ( <> +
+ + setValue( + `conditions.${index}.categoryFilterType`, + value as CategoryFilterType, + ) + } + className="flex gap-6" + > +
+ +
+
+ +
+
+ + +
+ - -