From aa91f1ac4c4951c285634a6cadc006571362f5aa Mon Sep 17 00:00:00 2001 From: Ichsan Kurniawan Date: Thu, 8 Oct 2026 13:19:41 +0700 Subject: [PATCH] Add internal memo metrics to client views Default client detail view now opens in list mode. The client model and listing UI now include `total_im`, showing internal memo counts across grid and list cards, and the profile summary adds the new metric. This also improves the empty-state description behavior and keeps the client summary stats consistent across views. --- .../(main)/ClientDetailComponent.tsx | 2 +- .../[client_id]/(main)/ClientProfileCard.tsx | 3 +- .../task/component/client/ClientGrid.tsx | 64 ++++++++----------- .../task/component/client/ClientList.tsx | 23 +++---- app/(dashboard)/task/types.ts | 1 + 5 files changed, 39 insertions(+), 54 deletions(-) diff --git a/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientDetailComponent.tsx b/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientDetailComponent.tsx index a409bee..6aca41f 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientDetailComponent.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientDetailComponent.tsx @@ -25,7 +25,7 @@ export default function ClientDetailComponent({ clientId, assignmentLists }: Pro const searchParams = useSearchParams(); const urlLayout = searchParams?.get('layout') as 'grid' | 'list' | null; - const [viewMode] = useState<'grid' | 'list'>(urlLayout || 'grid'); + const [viewMode] = useState<'grid' | 'list'>(urlLayout || 'list'); const [action, setAction] = useState<'MANAGE_EMPLOYEE' | 'UPDATE_STATUS' | 'DELETE' | undefined>(); const [selectedData, setSelectedData] = useState(); diff --git a/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientProfileCard.tsx b/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientProfileCard.tsx index 4194790..0ec65c6 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientProfileCard.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientProfileCard.tsx @@ -78,9 +78,10 @@ export default function ClientProfileCard({ client, clientId }: Props) { -
+
+
diff --git a/app/(dashboard)/task/component/client/ClientGrid.tsx b/app/(dashboard)/task/component/client/ClientGrid.tsx index f1b6555..a788dfa 100644 --- a/app/(dashboard)/task/component/client/ClientGrid.tsx +++ b/app/(dashboard)/task/component/client/ClientGrid.tsx @@ -3,7 +3,7 @@ import { motion } from 'motion/react'; import { Card900, CardContent } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; -import { ExternalLink, MoreHorizontal } from 'lucide-react'; +import { ExternalLink, MoreHorizontal, FolderGit2, FileText, ScrollText } from 'lucide-react'; import Link from 'next/link'; import { LazyImage } from '@/components/ui/lazy-image'; import { @@ -29,10 +29,9 @@ export default function ClientGrid({ clients, onEdit, onDelete }: ClientGridProp return (
{clients.map((client, i) => { - const imCount = 0; - const projectCount = client.total_project; - const woCount = client.total_work_order; - const userCount = client.total_user_assigned; + const imCount = client.total_im || 0; + const projectCount = client.total_project || 0; + const woCount = client.total_work_order || 0; const isActive = client.status_name.toLowerCase() === 'active'; return ( @@ -111,41 +110,32 @@ export default function ClientGrid({ clients, onEdit, onDelete }: ClientGridProp
-

- {projectCount === 0 && imCount === 0 && woCount === 0 ? ( - "No active projects, internal memos, or work orders recorded for this client yet." +

+ {typeof client.description === 'string' && client.description.trim().length > 0 ? ( + client.description ) : ( - <> - {(projectCount! > 0 || imCount > 0) && ( - <> - Currently managing a portfolio of{" "} - {projectCount! > 0 && ( - - {projectCount} project{projectCount! > 1 ? 's' : ''} - - )} - {projectCount! > 0 && imCount > 0 && " and "} - {imCount > 0 && ( - - {imCount} internal memo{imCount > 1 ? 's' : ''} - - )} - .{" "} - - )} - {woCount! > 0 && ( - <> - A dedicated team of{" "} - {userCount} experts is handling{" "} - - {woCount} work order{woCount! > 1 ? 's' : ''} - {" "} - to ensure successful delivery for {client.name}. - - )} - + No description provided. )}

+ + {/* Metrics Summary Bar */} +
+
+ + {projectCount} + Projects +
+
+ + {woCount} + Work Orders +
+
+ + {imCount} + Internal Memos +
+
diff --git a/app/(dashboard)/task/component/client/ClientList.tsx b/app/(dashboard)/task/component/client/ClientList.tsx index 379b64f..0949b5c 100644 --- a/app/(dashboard)/task/component/client/ClientList.tsx +++ b/app/(dashboard)/task/component/client/ClientList.tsx @@ -3,7 +3,7 @@ import { motion } from 'motion/react'; import { Card900, CardContent } from '@/components/ui/card'; import Link from 'next/link'; import { LazyImage } from '@/components/ui/lazy-image'; -import { ExternalLink, MoreHorizontal, FolderGit2, FileText, Users } from 'lucide-react'; +import { ExternalLink, MoreHorizontal, FolderGit2, FileText, Users, ScrollText } from 'lucide-react'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; @@ -28,7 +28,7 @@ export default function ClientList({ clients, onEdit, onDelete }: ClientListProp return (
{clients.map((client, index) => { - const imCount = 0; + const imCount = client.total_im || 0; const projectCount = client.total_project || 0; const woCount = client.total_work_order || 0; const userCount = client.total_user_assigned || client.users?.length || 0; @@ -159,7 +159,7 @@ export default function ClientList({ clients, onEdit, onDelete }: ClientListProp

- {/* Metrics Bar & Status Breakdown */} + {/* Metrics Bar */}
@@ -171,23 +171,16 @@ export default function ClientList({ clients, onEdit, onDelete }: ClientListProp {woCount} Work Orders
+
+ + {imCount} + Internal Memos +
{userCount} Assigned
- - {/* Project Status Summary items inline */} - {client.project_status_summary && client.project_status_summary.length > 0 && ( -
- {client.project_status_summary.slice(0, 3).map((item, key) => ( -
- - ({item.total}) -
- ))} -
- )}
diff --git a/app/(dashboard)/task/types.ts b/app/(dashboard)/task/types.ts index b49ba0f..d2b78e4 100644 --- a/app/(dashboard)/task/types.ts +++ b/app/(dashboard)/task/types.ts @@ -26,6 +26,7 @@ export type IClient = { status_code: string status_name: string total_project: number + total_im?: number total_work_order: number total_user_assigned: number users: IUser[]