Merge branch 'project-assignment' of https://github.com/ichsankurnia/hats-app into project-assignment

This commit is contained in:
Mohamad Ihsan
2026-10-07 13:09:48 +07:00
18 changed files with 242 additions and 239 deletions
@@ -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) {
<section aria-labelledby="client-name" className="rounded-2xl border border-border bg-card p-5 sm:p-7">
<div className="flex flex-col gap-6 md:flex-row md:items-start md:justify-between">
<div className="flex min-w-0 items-start gap-4 sm:gap-5">
<div className="flex h-20 w-20 shrink-0 items-center justify-center overflow-hidden rounded-2xl border border-border bg-zinc-50 p-1.5 sm:h-24 sm:w-24 dark:bg-zinc-100">
<div className="flex h-20 w-20 shrink-0 items-center justify-center overflow-hidden rounded-2xl border border-border bg-muted/30 p-1.5 sm:h-24 sm:w-24">
<LazyImage
src={client.photo}
src={client.photo || CLIENT_FALLBACK_IMAGE}
fallbackSrc={CLIENT_FALLBACK_IMAGE}
alt={client.name}
className="h-full w-full bg-transparent"
imgClassName="object-contain"
@@ -3,70 +3,59 @@ export default function Loading() {
<div
className="flex-1 space-y-6 p-4 sm:p-8 pt-4 sm:pt-6"
role="status"
aria-label="Loading client details"
aria-label="Loading client detail"
>
{/* Back Link Skeleton */}
<div className="h-5 w-32 animate-pulse rounded-md bg-muted" />
{/* Back link placeholder */}
<div className="h-5 w-32 animate-pulse rounded-lg bg-muted" />
{/* Client Profile Card Skeleton */}
<div className="rounded-2xl border border-border bg-card p-5 sm:p-7">
<div className="flex flex-col gap-6 md:flex-row md:items-start md:justify-between">
<div className="rounded-2xl border border-border bg-card p-5 sm:p-7 shadow-2xs">
<div className="flex flex-col gap-6 sm:flex-row sm:items-start sm:justify-between">
<div className="flex min-w-0 items-start gap-4 sm:gap-5 flex-1">
<div className="h-20 w-20 sm:h-24 sm:w-24 shrink-0 animate-pulse rounded-2xl bg-muted" />
<div className="min-w-0 flex-1 space-y-3">
<div className="flex flex-wrap items-center gap-2">
<div className="h-5 w-16 animate-pulse rounded-lg bg-muted" />
<div className="h-5 w-20 animate-pulse rounded-lg bg-muted" />
<div className="h-16 w-16 sm:h-20 sm:w-20 shrink-0 animate-pulse rounded-2xl bg-muted" />
<div className="min-w-0 flex-1 space-y-2.5">
<div className="flex items-center gap-2">
<div className="h-5 w-20 animate-pulse rounded-md bg-muted" />
<div className="h-5 w-24 animate-pulse rounded-md bg-muted" />
</div>
<div className="h-8 w-3/4 max-w-sm animate-pulse rounded-lg bg-muted" />
<div className="h-4 w-48 animate-pulse rounded bg-muted" />
<div className="h-7 w-2/3 max-w-sm animate-pulse rounded-lg bg-muted" />
<div className="h-4 w-full max-w-md animate-pulse rounded bg-muted" />
</div>
</div>
<div className="h-9 w-36 shrink-0 animate-pulse rounded-lg bg-muted" />
</div>
<div className="mt-7 grid grid-cols-2 gap-x-6 gap-y-5 border-t border-border/70 pt-6 sm:grid-cols-4">
{/* Metrics / Key facts row */}
<div className="mt-7 grid grid-cols-2 gap-4 border-t border-border/70 pt-6 sm:grid-cols-4">
{Array.from({ length: 4 }).map((_, i) => (
<div key={i} className="space-y-2">
<div className="h-3 w-14 animate-pulse rounded bg-muted" />
<div className="h-4 w-24 animate-pulse rounded bg-muted" />
<div key={i} className="space-y-1.5">
<div className="h-3 w-16 animate-pulse rounded bg-muted" />
<div className="h-5 w-24 animate-pulse rounded bg-muted" />
</div>
))}
</div>
</div>
{/* Project Assignments Section Skeleton */}
<div className="space-y-4 pt-2">
<div className="flex items-center justify-between gap-4">
<div className="h-7 w-48 animate-pulse rounded-lg bg-muted" />
<div className="h-6 w-20 animate-pulse rounded-md bg-muted" />
</div>
{/* Filter Bar Skeleton */}
<div className="h-11 w-full animate-pulse rounded-xl border border-border bg-card" />
{/* Filter & Layout Bar Skeleton */}
<div className="h-10 w-full animate-pulse rounded-xl border border-border bg-card" />
{/* Assignment Cards Grid Skeleton */}
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
{Array.from({ length: 3 }).map((_, i) => (
<div key={i} className="rounded-xl border border-border/80 bg-card p-5 space-y-4">
<div className="flex items-center justify-between">
<div className="h-5 w-24 animate-pulse rounded bg-muted" />
<div className="h-4 w-16 animate-pulse rounded bg-muted" />
</div>
<div className="space-y-2">
<div className="h-5 w-3/4 animate-pulse rounded bg-muted" />
<div className="h-3.5 w-full animate-pulse rounded bg-muted" />
</div>
<div className="flex items-center justify-between border-t border-border/60 pt-3">
<div className="h-4 w-28 animate-pulse rounded bg-muted" />
<div className="h-6 w-16 animate-pulse rounded-full bg-muted" />
</div>
{/* Assignment Cards Grid Skeleton */}
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
{Array.from({ length: 6 }).map((_, i) => (
<div key={i} className="rounded-2xl border border-border bg-card p-5 space-y-3.5 shadow-2xs">
<div className="flex items-center justify-between gap-2">
<div className="h-5 w-24 animate-pulse rounded-md bg-muted" />
<div className="h-5 w-16 animate-pulse rounded-md bg-muted" />
</div>
))}
</div>
<div className="space-y-2">
<div className="h-5 w-4/5 animate-pulse rounded bg-muted" />
<div className="h-4 w-3/5 animate-pulse rounded bg-muted" />
</div>
<div className="flex items-center justify-between border-t border-border/60 pt-3">
<div className="h-4 w-32 animate-pulse rounded bg-muted" />
<div className="h-6 w-16 animate-pulse rounded-full bg-muted" />
</div>
</div>
))}
</div>
</div>
);
@@ -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 = (
<>
<div className="relative h-12 w-12 shrink-0 overflow-hidden rounded-xl border border-border bg-background">
{party?.photo ? (
<LazyImage src={party.photo} alt={party.name ?? role} className="h-full w-full bg-transparent" imgClassName="object-contain p-1" />
) : (
<div className="flex h-full w-full items-center justify-center text-sm font-semibold text-muted-foreground">
{initials(party?.name) || '-'}
</div>
)}
<div className="relative h-12 w-12 shrink-0 overflow-hidden rounded-xl border border-border bg-muted/20 p-1">
<LazyImage
src={party?.photo || fallback}
fallbackSrc={fallback}
alt={party?.name ?? role}
className="h-full w-full bg-transparent"
imgClassName="object-contain"
/>
</div>
<div className="min-w-0 flex-1">
<p className="text-xs text-muted-foreground">{role}</p>
@@ -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 (
<div className={`flex items-center justify-between w-full py-1 rounded-sm ${isSelected ? 'bg-zinc-800' : ''}`}>
<div className="flex items-center gap-3">
<LazyImage className='w-10 h-10 rounded-md border border-border' alt={item.name} src={item.photo ? item.photo : '/assets/ilustration.png'} />
<LazyImage className='w-10 h-10 rounded-md border border-border bg-muted/30 p-1 shrink-0' alt={item.name} src={item.photo || CLIENT_FALLBACK_IMAGE} fallbackSrc={CLIENT_FALLBACK_IMAGE} imgClassName="object-contain" />
<div className="flex flex-col">
<span className={`text-sm ${isSelected ? 'font-bold text-primary' : ''}`}>
{item.name}
@@ -403,7 +403,7 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
return (
<div className={`flex items-center justify-between w-full py-1 rounded-sm ${isSelected ? 'bg-zinc-800' : ''}`}>
<div className="flex items-center gap-3">
<LazyImage className='w-10 h-10 rounded-md border border-border' alt={user.name} src={user.photo ? user.photo : '/assets/ilustration.png'} />
<LazyImage className='w-10 h-10 rounded-md border border-border bg-muted/30 p-1 shrink-0' alt={user.name} src={user.photo || END_USER_FALLBACK_IMAGE} fallbackSrc={END_USER_FALLBACK_IMAGE} imgClassName="object-contain" />
<div className="flex flex-col">
<span className={`text-sm ${isSelected ? 'font-bold text-primary' : ''}`}>
{user.name}
@@ -619,12 +619,8 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
<div className="space-y-3">
<Label className="text-[10px] text-muted-foreground uppercase tracking-widest font-bold">Client Information</Label>
<div className="flex items-center gap-4 p-4 rounded-xl border bg-card/50">
<div className="w-12 h-12 rounded-lg bg-white border flex items-center justify-center overflow-hidden shrink-0">
{selectedClient?.photo ?
<LazyImage src={selectedClient.photo} alt={selectedClient.name} className="w-11 h-11 object-contain rounded" />
:
<Briefcase className="w-6 h-6 text-muted-foreground" />
}
<div className="w-12 h-12 rounded-xl bg-muted/30 border border-border flex items-center justify-center overflow-hidden shrink-0 p-1">
<LazyImage src={selectedClient?.photo || CLIENT_FALLBACK_IMAGE} fallbackSrc={CLIENT_FALLBACK_IMAGE} alt={selectedClient?.name || 'Client'} className="w-full h-full bg-transparent" imgClassName="object-contain" />
</div>
<div className="min-w-0">
<p className="font-bold text-lg truncate">{selectedClient?.name}</p>
@@ -636,12 +632,8 @@ export default function ProjectAssignmentForm({ client, clientId, isEdit, assign
<div className="space-y-3">
<Label className="text-[10px] text-muted-foreground uppercase tracking-widest font-bold">End User Information</Label>
<div className="flex items-center gap-4 p-4 rounded-xl border bg-card/50">
<div className="w-12 h-12 rounded-lg bg-white border flex items-center justify-center overflow-hidden shrink-0">
{selectedEndUser?.photo ?
<LazyImage src={selectedEndUser.photo} alt={selectedEndUser.name} className="w-11 h-11 object-contain rounded" />
:
<Building2 className="w-6 h-6 text-muted-foreground" />
}
<div className="w-12 h-12 rounded-xl bg-muted/30 border border-border flex items-center justify-center overflow-hidden shrink-0 p-1">
<LazyImage src={selectedEndUser?.photo || END_USER_FALLBACK_IMAGE} fallbackSrc={END_USER_FALLBACK_IMAGE} alt={selectedEndUser?.name || 'End User'} className="w-full h-full bg-transparent" imgClassName="object-contain" />
</div>
<div className="min-w-0">
<p className="font-bold text-lg truncate">{selectedEndUser?.name}</p>
@@ -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"
>
<div className="flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-zinc-50 p-1 dark:bg-zinc-100">
<LazyImage src={client.photo} alt={client.name} className="h-full w-full bg-transparent" imgClassName="object-contain" />
<div className="flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-muted/30 p-1">
<LazyImage src={client.photo || CLIENT_FALLBACK_IMAGE} fallbackSrc={CLIENT_FALLBACK_IMAGE} alt={client.name} className="h-full w-full bg-transparent" imgClassName="object-contain" />
</div>
<div className="min-w-0 flex-1">
<p className="text-xs text-muted-foreground">Client</p>
@@ -5,98 +5,93 @@ export default function Loading() {
role="status"
aria-label="Loading project detail"
>
{/* Back Link Skeleton */}
<div className="h-5 w-32 animate-pulse rounded-md bg-muted" />
{/* Back link placeholder */}
<div className="h-5 w-32 animate-pulse rounded-lg bg-muted" />
{/* Project Header Skeleton */}
<div className="rounded-2xl border border-border bg-card p-5 sm:p-7">
<div className="rounded-2xl border border-border bg-card p-5 sm:p-7 shadow-2xs">
<div className="flex flex-col gap-6 md:flex-row md:items-start md:justify-between">
<div className="flex min-w-0 items-start gap-4 sm:gap-5 flex-1">
<div className="h-14 w-14 sm:h-20 sm:w-20 shrink-0 animate-pulse rounded-2xl bg-muted" />
<div className="min-w-0 flex-1 space-y-3">
<div className="flex flex-wrap items-center gap-2">
<div className="h-5 w-20 animate-pulse rounded-lg bg-muted" />
<div className="h-5 w-16 animate-pulse rounded-lg bg-muted" />
<div className="h-5 w-24 animate-pulse rounded-lg bg-muted" />
<div className="flex items-center gap-2">
<div className="h-5 w-20 animate-pulse rounded-md bg-muted" />
<div className="h-5 w-24 animate-pulse rounded-md bg-muted" />
<div className="h-5 w-28 animate-pulse rounded-md bg-muted" />
</div>
<div className="h-8 w-3/4 max-w-md animate-pulse rounded-lg bg-muted" />
<div className="h-7 w-3/4 max-w-md animate-pulse rounded-lg bg-muted" />
<div className="h-4 w-full max-w-xl animate-pulse rounded bg-muted" />
</div>
</div>
<div className="h-9 w-28 shrink-0 animate-pulse rounded-lg bg-muted" />
</div>
<div className="mt-7 grid grid-cols-2 gap-4 border-t border-border/70 pt-6 sm:grid-cols-4">
{/* Key Facts Grid */}
<div className="mt-7 grid grid-cols-2 gap-x-6 gap-y-5 border-t border-border/70 pt-6 sm:grid-cols-4">
{Array.from({ length: 4 }).map((_, i) => (
<div key={i} className="space-y-2">
<div className="h-3 w-12 animate-pulse rounded bg-muted" />
<div className="h-4 w-24 animate-pulse rounded bg-muted" />
<div key={i} className="space-y-1.5">
<div className="h-3 w-14 animate-pulse rounded bg-muted" />
<div className="h-4 w-28 animate-pulse rounded bg-muted" />
</div>
))}
</div>
{/* Client Link Footer */}
<div className="mt-6 flex items-center justify-between border-t border-border/60 pt-4">
<div className="flex items-center gap-2.5">
<div className="h-6 w-6 animate-pulse rounded-full bg-muted" />
<div className="h-4 w-36 animate-pulse rounded bg-muted" />
</div>
<div className="h-4 w-24 animate-pulse rounded bg-muted" />
</div>
</div>
{/* Delivery Overview Skeleton */}
<div className="rounded-2xl border border-border bg-card p-5 sm:p-6 space-y-5">
<div className="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
<div className="rounded-2xl border border-border bg-card p-5 sm:p-6 shadow-2xs space-y-5">
<div className="flex items-center justify-between gap-3">
<div className="space-y-1">
<div className="h-4 w-36 animate-pulse rounded bg-muted" />
<div className="h-3 w-48 animate-pulse rounded bg-muted" />
</div>
<div className="h-6 w-24 animate-pulse rounded-md bg-muted" />
<div className="h-7 w-20 animate-pulse rounded-lg bg-muted" />
</div>
<div className="h-2.5 w-full animate-pulse rounded-full bg-muted" />
<div className="h-2 w-full animate-pulse rounded-full bg-muted" />
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
{Array.from({ length: 4 }).map((_, i) => (
<div key={i} className="rounded-xl border border-border/70 bg-muted/20 p-3.5 space-y-2">
<div className="h-3 w-16 animate-pulse rounded bg-muted" />
<div className="h-6 w-12 animate-pulse rounded bg-muted" />
<div key={i} className="h-24 animate-pulse rounded-xl border border-border/60 bg-muted/20 p-3.5 space-y-2">
<div className="h-3 w-16 rounded bg-muted" />
<div className="h-6 w-12 rounded bg-muted" />
</div>
))}
</div>
</div>
{/* Work Orders List Skeleton */}
<div className="space-y-4 pt-2">
<div className="flex items-center gap-2">
<div className="h-6 w-28 animate-pulse rounded-md bg-muted" />
<div className="h-5 w-8 animate-pulse rounded-md bg-muted" />
</div>
{/* Filter Skeleton */}
<div className="h-11 w-full animate-pulse rounded-xl border border-border bg-card" />
{/* Filter Bar Skeleton */}
<div className="h-10 w-full animate-pulse rounded-xl border border-border bg-card" />
{/* Work Order Cards */}
<div className="space-y-4">
{Array.from({ length: 2 }).map((_, i) => (
<div key={i} className="rounded-2xl border border-border/80 bg-card p-4 sm:p-6 space-y-4">
<div className="flex items-start justify-between gap-4">
<div className="flex items-start gap-4 flex-1">
<div className="h-11 w-11 shrink-0 animate-pulse rounded-xl bg-muted" />
<div className="space-y-2 flex-1">
<div className="flex items-center gap-2">
<div className="h-5 w-20 animate-pulse rounded-md bg-muted" />
<div className="h-5 w-16 animate-pulse rounded-md bg-muted" />
</div>
<div className="h-5 w-2/3 max-w-sm animate-pulse rounded bg-muted" />
<div className="h-3.5 w-full max-w-md animate-pulse rounded bg-muted" />
</div>
{/* Work Order Cards Skeleton */}
<div className="space-y-4">
{Array.from({ length: 2 }).map((_, i) => (
<div key={i} className="rounded-2xl border border-border bg-card p-4 sm:p-6 space-y-4">
<div className="flex items-start gap-4">
<div className="h-11 w-11 shrink-0 animate-pulse rounded-xl bg-muted" />
<div className="min-w-0 flex-1 space-y-2">
<div className="flex items-center gap-2">
<div className="h-5 w-24 animate-pulse rounded-md bg-muted" />
<div className="h-5 w-20 animate-pulse rounded-md bg-muted" />
</div>
<div className="h-8 w-28 shrink-0 animate-pulse rounded-md bg-muted" />
</div>
<div className="flex items-center justify-between border-t border-border/60 pt-3.5">
<div className="h-4 w-48 animate-pulse rounded bg-muted" />
<div className="h-6 w-24 animate-pulse rounded-full bg-muted" />
<div className="h-5 w-1/2 animate-pulse rounded bg-muted" />
<div className="h-4 w-3/4 animate-pulse rounded bg-muted" />
</div>
<div className="h-9 w-28 shrink-0 animate-pulse rounded-lg bg-muted" />
</div>
))}
</div>
<div className="flex items-center justify-between border-t border-border/60 pt-3">
<div className="h-4 w-48 animate-pulse rounded bg-muted" />
<div className="h-4 w-32 animate-pulse rounded bg-muted" />
</div>
</div>
))}
</div>
</div>
);
@@ -110,6 +110,7 @@ const FormEndUser: FC<Props> = ({ 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<Props> = ({ data, onSuccess, onCancel }) => {
<AlertDialog open={true}>
<AlertDialogContent className='max-h-[90vh] overflow-y-auto'>
<AlertDialogHeader>
<AlertDialogTitle>EndUser Information</AlertDialogTitle>
<AlertDialogTitle>End User Information</AlertDialogTitle>
<AlertDialogDescription>
Enter the basic details of the EndUser.
Enter the basic details of the End User.
</AlertDialogDescription>
</AlertDialogHeader>
<Form {...form}>
@@ -160,7 +161,7 @@ const FormEndUser: FC<Props> = ({ data, onSuccess, onCancel }) => {
<FormField control={form.control} name='name'
render={({ field }) => (
<FormItem>
<FormLabel>EndUser Name <span className='text-red-600 font-bold'>*</span></FormLabel>
<FormLabel>End User Name <span className='text-red-600 font-bold'>*</span></FormLabel>
<FormControl>
<Input {...field} placeholder='e.g. PT ASDP Indonesia Ferry' />
</FormControl>
@@ -235,7 +236,7 @@ const FormEndUser: FC<Props> = ({ data, onSuccess, onCancel }) => {
<AlertDialogCancel onClick={onCancel} disabled={isLoading} type='button'>Cancel</AlertDialogCancel>
<Button type="submit" disabled={isLoading}>
{isLoading && <Loader2 className='animate-spin' />}
Save EndUser
Save End User
</Button>
</AlertDialogFooter>
</form>
@@ -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)
@@ -61,8 +61,8 @@ const UpdateTimelineStatus: FC<Props> = ({ 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
}
@@ -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
<div className="relative h-40 bg-muted/20 dark:bg-zinc-800/30 overflow-hidden flex items-center justify-center p-3 border-b border-border/50">
<Link href={`/task/client-detail/${client.id}`} className="w-full h-full flex items-center justify-center">
<LazyImage
src={client.photo!}
src={client.photo || CLIENT_FALLBACK_IMAGE}
fallbackSrc={CLIENT_FALLBACK_IMAGE}
alt={client.name}
className="w-full h-full max-h-32 bg-transparent"
imgClassName="object-contain p-1 group-hover:scale-105 transition-transform duration-500"
@@ -1,4 +1,4 @@
import { IClient } from '../../types';
import { IClient, CLIENT_FALLBACK_IMAGE } from '../../types';
import { motion } from 'motion/react';
import { Card900, CardContent } from '@/components/ui/card';
import Link from 'next/link';
@@ -50,7 +50,8 @@ export default function ClientList({ clients, onEdit, onDelete }: ClientListProp
<div className="relative w-full lg:w-56 xl:w-64 h-48 lg:h-auto min-h-40 bg-muted/20 dark:bg-zinc-800/20 shrink-0 overflow-hidden flex items-center justify-center p-3 border-b lg:border-b-0 lg:border-r border-border/50">
<Link href={`/task/client-detail/${client.id}`} className="w-full h-full flex items-center justify-center">
<LazyImage
src={client.photo!}
src={client.photo || CLIENT_FALLBACK_IMAGE}
fallbackSrc={CLIENT_FALLBACK_IMAGE}
alt={client.name}
className="w-full h-full max-h-36 bg-transparent"
imgClassName="object-contain p-1 group-hover:scale-105 transition-transform duration-500"
@@ -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>
+25 -30
View File
@@ -3,48 +3,43 @@ export default function Loading() {
<div
className="flex-1 space-y-8 p-4 sm:p-8 pt-4 sm:pt-6"
role="status"
aria-label="Loading tasks and clients"
aria-label="Loading tasks"
>
{/* Top Page Header Skeleton */}
{/* Header: Title, Subtitle, and Controls */}
<div className="flex flex-col md:flex-row md:items-center justify-between gap-4">
<div>
<div className="h-8 w-56 animate-pulse rounded-lg bg-muted" />
<div className="mt-2 h-4 w-72 max-w-full animate-pulse rounded bg-muted" />
<div className="space-y-2">
<div className="h-8 w-56 sm:w-64 animate-pulse rounded-lg bg-muted" />
<div className="h-4 w-72 sm:w-96 animate-pulse rounded bg-muted" />
</div>
<div className="flex flex-col sm:flex-row items-stretch sm:items-center gap-2.5 sm:gap-3 w-full md:w-auto">
<div className="h-10 w-full sm:w-44 animate-pulse rounded-md bg-muted" />
<div className="h-10 w-full sm:w-32 animate-pulse rounded-md bg-muted" />
<div className="flex items-center gap-3">
<div className="h-10 w-36 sm:w-44 animate-pulse rounded-lg bg-muted" />
<div className="h-10 w-28 sm:w-32 animate-pulse rounded-lg bg-muted" />
</div>
</div>
{/* Filter and Layout Toolbar Skeleton */}
{/* Filter and Search Bar Skeleton */}
<div className="h-11 w-full animate-pulse rounded-xl border border-border bg-card" />
{/* Client Cards Grid Skeleton */}
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
{/* Content Cards Grid Skeleton */}
<div className="grid gap-4 sm:gap-6 md:grid-cols-2 lg:grid-cols-3">
{Array.from({ length: 6 }).map((_, i) => (
<div
key={i}
className="overflow-hidden rounded-xl border border-border/80 bg-card shadow-2xs"
>
{/* Image Banner Skeleton */}
<div className="h-40 border-b border-border/50 bg-muted/20 animate-pulse" />
{/* Card Content Skeleton */}
<div className="p-5 space-y-3">
<div className="flex items-center justify-between">
<div className="h-4 w-16 animate-pulse rounded bg-muted" />
<div className="h-4 w-14 animate-pulse rounded-full bg-muted" />
<div key={i} className="rounded-2xl border border-border bg-card p-5 space-y-4 shadow-2xs">
{/* Top: Avatar and Title */}
<div className="flex items-start gap-3.5">
<div className="h-12 w-12 shrink-0 animate-pulse rounded-xl bg-muted" />
<div className="min-w-0 flex-1 space-y-2">
<div className="h-5 w-3/4 animate-pulse rounded bg-muted" />
<div className="h-4 w-1/3 animate-pulse rounded bg-muted" />
</div>
</div>
<div className="h-5 w-44 animate-pulse rounded bg-muted" />
<div className="h-3.5 w-32 animate-pulse rounded bg-muted" />
{/* Mid preview strip */}
<div className="h-14 w-full animate-pulse rounded-xl border border-border/50 bg-muted/20" />
<div className="grid grid-cols-3 gap-2 border-t border-border/50 pt-3">
<div className="h-8 animate-pulse rounded bg-muted/20" />
<div className="h-8 animate-pulse rounded bg-muted/20" />
<div className="h-8 animate-pulse rounded bg-muted/20" />
</div>
{/* Bottom metrics row */}
<div className="flex items-center justify-between border-t border-border/60 pt-3">
<div className="h-4 w-28 animate-pulse rounded bg-muted" />
<div className="h-4 w-20 animate-pulse rounded bg-muted" />
</div>
</div>
))}
+3
View File
@@ -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
+49 -37
View File
@@ -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 (
<Badge
variant={STATUS_BADGE_MAP[lookupKey] || "default"}
className={cn("text-[10px] font-semibold tracking-wide px-2 py-0.5", className)}
>
{formatted}
</Badge>
);
}
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 (
<Badge
variant={STATUS_BADGE_MAP[lookupKey] || "default"}
className={cn("text-[10px] font-semibold tracking-wide px-2 py-0.5", className)}
>
{formatted}
</Badge>
);
}
+22 -6
View File
@@ -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<HTMLImageElement>(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 (
<div className={cn("relative overflow-hidden bg-secondary/50", className)}>
<img
ref={imgRef}
src={src}
src={currentSrc}
alt={alt}
loading="lazy"
referrerPolicy="no-referrer"
onLoad={() => setIsLoaded(true)}
onError={handleError}
className={cn(
"w-full h-full object-cover transition-all duration-700 ease-in-out",
imgClassName,
Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB