A full-featured CRM built with React, shadcn/ui, and Supabase.
Fix regression
François Zaninotto6482b173299c
diff --git a/src/components/atomic-crm/tasks/TasksIterator.tsx b/src/components/atomic-crm/tasks/TasksIterator.tsxindex 8c2be068..528a572a 100644--- a/src/components/atomic-crm/tasks/TasksIterator.tsx+++ b/src/components/atomic-crm/tasks/TasksIterator.tsx@@ -1,7 +1,7 @@-import { isAfter } from "date-fns";import { useListContext } from "ra-core";import { Task } from "./Task";+import { isDone, isRecentlyDone } from "./tasksPredicate";export const TasksIterator = ({showContact,@@ -15,9 +15,7 @@ export const TasksIterator = ({// Keep only tasks that are not done or done less than 5 minutes agoconst tasks = data.filter(- (task) =>- !task.done_date ||- isAfter(new Date(task.done_date), new Date(Date.now() - 5 * 60 * 1000)),+ (task) => !isDone(task) || isRecentlyDone(task),);return (diff --git a/src/components/atomic-crm/tasks/TasksListByDueDate.tsx b/src/components/atomic-crm/tasks/TasksListByDueDate.tsxindex 678f9002..ef20201f 100644--- a/src/components/atomic-crm/tasks/TasksListByDueDate.tsx+++ b/src/components/atomic-crm/tasks/TasksListByDueDate.tsx@@ -16,6 +16,7 @@ import {isDueToday,isDueTomorrow,isOverdue,+ isRecentlyDone,} from "./tasksPredicate";export const TasksListByDueDate = ({@@ -47,7 +48,8 @@ export const TasksListByDueDate = ({const showContact = filterByContact == null;const ongoingTasks = useMemo(- () => tasks?.filter((task) => !isDone(task)) || [],+ () =>+ tasks?.filter((task) => !isDone(task) || isRecentlyDone(task)) || [],[tasks],);diff --git a/src/components/atomic-crm/tasks/tasksPredicate.ts b/src/components/atomic-crm/tasks/tasksPredicate.tsindex b7215a24..0b0bd976 100644--- a/src/components/atomic-crm/tasks/tasksPredicate.ts+++ b/src/components/atomic-crm/tasks/tasksPredicate.ts@@ -3,7 +3,7 @@ import { endOfToday } from "date-fns/endOfToday";import { endOfTomorrow } from "date-fns/endOfTomorrow";import { endOfWeek } from "date-fns/endOfWeek";-import { getDay } from "date-fns";+import { getDay, isAfter } from "date-fns";export const isBeforeFriday = () => getDay(new Date()) < 5; // Friday is represented by 5@@ -14,6 +14,12 @@ type Task = {export const isDone = (task: Task) => task.done_date != null;+// A task is recently done if it was marked as done less than 5 minutes ago+// useful to keep recently done tasks in the list to avoid flickering when a task is marked as done while the user is consulting the list of tasks. It gives a chance to the user to see that the task was marked as done and then it will disappear after 5 minutes.+export const isRecentlyDone = (task: Task) =>+ task.done_date != null &&+ isAfter(new Date(task.done_date), new Date(Date.now() - 5 * 60 * 1000));+export const isOverdue = (dateString: string) => {return new Date(dateString) < startOfToday();};