Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(crm): show retired stage names in list cells (#6041)

teoe5ab32452faf
diff --git a/apps/web/src/features/entity/extractors-property/property-helpers.test.ts b/apps/web/src/features/entity/extractors-property/property-helpers.test.ts
new file mode 100644
index 0000000000..28d8b682d8
--- /dev/null
+++ b/apps/web/src/features/entity/extractors-property/property-helpers.test.ts
@@ -0,0 +1,39 @@
+// @vitest-environment jsdom
+import { PROPERTY_OPTION_IDS, SYSTEM_PROPERTY_IDS } from '@property/constants';
+import { formatPropertyValue } from '@property/utils/formatting';
+import type { SoupProperty } from '@service-storage/generated/schemas/soupProperty';
+import { describe, expect, it } from 'vitest';
+import { soupPropertyToProperty } from './property-helpers';
+
+const EPOCH_ZERO = new Date(0).toISOString();
+
+const stageSoupProperty = (optionId: string): SoupProperty => ({
+ id: SYSTEM_PROPERTY_IDS.STAGE,
+ definition: {
+ id: SYSTEM_PROPERTY_IDS.STAGE,
+ display_name: 'Stage',
+ data_type: 'SELECT_STRING',
+ is_metadata: false,
+ is_multi_select: false,
+ is_system: true,
+ owner: { scope: 'system' },
+ created_at: EPOCH_ZERO,
+ updated_at: EPOCH_ZERO,
+ },
+ value: { type: 'SelectOption', value: [optionId] },
+});
+
+describe('soupPropertyToProperty stage labels', () => {
+ it.each([
+ ['Lead', PROPERTY_OPTION_IDS.STAGE.LEAD],
+ ['Demo', PROPERTY_OPTION_IDS.STAGE.DEMO],
+ ['Customer', PROPERTY_OPTION_IDS.STAGE.CUSTOMER],
+ ['Churned', PROPERTY_OPTION_IDS.STAGE.CHURNED],
+ ['Qualified', PROPERTY_OPTION_IDS.STAGE.QUALIFIED],
+ ['Trial', PROPERTY_OPTION_IDS.STAGE.TRIAL],
+ ['Negotiation', PROPERTY_OPTION_IDS.STAGE.NEGOTIATION],
+ ] as const)('formats %s from its option id', (label, optionId) => {
+ const property = soupPropertyToProperty(stageSoupProperty(optionId));
+ expect(formatPropertyValue(property, optionId)).toBe(label);
+ });
+});
diff --git a/apps/web/src/features/property/utils/formatting.ts b/apps/web/src/features/property/utils/formatting.ts
index 708fc82094..35fb2c1c2f 100644
--- a/apps/web/src/features/property/utils/formatting.ts
+++ b/apps/web/src/features/property/utils/formatting.ts
@@ -1,3 +1,4 @@
+import { getPropertyOptionLabel } from '@entity/utils/task-properties';
import { NUMBER_DECIMAL_PLACES } from '../constants';
import type { Property, PropertyOptionValue } from '../types';
@@ -107,12 +108,9 @@ const formatOptionValueById = (
optionId: string,
options: Array<{ id: string; value: PropertyOptionValue }> | undefined
): string => {
- if (!options) return optionId;
-
- const option = options.find((opt) => opt.id === optionId);
- if (!option) return optionId; // Fallback to showing the ID if option not found
-
- return formatOptionValue(option);
+ const option = options?.find((opt) => opt.id === optionId);
+ if (option) return formatOptionValue(option);
+ return getPropertyOptionLabel(optionId) ?? optionId;
};
/**