mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage
synced 2026-04-11 18:28:15 +00:00
fix: wire role-based views — sidebar auth, user display, table tabs, card actions
- 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) <noreply@anthropic.com>
This commit is contained in:
@@ -9,9 +9,10 @@ import { LeadTable } from '@/components/leads/lead-table';
|
||||
import { BulkActionBar } from '@/components/leads/bulk-action-bar';
|
||||
import { FilterPills } from '@/components/leads/filter-pills';
|
||||
import { useLeads } from '@/hooks/use-leads';
|
||||
import { useAuth } from '@/providers/auth-provider';
|
||||
import type { LeadSource, LeadStatus } from '@/types/entities';
|
||||
|
||||
type TabKey = 'new' | 'all';
|
||||
type TabKey = 'new' | 'my-leads' | 'all';
|
||||
|
||||
type ActiveFilter = {
|
||||
key: string;
|
||||
@@ -22,6 +23,7 @@ type ActiveFilter = {
|
||||
const PAGE_SIZE = 25;
|
||||
|
||||
export const AllLeadsPage = () => {
|
||||
const { user } = useAuth();
|
||||
const [tab, setTab] = useState<TabKey>('new');
|
||||
const [selectedIds, setSelectedIds] = useState<string[]>([]);
|
||||
const [sortField, setSortField] = useState('createdAt');
|
||||
@@ -31,6 +33,7 @@ export const AllLeadsPage = () => {
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
|
||||
const statusFilter: LeadStatus | undefined = tab === 'new' ? 'NEW' : undefined;
|
||||
const myLeadsOnly = tab === 'my-leads';
|
||||
|
||||
const { leads: filteredLeads, total } = useLeads({
|
||||
source: sourceFilter ?? undefined,
|
||||
@@ -93,9 +96,17 @@ export const AllLeadsPage = () => {
|
||||
return sorted;
|
||||
}, [filteredLeads, sortField, sortDirection]);
|
||||
|
||||
// Apply "My Leads" filter when on that tab
|
||||
const displayLeads = useMemo(() => {
|
||||
if (myLeadsOnly) {
|
||||
return sortedLeads.filter((l) => l.assignedAgent === user.name);
|
||||
}
|
||||
return sortedLeads;
|
||||
}, [sortedLeads, myLeadsOnly, user.name]);
|
||||
|
||||
// Client-side pagination
|
||||
const totalPages = Math.max(1, Math.ceil(sortedLeads.length / PAGE_SIZE));
|
||||
const pagedLeads = sortedLeads.slice((currentPage - 1) * PAGE_SIZE, currentPage * PAGE_SIZE);
|
||||
const totalPages = Math.max(1, Math.ceil(displayLeads.length / PAGE_SIZE));
|
||||
const pagedLeads = displayLeads.slice((currentPage - 1) * PAGE_SIZE, currentPage * PAGE_SIZE);
|
||||
|
||||
const handleSort = (field: string) => {
|
||||
if (field === sortField) {
|
||||
@@ -139,8 +150,11 @@ export const AllLeadsPage = () => {
|
||||
setCurrentPage(1);
|
||||
};
|
||||
|
||||
const myLeadsCount = sortedLeads.filter((l) => l.assignedAgent === user.name).length;
|
||||
|
||||
const tabItems = [
|
||||
{ id: 'new', label: 'New', badge: tab === 'new' ? total : undefined },
|
||||
{ id: 'my-leads', label: 'My Leads', badge: tab === 'my-leads' ? myLeadsCount : undefined },
|
||||
{ id: 'all', label: 'All Leads', badge: tab === 'all' ? total : undefined },
|
||||
];
|
||||
|
||||
|
||||
@@ -37,6 +37,14 @@ export const LeadWorkspacePage = () => {
|
||||
// placeholder
|
||||
};
|
||||
|
||||
const handleLogCall = () => {
|
||||
// placeholder
|
||||
};
|
||||
|
||||
const handleUpdateStatus = () => {
|
||||
// placeholder
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-1 flex-col">
|
||||
<TopBar title="Lead Workspace" subtitle="Ramaiah Memorial Hospital · Last 24 hours" />
|
||||
@@ -69,6 +77,8 @@ export const LeadWorkspacePage = () => {
|
||||
onMessage={handleMessage}
|
||||
onMarkSpam={handleMarkSpam}
|
||||
onMerge={handleMerge}
|
||||
onLogCall={handleLogCall}
|
||||
onUpdateStatus={handleUpdateStatus}
|
||||
/>
|
||||
))}
|
||||
{displayLeads.length === 0 && (
|
||||
|
||||
Reference in New Issue
Block a user