fix: update segment filter logic to retain value and unit, enhance activity name mapping

This commit is contained in:
Dries Augustyns
2026-05-04 19:35:29 +02:00
parent a3cc62213f
commit a126563542
2 changed files with 8 additions and 3 deletions
+6 -1
View File
@@ -1301,13 +1301,18 @@ export class SegmentService {
value: unknown,
unit?: 'days' | 'hours' | 'minutes',
): Prisma.ContactWhereInput {
// Map activity names to Email model fields
// Map activity names to Email model fields (accept both verb and past-tense forms)
const fieldMap: Record<string, string> = {
open: 'openedAt',
opened: 'openedAt',
click: 'clickedAt',
clicked: 'clickedAt',
bounce: 'bouncedAt',
bounced: 'bouncedAt',
complaint: 'complainedAt',
complained: 'complainedAt',
sent: 'sentAt',
delivery: 'deliveredAt',
delivered: 'deliveredAt',
};
@@ -273,8 +273,8 @@ const FilterRow = memo(function FilterRow({filter, onChange, onRemove, available
// Determine default operator and value based on new field type
let newOperator = filter.operator;
let newValue: string | number | boolean | undefined = undefined;
let newUnit: 'days' | 'hours' | 'minutes' | undefined = undefined;
let newValue: string | number | boolean | undefined = filter.value;
let newUnit: 'days' | 'hours' | 'minutes' | undefined = filter.unit;
if (isNewSegment && !currentOperatorIsSegment) {
// Switching to segment field