"use client"; 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 Link from 'next/link'; import { LazyImage } from '@/components/ui/lazy-image'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { Tooltip, TooltipContent, TooltipTrigger, } from '@/components/ui/tooltip'; import { HoverCard, HoverCardContent, HoverCardTrigger, } from "@/components/ui/hover-card"; import { cn } from '@/lib/utils'; import BadgeStatus from '@/components/ui/badge-status'; import { IClient } from '../../types'; interface ClientGridProps { clients: IClient[]; onEdit: (client: IClient) => void; onDelete: (client: IClient) => void; } export default function ClientGrid({ clients, onEdit, onDelete }: ClientGridProps) { 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 isActive = client.status_name.toLowerCase() === 'active'; return ( {/* Uncropped Image banner */}
Status Summary
This is status summary information from WO or IM related to this client.
{client.project_status_summary.map((item, key) => (
{item.total}
))}
{client.code && ( {client.code} )} {client.name}

{projectCount === 0 && imCount === 0 && woCount === 0 ? ( "No active projects, internal memos, or work orders recorded for this client yet." ) : ( <> {(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}. )} )}

Assigned Team
{client.users?.slice(0, 5).map((user, key) => (

{user?.name}

{user?.position?.name}

))} {client.users?.length! > 5 && (
+{client.users?.length! - 5}
)} {client.users?.length === 0 && ( No team assigned )}
e.stopPropagation()}> View Client Detail onEdit(client)} onClick={(e) => e.stopPropagation()}> Edit Client onDelete(client)} className="text-destructive" onClick={(e) => e.stopPropagation()}> Delete Client
); })}
); }