Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #423 from beabee-communityrm/fix/contact-me-mapping
Browse files Browse the repository at this point in the history
fix: failing with no contact if not using "me" mapping
  • Loading branch information
wpf500 authored May 15, 2024
2 parents b35b3b3 + 84f393a commit fed2f34
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/api/utils/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,19 @@ function prepareRule(
}

case "contact":
if (!contact) {
throw new Error("No contact provided to map contact field type");
}
// Map "me" to contact id
return [
simpleField,
rule.value.map((v) => (v === "me" ? contact.id : v))
rule.value.map((v) => {
// Map "me" to contact id
if (v === "me") {
if (!contact) {
throw new Error("No contact provided to map contact field type");
}
return contact.id;
} else {
return v;
}
})
];

default:
Expand Down

0 comments on commit fed2f34

Please sign in to comment.