+
+
{label && {label}}
{typeof children === "function" ? children(state) : children}
@@ -206,6 +209,10 @@ const TableHead = ({ className, tooltip, label, children, ...props }: TableHeadP
) : (
))}
+
+ {allowsResizing && (
+
+ )}
)}
diff --git a/src/components/leads/lead-table.tsx b/src/components/leads/lead-table.tsx
index 8da8582..3fc53fa 100644
--- a/src/components/leads/lead-table.tsx
+++ b/src/components/leads/lead-table.tsx
@@ -24,6 +24,7 @@ type LeadTableProps = {
sortDirection: 'asc' | 'desc';
onSort: (field: string) => void;
onViewActivity?: (lead: Lead) => void;
+ visibleColumns?: Set
;
};
type TableRow = {
@@ -53,6 +54,7 @@ export const LeadTable = ({
sortDirection,
onSort,
onViewActivity,
+ visibleColumns,
}: LeadTableProps) => {
const [expandedDupId, setExpandedDupId] = useState(null);
@@ -92,22 +94,26 @@ export const LeadTable = ({
return rows;
}, [leads, expandedDupId]);
- const columns = [
- { id: 'phone', label: 'Phone', allowsSorting: true },
- { id: 'name', label: 'Name', allowsSorting: true },
- { id: 'email', label: 'Email', allowsSorting: false },
- { id: 'campaign', label: 'Campaign', allowsSorting: false },
- { id: 'ad', label: 'Ad', allowsSorting: false },
- { id: 'source', label: 'Source', allowsSorting: true },
- { id: 'firstContactedAt', label: 'First Contact', allowsSorting: true },
- { id: 'lastContactedAt', label: 'Last Contact', allowsSorting: true },
- { id: 'status', label: 'Status', allowsSorting: true },
- { id: 'createdAt', label: 'Age', allowsSorting: true },
- { id: 'spamScore', label: 'Spam', allowsSorting: true },
- { id: 'dups', label: 'Dups', allowsSorting: false },
- { id: 'actions', label: '', allowsSorting: false },
+ const allColumns = [
+ { id: 'phone', label: 'Phone', allowsSorting: true, defaultWidth: 150 },
+ { id: 'name', label: 'Name', allowsSorting: true, defaultWidth: 160 },
+ { id: 'email', label: 'Email', allowsSorting: false, defaultWidth: 180 },
+ { id: 'campaign', label: 'Campaign', allowsSorting: false, defaultWidth: 140 },
+ { id: 'ad', label: 'Ad', allowsSorting: false, defaultWidth: 80 },
+ { id: 'source', label: 'Source', allowsSorting: true, defaultWidth: 100 },
+ { id: 'firstContactedAt', label: 'First Contact', allowsSorting: true, defaultWidth: 130 },
+ { id: 'lastContactedAt', label: 'Last Contact', allowsSorting: true, defaultWidth: 130 },
+ { id: 'status', label: 'Status', allowsSorting: true, defaultWidth: 100 },
+ { id: 'createdAt', label: 'Age', allowsSorting: true, defaultWidth: 80 },
+ { id: 'spamScore', label: 'Spam', allowsSorting: true, defaultWidth: 70 },
+ { id: 'dups', label: 'Dups', allowsSorting: false, defaultWidth: 60 },
+ { id: 'actions', label: '', allowsSorting: false, defaultWidth: 50 },
];
+ const columns = visibleColumns
+ ? allColumns.filter(c => visibleColumns.has(c.id) || c.id === 'actions')
+ : allColumns;
+
return (
)}
@@ -204,6 +213,8 @@ export const LeadTable = ({
const isDup = lead.isDuplicate === true;
const isExpanded = expandedDupId === lead.id;
+ const isCol = (id: string) => !visibleColumns || visibleColumns.has(id);
+
return (
-
+ {isCol('phone') &&
{phone}
-
-
+ }
+ {isCol('name') &&
{name}
-
-
+ }
+ {isCol('email') &&
{email}
-
-
+ }
+ {isCol('campaign') &&
{lead.utmCampaign ? (
{lead.utmCampaign}
@@ -230,8 +241,8 @@ export const LeadTable = ({
) : (
{'\u2014'}
)}
-
-
+ }
+ {isCol('ad') &&
{lead.adId ? (
Ad
@@ -239,50 +250,50 @@ export const LeadTable = ({
) : (
{'\u2014'}
)}
-
-
+ }
+ {isCol('source') &&
{lead.leadSource ? (
) : (
{'\u2014'}
)}
-
-
+ }
+ {isCol('firstContactedAt') &&
{lead.firstContactedAt
? formatShortDate(lead.firstContactedAt)
: '\u2014'}
-
-
+ }
+ {isCol('lastContactedAt') &&
{lead.lastContactedAt
? formatShortDate(lead.lastContactedAt)
: '\u2014'}
-
-
+ }
+ {isCol('status') &&
{lead.leadStatus ? (
) : (
{'\u2014'}
)}
-
-
+ }
+ {isCol('createdAt') &&
{lead.createdAt ? (
) : (
{'\u2014'}
)}
-
-
+ }
+ {isCol('spamScore') &&
{lead.spamScore != null ? (
) : (
0%
)}
-
-
+ }
+ {isCol('dups') &&
{isDup ? (
+ }
-
-
{
aria-label="Search leads"
/>
+