This commit is contained in:
Ichsan Kurniawan
2026-04-22 14:28:53 +07:00
parent 60d1af3758
commit dbc70a6671
10 changed files with 65 additions and 43 deletions
+11 -16
View File
@@ -19,7 +19,7 @@ import { useRouter } from 'next/navigation';
import FormClient from './FormClient';
import { ConfirmDeleteWithInput } from '@/components/modal/ConfirmDeleteWithInput';
export default function ClientGrid({ clients, assignments }: { clients: IClient[], assignments: any[] }) {
export default function ClientGrid({ clients }: { clients: IClient[] }) {
const router = useRouter();
const [action, setAction] = useState<'EDIT' | 'DELETE' | undefined>(undefined)
const [selectedData, setShowSelectedData] = useState<IClient>()
@@ -42,13 +42,10 @@ export default function ClientGrid({ clients, assignments }: { clients: IClient[
<>
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
{clients.map((client, i) => {
const clientAssignments = assignments.filter(a => a.clientId === client.id);
const imCount = 0
const projectCount = client.total_project;
// const woCount = clientAssignments.reduce((acc, a) => acc + a.workOrders.length, 0);
const woCount = client.total_work_order
const assignedEmployeeIds = Array.from(new Set(clientAssignments.flatMap(a => a.assignedEmployees)));
console.log(client)
const userCount = client.total_user_assigned
return (
<motion.div
@@ -106,7 +103,7 @@ export default function ClientGrid({ clients, assignments }: { clients: IClient[
{woCount! > 0 && (
<>
A dedicated team of{" "}
<span className="font-bold text-foreground">{assignedEmployeeIds.length} experts</span> is handling{" "}
<span className="font-bold text-foreground">{userCount} experts</span> is handling{" "}
<span className="font-bold text-foreground">{woCount} work order{woCount! > 1 ? 's' : ''}</span>{" "}to ensure successful delivery for <span className="italic">{client.end_user_name}</span>.
</>
)}
@@ -123,27 +120,25 @@ export default function ClientGrid({ clients, assignments }: { clients: IClient[
return (
<div key={key}>
<Tooltip>
<TooltipTrigger asChild>
<LazyImage src={user?.avatar!} alt={user?.fullname!}
className="inline-block h-8 w-8 rounded-full ring-2 ring-background object-cover"
/>
<TooltipTrigger>
<LazyImage src={user?.avatar ? `${process.env.BASE_URL_IMG}/${user?.avatar}` : '/assets/no-avatar.jpg'} alt={user?.fullname!} className="inline-block h-8 w-8 rounded-full border-2 border-background cursor-help hover:scale-110 hover:z-10 transition-transform" />
</TooltipTrigger>
<TooltipContent>
<p className="text-xs font-bold">{user?.fullname}</p>
<p className="text-[10px] opacity-80">{user?.role?.name}</p>
<p className="text-xs font-bold">{user?.name}</p>
<p className="text-[10px] opacity-80">{user?.position?.name}</p>
</TooltipContent>
</Tooltip>
</div>
);
})}
{client.users?.length! > 5 && (
{client.users?.length! > 5 &&
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-accent ring-2 ring-background text-[10px] font-bold">
+{client.users?.length! - 5}
</div>
)}
{client.users?.length === 0 && (
}
{client.users?.length === 0 &&
<span className="text-[10px] text-muted-foreground italic">No team assigned</span>
)}
}
</div>
</div>
<div className="flex items-center gap-2 self-end">