Skip to content

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

Fix date formatting

fzaninottobaccb67d8152
diff --git a/src/components/atomic-crm/misc/RelativeDate.tsx b/src/components/atomic-crm/misc/RelativeDate.tsx
index 7ef5452e..c3b9eb15 100644
--- a/src/components/atomic-crm/misc/RelativeDate.tsx
+++ b/src/components/atomic-crm/misc/RelativeDate.tsx
@@ -1,5 +1,12 @@
-import { formatRelative } from "date-fns";
+import { differenceInDays, formatRelative } from "date-fns";
export function RelativeDate({ date }: { date: string }) {
- return formatRelative(new Date(date), new Date());
+ const dateObj = new Date(date);
+ const now = new Date();
+
+ if (differenceInDays(now, dateObj) > 6) {
+ return dateObj.toLocaleDateString();
+ }
+
+ return formatRelative(dateObj, now);
}