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) {
-
+
- {/* Back Link Skeleton */} -
+ {/* Back link placeholder */} +
{/* Client Profile Card Skeleton */} -
-
+
+
-
- -
-
-
-
+
+
+
+
+
- -
-
+
+
- -
-
+ {/* Metrics / Key facts row */} +
{Array.from({ length: 4 }).map((_, i) => ( -
-
-
+
+
+
))}
- {/* Project Assignments Section Skeleton */} -
-
-
-
-
+ {/* Filter Bar Skeleton */} +
- {/* Filter & Layout Bar Skeleton */} -
- - {/* Assignment Cards Grid Skeleton */} -
- {Array.from({ length: 3 }).map((_, i) => ( -
-
-
-
-
-
-
-
-
-
-
-
-
+ {/* Assignment Cards Grid Skeleton */} +
+ {Array.from({ length: 6 }).map((_, i) => ( +
+
+
+
- ))} -
+
+
+
+
+
+
+
+
+
+ ))}
); diff --git a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.tsx b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.tsx index 395f600..4a42c42 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.tsx @@ -22,7 +22,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 '../../../types'; +import { IClient, CLIENT_FALLBACK_IMAGE, END_USER_FALLBACK_IMAGE } from '../../../types'; import { IProjectAssignment, ProjectAssignmentWorkOrderDetail } from '../../../type.assignment'; import { ManageTeam } from '../../../component/ManageTeam'; import UpdateTimelineStatus from '../../../component/UpdateTimelineStatus'; @@ -458,16 +458,18 @@ function initials(name?: string) { } function PartyRow({ role, party, href }: { role: string; party?: { name?: string; photo?: string; description?: string | null; code?: string } | null; href?: string }) { + const fallback = role.toLowerCase().includes('end user') ? END_USER_FALLBACK_IMAGE : CLIENT_FALLBACK_IMAGE; + const body = ( <> -
- {party?.photo ? ( - - ) : ( -
- {initials(party?.name) || '-'} -
- )} +
+

{role}

diff --git a/app/(dashboard)/task/client-detail/[client_id]/project-assignments/ProjectAssignmentForm.tsx b/app/(dashboard)/task/client-detail/[client_id]/project-assignments/ProjectAssignmentForm.tsx index 0e35199..8addd5b 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/project-assignments/ProjectAssignmentForm.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/project-assignments/ProjectAssignmentForm.tsx @@ -25,7 +25,7 @@ import { toast } from 'sonner'; import { cn } from '@/lib/utils'; import { Label } from '@/components/ui/label'; import * as yup from 'yup'; -import { IClient, IEndUser } from '../../../types'; +import { IClient, IEndUser, CLIENT_FALLBACK_IMAGE, END_USER_FALLBACK_IMAGE } from '../../../types'; import { serverApiCall } from '@/lib/server-api'; import dayjs from 'dayjs'; import PageLoading from '@/components/loader/PageLoading'; @@ -206,7 +206,7 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign "project_code": assignmentType === 'Project' ? payload.code : '', "project_name": assignmentType === 'Project' ? payload.name : '', - "project_year": assignmentType === 'Project' ? Number(payload.year) : 2026, + "project_year": assignmentType === 'Project' ? Number(payload.year) : new Date().getFullYear(), "project_start_date": assignmentType === 'Project' ? dayjs(payload.startDate).format('YYYY-MM-DD') : '', "project_end_date": assignmentType === 'Project' ? payload.endDate ? dayjs(payload.endDate).format('YYYY-MM-DD') : '' : '', "project_description": assignmentType === 'Project' ? payload.description : '', @@ -362,7 +362,7 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign return (
- +
{item.name} @@ -403,7 +403,7 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign return (
- +
{user.name} @@ -619,12 +619,8 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
-
- {selectedClient?.photo ? - - : - - } +
+

{selectedClient?.name}

@@ -636,12 +632,8 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
-
- {selectedEndUser?.photo ? - - : - - } +
+

{selectedEndUser?.name}

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/client-detail/[client_id]/project-detail/[project_id]/loading.tsx b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/loading.tsx index eb90f63..b752c2a 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/loading.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/loading.tsx @@ -5,98 +5,93 @@ export default function Loading() { role="status" aria-label="Loading project detail" > - {/* Back Link Skeleton */} -
+ {/* Back link placeholder */} +
{/* Project Header Skeleton */} -
+
-
-
-
-
-
+
+
+
+
- -
+
- -
-
+ {/* Key Facts Grid */} +
{Array.from({ length: 4 }).map((_, i) => ( -
-
-
+
+
+
))}
+ + {/* Client Link Footer */} +
+
+
+
+
+
+
{/* Delivery Overview Skeleton */} -
-
+
+
-
+
-
+
{Array.from({ length: 4 }).map((_, i) => ( -
-
-
+
+
+
))}
- {/* Work Orders List Skeleton */} -
-
-
-
-
+ {/* Filter Skeleton */} +
- {/* Filter Bar Skeleton */} -
- - {/* Work Order Cards */} -
- {Array.from({ length: 2 }).map((_, i) => ( -
-
-
-
-
-
-
-
-
-
-
-
+ {/* Work Order Cards Skeleton */} +
+ {Array.from({ length: 2 }).map((_, i) => ( +
+
+
+
+
+
+
-
-
- -
-
-
+
+
+
- ))} -
+
+
+
+
+
+ ))}
); 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/ManageTeam.tsx b/app/(dashboard)/task/component/ManageTeam.tsx index cb1f881..ff7db2f 100644 --- a/app/(dashboard)/task/component/ManageTeam.tsx +++ b/app/(dashboard)/task/component/ManageTeam.tsx @@ -77,8 +77,8 @@ export function ManageTeam({ assignmentId, onClose, startDate, endDate }: { assi const submitPayload = { "project_assignment_id": assignmentId, "status": draftData.status, - "start_date": draftData.start_date ? new Date(draftData.start_date).toISOString() : '', - "end_date": draftData.end_date ? new Date(draftData.end_date).toISOString() : '', + "start_date": draftData.start_date ? dayjs(draftData.start_date).format("YYYY-MM-DD") : '', + "end_date": draftData.end_date ? dayjs(draftData.end_date).format("YYYY-MM-DD") : '', } console.log(submitPayload) diff --git a/app/(dashboard)/task/component/UpdateTimelineStatus.tsx b/app/(dashboard)/task/component/UpdateTimelineStatus.tsx index c201705..ca85ce5 100644 --- a/app/(dashboard)/task/component/UpdateTimelineStatus.tsx +++ b/app/(dashboard)/task/component/UpdateTimelineStatus.tsx @@ -61,8 +61,8 @@ const UpdateTimelineStatus: FC = ({ assignmentId, onClose }) => { const submitPayload = { "project_assignment_status_detail_id": Number(draftData.detailId), "project_assignment_status_id": Number(draftData.masterId), - "start_date": draftData.start_date_assign ? new Date(draftData.start_date_assign).toISOString() : '', - "end_date": draftData.end_date_assign ? new Date(draftData.end_date_assign).toISOString() : '', + "start_date": draftData.start_date_assign ? dayjs(draftData.start_date_assign).format("YYYY-MM-DD") : '', + "end_date": draftData.end_date_assign ? dayjs(draftData.end_date_assign).format("YYYY-MM-DD") : '', "note": draftData.note, "remarks": draftData.note } 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/loading.tsx b/app/(dashboard)/task/loading.tsx index 617f8d2..8828e3a 100644 --- a/app/(dashboard)/task/loading.tsx +++ b/app/(dashboard)/task/loading.tsx @@ -3,48 +3,43 @@ export default function Loading() {
- {/* Top Page Header Skeleton */} + {/* Header: Title, Subtitle, and Controls */}
-
-
-
+
+
+
-
-
-
+
+
+
- {/* Filter and Layout Toolbar Skeleton */} + {/* Filter and Search Bar Skeleton */}
- {/* Client Cards Grid Skeleton */} -
+ {/* Content Cards Grid Skeleton */} +
{Array.from({ length: 6 }).map((_, i) => ( -
- {/* Image Banner Skeleton */} -
- - {/* Card Content Skeleton */} -
-
-
-
+
+ {/* Top: Avatar and Title */} +
+
+
+
+
+
-
-
+ {/* Mid preview strip */} +
-
-
-
-
-
+ {/* Bottom metrics row */} +
+
+
))} 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