Skip to content

Commit f0404e4

Browse files
Skip duplicate rule warning when editing the priority rule
When editing a merchant rule that was created before another rule with the same merchant, the duplicate warning is no longer shown since the rule being edited already has priority. Co-authored-by: Carlos Martins <luacmartins@users.noreply.github.com>
1 parent ad4f6c9 commit f0404e4

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/pages/workspace/rules/MerchantRules/MerchantRulePageBase.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,17 @@ function MerchantRulePageBase({policyID, ruleID, titleKey, testID}: MerchantRule
210210
const existingMerchant = rule.filters.right.toLowerCase();
211211
const existingMatchType = rule.filters.operator ?? defaultMatchType;
212212

213-
return existingMerchant === normalizedMerchant && existingMatchType === currentMatchType;
213+
if (existingMerchant !== normalizedMerchant || existingMatchType !== currentMatchType) {
214+
return false;
215+
}
216+
217+
// When editing, if the rule being edited was created before the duplicate,
218+
// the edited rule already has priority — no warning needed
219+
if (isEditing && existingRule?.created && rule.created && existingRule.created <= rule.created) {
220+
return false;
221+
}
222+
223+
return true;
214224
});
215225
};
216226

0 commit comments

Comments
 (0)