From d98da9a1ea22f0cc5cbbbfb9874b30e9677eb2a8 Mon Sep 17 00:00:00 2001 From: saridsa2 Date: Mon, 16 Mar 2026 16:15:08 +0530 Subject: [PATCH] =?UTF-8?q?fix:=20wire=20role-based=20views=20=E2=80=94=20?= =?UTF-8?q?sidebar=20auth,=20user=20display,=20table=20tabs,=20card=20acti?= =?UTF-8?q?ons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Sidebar: use useAuth() for isAdmin and pass auth user to NavAccountCard - NavAccountCard: fix bug where items prop was ignored (used placeholderAccounts) - TopBar: replace hardcoded "SM" initials with user.initials from auth - All Leads: add "My Leads" tab filtering by assignedAgent matching user - Lead Card: add role-aware action buttons (Call/Disposition for assigned leads) - Lead Workspace: pass onLogCall/onUpdateStatus handlers to LeadCard Co-Authored-By: Claude Opus 4.6 (1M context) --- .../base-components/nav-account-card.tsx | 2 +- src/components/layout/sidebar.tsx | 12 ++++++++++- src/components/layout/top-bar.tsx | 5 ++++- src/components/leads/lead-card.tsx | 14 ++++++++++++- src/pages/all-leads.tsx | 20 ++++++++++++++++--- src/pages/lead-workspace.tsx | 10 ++++++++++ 6 files changed, 56 insertions(+), 7 deletions(-) diff --git a/src/components/application/app-navigation/base-components/nav-account-card.tsx b/src/components/application/app-navigation/base-components/nav-account-card.tsx index 8da9970..67836a7 100644 --- a/src/components/application/app-navigation/base-components/nav-account-card.tsx +++ b/src/components/application/app-navigation/base-components/nav-account-card.tsx @@ -167,7 +167,7 @@ export const NavAccountCard = ({ const triggerRef = useRef(null); const isDesktop = useBreakpoint("lg"); - const selectedAccount = placeholderAccounts.find((account) => account.id === selectedAccountId); + const selectedAccount = items.find((account) => account.id === selectedAccountId); if (!selectedAccount) { console.warn(`Account with ID ${selectedAccountId} not found in `); diff --git a/src/components/layout/sidebar.tsx b/src/components/layout/sidebar.tsx index 177a5ff..8f8e0df 100644 --- a/src/components/layout/sidebar.tsx +++ b/src/components/layout/sidebar.tsx @@ -110,7 +110,17 @@ export const Sidebar = ({ activeUrl = "/" }: SidebarProps) => { {/* Account card */}
- +
); diff --git a/src/components/layout/top-bar.tsx b/src/components/layout/top-bar.tsx index c833e36..6f5a6b5 100644 --- a/src/components/layout/top-bar.tsx +++ b/src/components/layout/top-bar.tsx @@ -1,6 +1,7 @@ import { SearchLg } from "@untitledui/icons"; import { Avatar } from "@/components/base/avatar/avatar"; import { Input } from "@/components/base/input/input"; +import { useAuth } from "@/providers/auth-provider"; interface TopBarProps { title: string; @@ -8,6 +9,8 @@ interface TopBarProps { } export const TopBar = ({ title, subtitle }: TopBarProps) => { + const { user } = useAuth(); + return (
@@ -23,7 +26,7 @@ export const TopBar = ({ title, subtitle }: TopBarProps) => { aria-label="Search" />
- +
); diff --git a/src/components/leads/lead-card.tsx b/src/components/leads/lead-card.tsx index 117676e..60f57f2 100644 --- a/src/components/leads/lead-card.tsx +++ b/src/components/leads/lead-card.tsx @@ -14,6 +14,8 @@ interface LeadCardProps { onMessage: (lead: Lead) => void; onMarkSpam: (lead: Lead) => void; onMerge: (lead: Lead) => void; + onLogCall?: (lead: Lead) => void; + onUpdateStatus?: (lead: Lead) => void; } const sourceLabelMap: Record = { @@ -29,7 +31,7 @@ const sourceLabelMap: Record = { OTHER: 'Other', }; -export const LeadCard = ({ lead, onAssign, onMessage, onMarkSpam, onMerge }: LeadCardProps) => { +export const LeadCard = ({ lead, onAssign, onMessage, onMarkSpam, onMerge, onLogCall, onUpdateStatus }: LeadCardProps) => { const firstName = lead.contactName?.firstName ?? ''; const lastName = lead.contactName?.lastName ?? ''; const name = `${firstName} ${lastName}`.trim() || 'Unknown'; @@ -38,6 +40,7 @@ export const LeadCard = ({ lead, onAssign, onMessage, onMarkSpam, onMerge }: Lea const sourceLabel = lead.leadSource ? sourceLabelMap[lead.leadSource] ?? lead.leadSource : ''; const isSpam = (lead.spamScore ?? 0) >= 60; const isDuplicate = lead.isDuplicate === true; + const isAssigned = lead.assignedAgent !== null && lead.leadStatus !== 'NEW'; return (
+ ) : isAssigned ? ( + <> + + + ) : ( <>