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 3f4dcbe..4194790 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientProfileCard.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientProfileCard.tsx @@ -11,7 +11,7 @@ import { Button } from '@/components/ui/button'; import { LazyImage } from '@/components/ui/lazy-image'; import BadgeStatus from '@/components/ui/badge-status'; import { cn } from '@/lib/utils'; -import { IClient } from '../../../types'; +import { IClient, CLIENT_FALLBACK_IMAGE } from '../../../types'; interface Props { client: IClient; @@ -37,9 +37,10 @@ export default function ClientProfileCard({ client, clientId }: Props) {
-
+
-
- {party?.photo ? ( - - ) : ( -
- {initials(party?.name) || '-'} -
- )} +
+

{role}

diff --git a/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/ProjectHeader.tsx b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/ProjectHeader.tsx index c532e9d..560a715 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/ProjectHeader.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/ProjectHeader.tsx @@ -11,7 +11,7 @@ import { Badge } from '@/components/ui/badge'; import { LazyImage } from '@/components/ui/lazy-image'; import BadgeStatus from '@/components/ui/badge-status'; import { cn } from '@/lib/utils'; -import { IClient } from '@/app/(dashboard)/task/types'; +import { IClient, CLIENT_FALLBACK_IMAGE } from '@/app/(dashboard)/task/types'; import { IProject } from '@/app/(dashboard)/task/type.project'; import { formatDate, formatSpan } from './format'; @@ -90,8 +90,8 @@ export default function ProjectHeader({ client, clientId, project }: Props) { href={`/task/client-detail/${clientId}`} className="group mt-6 flex items-center gap-3 rounded-xl border border-border/60 bg-muted/20 p-3 transition-colors hover:bg-muted/40" > -
- +
+

Client

diff --git a/app/(dashboard)/task/component/FormEndUser.tsx b/app/(dashboard)/task/component/FormEndUser.tsx index 34fd603..f961ae5 100644 --- a/app/(dashboard)/task/component/FormEndUser.tsx +++ b/app/(dashboard)/task/component/FormEndUser.tsx @@ -110,6 +110,7 @@ const FormEndUser: FC = ({ data, onSuccess, onCancel }) => { } catch (error: any) { toast.error(`Failed uploading image.\n(${error?.response?.data?.code || error?.response?.status || '-'}) ${error?.response?.data?.message || error?.response?.statusText || error?.message}`, { id: toastId }); } finally { + toast.dismiss(toastId) setIsLoading(false) } @@ -149,9 +150,9 @@ const FormEndUser: FC = ({ data, onSuccess, onCancel }) => { - EndUser Information + End User Information - Enter the basic details of the EndUser. + Enter the basic details of the End User.
@@ -160,7 +161,7 @@ const FormEndUser: FC = ({ data, onSuccess, onCancel }) => { ( - EndUser Name * + End User Name * @@ -235,7 +236,7 @@ const FormEndUser: FC = ({ data, onSuccess, onCancel }) => { Cancel diff --git a/app/(dashboard)/task/component/client/ClientGrid.tsx b/app/(dashboard)/task/component/client/ClientGrid.tsx index b13c762..f1b6555 100644 --- a/app/(dashboard)/task/component/client/ClientGrid.tsx +++ b/app/(dashboard)/task/component/client/ClientGrid.tsx @@ -17,7 +17,7 @@ import { } from "@/components/ui/hover-card"; import { cn } from '@/lib/utils'; import BadgeStatus from '@/components/ui/badge-status'; -import { IClient } from '../../types'; +import { IClient, CLIENT_FALLBACK_IMAGE } from '../../types'; interface ClientGridProps { clients: IClient[]; @@ -49,7 +49,8 @@ export default function ClientGrid({ clients, onEdit, onDelete }: ClientGridProp
- {assignment.client.photo ? - - : - - } + Client: {assignment.client.name} @@ -222,17 +220,14 @@ export default function AssignmentGrid({ {assignment.end_user?.name && (
-
- {assignment.end_user?.photo ? ( - - ) : ( - - )} +
+
End User: {assignment.end_user.name} diff --git a/app/(dashboard)/task/types.ts b/app/(dashboard)/task/types.ts index 9a4013f..b49ba0f 100644 --- a/app/(dashboard)/task/types.ts +++ b/app/(dashboard)/task/types.ts @@ -1,5 +1,8 @@ import { IUser } from "@/app/admin/administration/user/component/type"; +export const CLIENT_FALLBACK_IMAGE = '/assets/illustrations/client_fallback.webp'; +export const END_USER_FALLBACK_IMAGE = '/assets/illustrations/end_user_fallback.webp'; + export type IEndUser = { id?: string; code?: string diff --git a/components/ui/badge-status.tsx b/components/ui/badge-status.tsx index 7aa30f2..d2d60c3 100644 --- a/components/ui/badge-status.tsx +++ b/components/ui/badge-status.tsx @@ -1,37 +1,49 @@ -import { Badge, STATUS_BADGE_MAP } from "@/components/ui/badge" -import { cn } from "@/lib/utils" - -export function formatStatusText(status?: string): string { - if (!status) return ""; - const trimmed = status.trim(); - if (!trimmed) return ""; - - // Tetap UPPERCASE jika seluruh teks status hanya 3 huruf (SIT, UAT, PTR, dll) atau akronim BAST - const upperAcronyms = new Set(["SIT", "UAT", "PTR", "BAST", "POC", "WIP", "WO", "IM"]); - if (trimmed.length === 3 || upperAcronyms.has(trimmed.toUpperCase())) { - return trimmed.toUpperCase(); - } - - // Capitalize setiap kata untuk teks status lainnya - return trimmed - .split(/\s+/) - .map(word => { - if (!word) return ""; - return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(); - }) - .join(" "); -} - -export default function BadgeStatus({ status, className }: { status: string, className?: string }) { // e.g. status = "UAT" - const formatted = formatStatusText(status); - const lookupKey = (status || "").toLowerCase().trim(); - - return ( - - {formatted} - - ); -} \ No newline at end of file +import { Badge, STATUS_BADGE_MAP } from "@/components/ui/badge" +import { cn } from "@/lib/utils" + +function extractStatusString(status?: any): string { + if (!status) return ""; + if (typeof status === "string") return status; + if (typeof status === "object") { + return status.name || status.status || status.title || ""; + } + return String(status); +} + +export function formatStatusText(status?: any): string { + const raw = extractStatusString(status); + const trimmed = raw.trim(); + if (!trimmed) return ""; + + // Tetap UPPERCASE jika seluruh teks status hanya 3 huruf (SIT, UAT, PTR, dll) atau akronim BAST + const upperAcronyms = new Set(["SIT", "UAT", "PTR", "BAST", "POC", "WIP", "WO", "IM"]); + if (trimmed.length === 3 || upperAcronyms.has(trimmed.toUpperCase())) { + return trimmed.toUpperCase(); + } + + // Capitalize setiap kata untuk teks status lainnya + return trimmed + .split(/\s+/) + .map(word => { + if (!word) return ""; + return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(); + }) + .join(" "); +} + +export default function BadgeStatus({ status, className }: { status: any, className?: string }) { // e.g. status = "UAT" + const raw = extractStatusString(status); + const formatted = formatStatusText(raw); + if (!formatted) return null; + + const lookupKey = raw.toLowerCase().trim(); + + return ( + + {formatted} + + ); +} diff --git a/components/ui/lazy-image.tsx b/components/ui/lazy-image.tsx index c287d0c..c1d4ba4 100644 --- a/components/ui/lazy-image.tsx +++ b/components/ui/lazy-image.tsx @@ -1,4 +1,4 @@ -"use client" +"use client"; import { cn } from "@/lib/utils"; import { useState, useRef, useEffect } from "react"; @@ -8,31 +8,47 @@ export function LazyImage({ alt, className, imgClassName, + fallbackSrc, }: { - src: string; + src?: string | null; alt: string; className?: string; imgClassName?: string; + fallbackSrc?: string; }) { + const effectiveSrc = src || fallbackSrc || ""; + const [currentSrc, setCurrentSrc] = useState(effectiveSrc); const [isLoaded, setIsLoaded] = useState(false); const imgRef = useRef(null); - // Check if the image is already loaded from the cache useEffect(() => { - if (imgRef.current?.complete) { + const nextSrc = src || fallbackSrc || ""; + setCurrentSrc(nextSrc); + setIsLoaded(false); + }, [src, fallbackSrc]); + + useEffect(() => { + if (imgRef.current?.complete && (imgRef.current?.naturalWidth ?? 0) > 0) { setIsLoaded(true); } - }, [src]); // Re-run this check if the src prop changes + }, [currentSrc]); + + const handleError = () => { + if (fallbackSrc && currentSrc !== fallbackSrc) { + setCurrentSrc(fallbackSrc); + } + }; return (
{alt} setIsLoaded(true)} + onError={handleError} className={cn( "w-full h-full object-cover transition-all duration-700 ease-in-out", imgClassName, diff --git a/public/assets/illustrations/client_fallback.webp b/public/assets/illustrations/client_fallback.webp new file mode 100644 index 0000000..e6838b6 Binary files /dev/null and b/public/assets/illustrations/client_fallback.webp differ diff --git a/public/assets/illustrations/end_user_fallback.webp b/public/assets/illustrations/end_user_fallback.webp new file mode 100644 index 0000000..35fe983 Binary files /dev/null and b/public/assets/illustrations/end_user_fallback.webp differ