Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

Fix ActivityLog ordering when a date is missing

fzaninotto5cb5efac1483
diff --git a/src/components/atomic-crm/providers/commons/activity.ts b/src/components/atomic-crm/providers/commons/activity.ts
index 734bb5d8..6655074f 100644
--- a/src/components/atomic-crm/providers/commons/activity.ts
+++ b/src/components/atomic-crm/providers/commons/activity.ts
@@ -46,8 +46,11 @@ export async function getActivityLog(
return (
[...newCompanies, ...newContactsAndNotes, ...newDealsAndNotes]
// sort by date desc
- .sort((a, b) =>
- a.date && b.date ? a.date.localeCompare(b.date) * -1 : 0,
+ .sort(
+ (a, b) =>
+ (a.date || new Date(0).toISOString()).localeCompare(
+ b.date || new Date(0).toISOString(),
+ ) * -1,
)
// limit to 250 activities
.slice(0, 250)