Skip to content

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

refactor: update type for contactId and improve conditional checks in TasksListFilter

Jean-Baptiste Kaiserd2dcbfed676d
diff --git a/src/components/atomic-crm/dashboard/TasksListFilter.tsx b/src/components/atomic-crm/dashboard/TasksListFilter.tsx
index 2ef2a765..219fa046 100644
--- a/src/components/atomic-crm/dashboard/TasksListFilter.tsx
+++ b/src/components/atomic-crm/dashboard/TasksListFilter.tsx
@@ -1,4 +1,5 @@
import {
+ type Identifier,
ListContextProvider,
ResourceContextProvider,
useGetIdentity,
@@ -15,7 +16,7 @@ export const TasksListFilter = ({
}: {
title: string;
filter: any;
- contactId?: string | number;
+ contactId?: Identifier;
}) => {
const { identity } = useGetIdentity();
@@ -30,10 +31,12 @@ export const TasksListFilter = ({
sort: { field: "due_date", order: "ASC" },
filter: {
...filter,
- ...(contactId ? { contact_id: contactId } : { sales_id: identity?.id }),
+ ...(contactId != null
+ ? { contact_id: contactId }
+ : { sales_id: identity?.id }),
},
},
- { enabled: contactId ? true : !!identity },
+ { enabled: contactId != null ? true : !!identity },
);
const listContext = useList({
@@ -52,7 +55,7 @@ export const TasksListFilter = ({
</p>
<ResourceContextProvider value="tasks">
<ListContextProvider value={listContext}>
- <TasksIterator showContact={!contactId} />
+ <TasksIterator showContact={contactId == null} />
</ListContextProvider>
</ResourceContextProvider>
{total > listContext.perPage && (