Improve image fallbacks and status display

This commit adds reusable client and end-user fallback assets and updates profile cards, lists, and assignment views to render graceful placeholders when images are missing or fail to load. It also hardens the shared LazyImage component with fallback handling and improves BadgeStatus so it accepts object-like status values and still renders clean labels. Minor UX fixes include dismissing upload toasts after completion and clarifying end-user form labels/copy.
This commit is contained in:
Ichsan Kurniawan
2026-10-07 12:16:03 +07:00
parent c6ecabd084
commit 3f0ed29f0c
12 changed files with 119 additions and 87 deletions
@@ -1,6 +1,7 @@
"use client";
import { IProjectAssignment } from '../../type.assignment';
import { CLIENT_FALLBACK_IMAGE, END_USER_FALLBACK_IMAGE } from '../../types';
import { motion } from 'motion/react';
import { Card900 } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
@@ -205,16 +206,13 @@ export default function AssignmentGrid({
href={`/task/client-detail/${assignment.client.id}`}
className="flex items-center gap-1.5 px-2 py-0.5 rounded-md bg-muted/60 hover:bg-muted border border-border/50 text-foreground transition-colors text-[11px] max-w-full min-w-0"
>
{assignment.client.photo ?
<LazyImage
src={assignment.client.photo}
alt={assignment.client.name}
className="w-3 h-3 rounded-xs bg-transparent shrink-0"
imgClassName="object-cover"
/>
:
<BuildingComplex className="w-3 h-3 text-muted-foreground shrink-0" />
}
<LazyImage
src={assignment.client.photo || CLIENT_FALLBACK_IMAGE}
fallbackSrc={CLIENT_FALLBACK_IMAGE}
alt={assignment.client.name}
className="w-3.5 h-3.5 rounded-xs bg-transparent shrink-0"
imgClassName="object-contain"
/>
<span className="text-muted-foreground shrink-0">Client:</span>
<span className="font-medium truncate max-w-32.5 sm:max-w-45">{assignment.client.name}</span>
</Link>
@@ -222,17 +220,14 @@ export default function AssignmentGrid({
{assignment.end_user?.name && (
<div className="flex items-center gap-1.5 px-2 py-0.5 rounded-md bg-muted/40 border border-border/40 text-foreground text-[11px] max-w-full min-w-0">
<div className="w-3.5 h-3.5 rounded-xs overflow-hidden shrink-0 bg-secondary">
{assignment.end_user?.photo ? (
<LazyImage
src={assignment.end_user.photo ? assignment.end_user.photo : '/assets/ilustration.png'}
alt={assignment.end_user.name}
className="w-full h-full bg-transparent"
imgClassName="object-contain"
/>
) : (
<Building className="w-3 h-3 text-muted-foreground" />
)}
<div className="w-3.5 h-3.5 rounded-xs overflow-hidden shrink-0 bg-transparent">
<LazyImage
src={assignment.end_user?.photo || END_USER_FALLBACK_IMAGE}
fallbackSrc={END_USER_FALLBACK_IMAGE}
alt={assignment.end_user.name}
className="w-full h-full bg-transparent"
imgClassName="object-contain"
/>
</div>
<span className="text-muted-foreground shrink-0">End User:</span>
<span className="font-medium truncate max-w-32.5 sm:max-w-45">{assignment.end_user.name}</span>