mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:56:28 +00:00
Refactor project/assignment UI and timeline
Multiple UI adjustments across client/project/assignment views: fix client description copy, add project Year badge and adjust project card padding and description punctuation, move work-order/team section into its own card and update manage-team button, tweak AssignedPeople button label/styling, make StatusTimeline collapsible with animation (show current entry prominently and toggle historic entries), add padding and end-date fallback (N/A) to WorkOrderCard, and small ClientGrid markup/spacing cleanups. These changes improve layout consistency, UX for viewing details, and handle missing end dates more gracefully.
This commit is contained in:
@@ -56,7 +56,7 @@ export default async function ClientDetailPage({ params, searchParams }: Props)
|
||||
</Button>
|
||||
</Link>
|
||||
<h1 className="text-xl sm:text-4xl font-bold tracking-tight">{client.name}</h1>
|
||||
<p className="text-sm sm:text-lg text-muted-foreground">{client?.description || 'No description available for this client!'}</p>
|
||||
<p className="text-sm sm:text-lg text-muted-foreground">{client?.description || 'No description available for this client.'}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-3">
|
||||
|
||||
+30
-32
@@ -117,7 +117,7 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
</div>
|
||||
|
||||
{isProject && (
|
||||
<Card900 className="p-5 gap-5">
|
||||
<Card900 className="p-6 gap-5">
|
||||
<div className="flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-[0.18em] text-muted-foreground">
|
||||
<FileText className="h-3 w-3" /> Project context
|
||||
</div>
|
||||
@@ -127,50 +127,48 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
<Button size="icon" variant="secondary" className="h-5 w-5 rounded-full opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer duration-300">
|
||||
<ExternalLink className="w-4 h-4" />
|
||||
</Button>
|
||||
<span className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-muted text-muted-foreground">
|
||||
Year {assignment.project?.year}
|
||||
</span>
|
||||
</Link>
|
||||
</div>
|
||||
<div className="grid grid-cols-3 text-sm">
|
||||
{/* <span className="font-semibold text-foreground">{assignment.project?.name}</span> */}
|
||||
<div className="flex items-center gap-4 text-sm">
|
||||
<span className="text-muted-foreground"># Code: <span className="text-foreground/80">{assignment.project?.code}</span></span>
|
||||
<span className="text-muted-foreground flex items-center"><Calendar size={16} className='mr-1' /> Year: <span className="text-foreground/80"> {assignment.project?.year}</span></span>
|
||||
<span className="inline-flex items-center gap-1.5 text-muted-foreground">
|
||||
<CalendarRange size={16} />
|
||||
{formatDate(assignment.project?.start_date!)} → {`${assignment.project?.end_date ? formatDate(assignment.project.end_date) : 'N/A'}`}
|
||||
</span>
|
||||
</div>
|
||||
<p className='text-muted-foreground text-xs sm:text-sm'>{assignment.project?.description ?? 'No description available'}</p>
|
||||
<p className='text-muted-foreground text-xs sm:text-sm'>{assignment.project?.description ?? 'No description available.'}</p>
|
||||
</Card900>
|
||||
)}
|
||||
|
||||
{/* Work Orders Section */}
|
||||
<div className="space-y-4">
|
||||
{!assignment.wo_name ?
|
||||
<Card className="border-dashed bg-accent/10">
|
||||
<CardContent className="py-10 text-center text-muted-foreground">
|
||||
No work orders defined for this assignment.
|
||||
</CardContent>
|
||||
</Card>
|
||||
:
|
||||
<div className="grid gap-4">
|
||||
<Card900 className="overflow-hidden border-l-4 border-l-primary">
|
||||
<CardContent className="p-6 pt-4">
|
||||
<div className='flex items-center justify-between mb-6 sm:mb-8'>
|
||||
<div className="flex items-center gap-1.5 text-xs font-bold uppercase tracking-[0.18em] text-muted-foreground">
|
||||
<Users className="h-4 w-4" /> Team
|
||||
</div>
|
||||
<Button onClick={() => setAction('MANAGE_EMPLOYEE')} className="gap-2" size='sm'>
|
||||
<UserPlus className="w-4 h-4" />
|
||||
Manage Team
|
||||
</Button>
|
||||
</div>
|
||||
{!assignment.wo_name ?
|
||||
<Card className="border-dashed bg-accent/10">
|
||||
<CardContent className="py-10 text-center text-muted-foreground">
|
||||
No work orders defined for this assignment.
|
||||
</CardContent>
|
||||
</Card>
|
||||
: null
|
||||
}
|
||||
|
||||
<AssignedPeople people={assignment.project_assignment_work_order_detail} defaultOpen={false} />
|
||||
|
||||
</CardContent>
|
||||
</Card900>
|
||||
<Card900 className="overflow-hidden border-l-4 border-l-primary">
|
||||
<CardContent className="p-6 pt-2">
|
||||
<div className='flex items-center justify-between mb-6 sm:mb-8'>
|
||||
<div className="flex items-center gap-1.5 text-xs font-bold uppercase tracking-[0.18em] text-muted-foreground">
|
||||
<Users className="h-4 w-4" /> Team
|
||||
</div>
|
||||
<Button onClick={() => setAction('MANAGE_EMPLOYEE')} className="gap-2" size='sm'>
|
||||
<UserPlus className="w-4 h-4" />
|
||||
Manage Team
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<AssignedPeople people={assignment.project_assignment_work_order_detail} defaultOpen={false} />
|
||||
|
||||
</CardContent>
|
||||
</Card900>
|
||||
|
||||
</div>
|
||||
|
||||
{/* Right Column: Status History */}
|
||||
|
||||
+2
-2
@@ -43,8 +43,8 @@ const AssignedPeople = ({ people, defaultOpen = true }: Props) => {
|
||||
<p className="text-muted-foreground">assigned to this work order</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button onClick={() => setIsOpen(!isOpen)} variant='ghost' size='sm' className="ml-auto">
|
||||
<ChevronDown className={`w-4 h-4 mr-1 transition-transform ${isOpen ? 'rotate-180' : ''}`} /> {isOpen ? 'Hide' : 'View'} Team
|
||||
<Button onClick={() => setIsOpen(!isOpen)} variant='ghost' size='sm' className="ml-auto text-xs text-muted-foreground">
|
||||
<ChevronDown className={`w-4 h-4 mr-1 transition-transform ${isOpen ? 'rotate-180' : ''}`} /> {isOpen ? 'Hide' : 'View'} details
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
|
||||
+79
-31
@@ -1,55 +1,103 @@
|
||||
import { ProjectAssignmentStatusDetail } from '@/app/(dashboard)/task/type.assignment';
|
||||
import BadgeStatus from '@/components/ui/badge-status';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import dayjs from 'dayjs';
|
||||
import { Clock } from 'lucide-react';
|
||||
import { ChevronDown, Clock } from 'lucide-react';
|
||||
import { useState } from 'react';
|
||||
import { motion, AnimatePresence } from 'motion/react';
|
||||
|
||||
interface StatusTimelineProps {
|
||||
history: ProjectAssignmentStatusDetail[];
|
||||
defaultOpen?: boolean;
|
||||
}
|
||||
|
||||
const StatusTimeline = ({ history }: StatusTimelineProps) => {
|
||||
const StatusTimeline = ({ history, defaultOpen = true }: StatusTimelineProps) => {
|
||||
const [isOpen, setIsOpen] = useState(defaultOpen);
|
||||
|
||||
return (
|
||||
<div className="relative">
|
||||
{/* Vertical connector line */}
|
||||
<div className="absolute left-3.75 top-2 bottom-2 w-px bg-linear-to-b from-primary/40 via-border to-transparent" />
|
||||
|
||||
<div className="space-y-5">
|
||||
{history.map((item, i) => {
|
||||
const isLatest = i === 0;
|
||||
<div className='flex justify-between items-start mb-5'>
|
||||
<div className="relative flex items-start gap-4 group">
|
||||
{/* Dot */}
|
||||
<div className="relative z-10 shrink-0">
|
||||
<div className={`w-8 h-8 rounded-full flex items-center justify-center bg-linear-to-br from-zinc-700 to-zinc-500 dark:from-zinc-400 dark:to-zinc-600 ring-4 ring-background shadow-lg animate-pulse-slow `}>
|
||||
<div className="w-2 h-2 rounded-full bg-white" />
|
||||
</div>
|
||||
<div className={`absolute inset-0 rounded-full bg-linear-to-br from-his to-yellow-700 blur-md opacity-60 -z-10`} />
|
||||
</div>
|
||||
|
||||
return (
|
||||
<div key={item.id} className="relative flex items-start gap-4 group">
|
||||
{/* Dot */}
|
||||
<div className="relative z-10 shrink-0">
|
||||
<div className={`w-8 h-8 rounded-full flex items-center justify-center bg-linear-to-br from-zinc-700 to-zinc-500 dark:from-zinc-400 dark:to-zinc-600 ring-4 ring-background shadow-lg ${isLatest ? 'animate-pulse-slow' : ''}`}>
|
||||
<div className="w-2 h-2 rounded-full bg-white" />
|
||||
</div>
|
||||
{isLatest && <div className={`absolute inset-0 rounded-full bg-linear-to-br from-his to-yellow-700 blur-md opacity-60 -z-10`} />}
|
||||
</div>
|
||||
{/* Content */}
|
||||
<div className="flex-1 min-w-0 pb-1">
|
||||
<div className="flex flex-wrap items-center gap-2 mb-1">
|
||||
<BadgeStatus status={history[0]?.project_assignment_status.name} />
|
||||
<span className="text-xs font-bold uppercase tracking-wider text-primary">Current</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5 text-xs text-muted-foreground mb-1.5">
|
||||
<Clock className="w-3 h-3" />
|
||||
<span>{history[0]?.start_date ? dayjs(history[0]?.start_date).format('MMM D, YYYY') : ''}</span>
|
||||
<span className="opacity-70">-</span>
|
||||
<span className="font-mono">{history[0]?.end_date ? dayjs(history[0]?.end_date).format('MMM D, YYYY') : ''}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Content */}
|
||||
<div className="flex-1 min-w-0 pb-1">
|
||||
<div className="flex flex-wrap items-center gap-2 mb-1">
|
||||
<BadgeStatus status={item.project_assignment_status.name} />
|
||||
{isLatest && <span className="text-xs font-bold uppercase tracking-wider text-primary">Current</span>}
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5 text-xs text-muted-foreground mb-1.5">
|
||||
<Clock className="w-3 h-3" />
|
||||
<span>{item.start_date ? dayjs(item.start_date).format('MMM D, YYYY') : ''}</span>
|
||||
<span className="opacity-70">-</span>
|
||||
<span className="font-mono">{item.end_date ? dayjs(item.end_date).format('MMM D, YYYY') : ''}</span>
|
||||
</div>
|
||||
{/* {item.status_remarks &&
|
||||
<Button onClick={() => setIsOpen(!isOpen)} variant='ghost' size='sm' className="text-xs ml-auto text-muted-foreground">
|
||||
<ChevronDown className={`w-4 h-4 mr-1 transition-transform ${isOpen ? 'rotate-180' : ''}`} /> {isOpen ? 'Hide' : 'View'} details
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<AnimatePresence initial={false}>
|
||||
{isOpen && (
|
||||
<motion.div
|
||||
initial={{ height: 0, opacity: 0 }}
|
||||
animate={{ height: "auto", opacity: 1 }}
|
||||
exit={{ height: 0, opacity: 0 }}
|
||||
transition={{ duration: 0.3, ease: "easeInOut" }}
|
||||
className="overflow-hidden"
|
||||
>
|
||||
|
||||
<div className="space-y-5">
|
||||
{history.slice(1, history.length).map((item, i) => {
|
||||
// const isLatest = i === 0;
|
||||
|
||||
return (
|
||||
<div className="relative flex items-start gap-4 group">
|
||||
{/* Dot */}
|
||||
<div className="relative z-10 shrink-0">
|
||||
<div className={`w-8 h-8 rounded-full flex items-center justify-center bg-linear-to-br from-zinc-700 to-zinc-500 dark:from-zinc-400 dark:to-zinc-600 ring-4 ring-background shadow-lg`}>
|
||||
<div className="w-2 h-2 rounded-full bg-white" />
|
||||
</div>
|
||||
{/* {isLatest && <div className={`absolute inset-0 rounded-full bg-linear-to-br from-his to-yellow-700 blur-md opacity-60 -z-10`} />} */}
|
||||
</div>
|
||||
|
||||
{/* Content */}
|
||||
<div className="flex-1 min-w-0 pb-1">
|
||||
<div className="flex flex-wrap items-center gap-2 mb-1">
|
||||
<BadgeStatus status={item.project_assignment_status.name} />
|
||||
{/* {isLatest && <span className="text-xs font-bold uppercase tracking-wider text-primary">Current</span>} */}
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5 text-xs text-muted-foreground mb-1.5">
|
||||
<Clock className="w-3 h-3" />
|
||||
<span>{item.start_date ? dayjs(item.start_date).format('MMM D, YYYY') : ''}</span>
|
||||
<span className="opacity-70">-</span>
|
||||
<span className="font-mono">{item.end_date ? dayjs(item.end_date).format('MMM D, YYYY') : ''}</span>
|
||||
</div>
|
||||
{/* {item.status_remarks &&
|
||||
<p className="text-sm text-foreground/80 bg-muted/30 rounded-md px-3 py-2 border border-border/50">
|
||||
{item.status_remarks}
|
||||
</p>
|
||||
} */}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
+3
-5
@@ -34,7 +34,7 @@ const WorkOrderCard = ({ workOrder, index, defaultOpen = false }: WorkOrderCardP
|
||||
|
||||
return (
|
||||
<>
|
||||
<Card900 className="overflow-hidden border-border/60 bg-card/80 backdrop-blur-sm hover:shadow-xl transition-all text-sm border-l-4 border-l-primary">
|
||||
<Card900 className="overflow-hidden border-border/60 bg-card/80 backdrop-blur-sm hover:shadow-xl transition-all text-sm border-l-4 border-l-primary py-3">
|
||||
{/* Header (always visible) */}
|
||||
<div className="p-4 sm:p-6">
|
||||
<div className="flex items-start gap-3 sm:gap-4">
|
||||
@@ -60,7 +60,7 @@ const WorkOrderCard = ({ workOrder, index, defaultOpen = false }: WorkOrderCardP
|
||||
<span className="inline-flex items-center gap-1.5 min-w-0">
|
||||
<Calendar className="w-3 h-3 shrink-0" />
|
||||
<span className="truncate">
|
||||
{formatDate(workOrder.wo_start_date)} → {formatDate(workOrder.wo_end_date!)}
|
||||
{formatDate(workOrder.wo_start_date)} → {workOrder.wo_end_date ? formatDate(workOrder.wo_end_date!) : 'N/A'}
|
||||
</span>
|
||||
</span>
|
||||
<span className="inline-flex items-center gap-1.5">
|
||||
@@ -80,9 +80,7 @@ const WorkOrderCard = ({ workOrder, index, defaultOpen = false }: WorkOrderCardP
|
||||
|
||||
{/* Toggle button - full width on mobile */}
|
||||
<Button variant='secondary' size="sm" onClick={() => setIsOpen((v) => !v)} className="w-full sm:w-auto mt-4 sm:ml-16">
|
||||
<ChevronDown
|
||||
className={`w-4 h-4 mr-1 transition-transform ${isOpen ? 'rotate-180' : ''}`}
|
||||
/>
|
||||
<ChevronDown className={`w-4 h-4 mr-1 transition-transform ${isOpen ? 'rotate-180' : ''}`} />
|
||||
{isOpen ? 'Hide details' : 'View details'}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -115,7 +115,7 @@ export default async function ProjectDetailPage({ params, searchParams }: Props)
|
||||
</Button>
|
||||
</Link>
|
||||
|
||||
<Card900 className="relative overflow-hidden border-border/60 bg-card/80 backdrop-blur-sm">
|
||||
<Card900 className="relative overflow-hidden border-border/60 bg-card/80 backdrop-blur-sm py-3">
|
||||
{/* <div className="absolute inset-0 bg-linear-to-br from-primary/5 via-transparent to-violet-500/5" /> */}
|
||||
{/* <div className="absolute top-0 left-0 h-1 w-full bg-linear-to-r from-primary via-violet-500 to-emerald-500" /> */}
|
||||
|
||||
|
||||
@@ -80,9 +80,7 @@ export default function ClientGrid({ clients }: { clients: IClient[] }) {
|
||||
<HoverCardTrigger>
|
||||
<div className="group/pill flex items-center gap-2 bg-black/40 hover:bg-black/60 backdrop-blur-md border border-white/20 rounded-full py-1 px-3 transition-all duration-300 cursor-help hover:scale-105 active:scale-95 shadow-xl">
|
||||
<div className="relative flex items-center justify-center">
|
||||
{client.status_name.toLowerCase() === 'active' &&
|
||||
<span className="absolute inset-0 rounded-full bg-green-400 animate-ping opacity-40 scale-150" />
|
||||
}
|
||||
{client.status_name.toLowerCase() === 'active' && <span className="absolute inset-0 rounded-full bg-green-400 animate-ping opacity-40 scale-150" />}
|
||||
<div className={cn(
|
||||
"w-2.5 h-2.5 rounded-full ring-2 ring-black/40 relative z-10",
|
||||
client.status_name.toLowerCase() === 'active' ? 'bg-green-400' : 'bg-orange-400'
|
||||
@@ -97,7 +95,7 @@ export default function ClientGrid({ clients }: { clients: IClient[] }) {
|
||||
<HoverCardContent side="bottom" align='end' className="flex flex-col gap-0.5 text-sm">
|
||||
<div className="font-semibold">Status Summary</div>
|
||||
<div className="text-xs text-muted-foreground">This is status summary information from WO or IM related to this client.</div>
|
||||
<div className='flex flex-col mt-4 gap-2.5 text-xs'>
|
||||
<div className='flex flex-col mt-4 gap-3 text-xs'>
|
||||
{client.project_status_summary.map((item, key) =>
|
||||
<div className='flex justify-between items-center gap-2' key={key}>
|
||||
<BadgeStatus status={item.project_status} />
|
||||
|
||||
Reference in New Issue
Block a user