mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-06 22:26:27 +00:00
update UI
This commit is contained in:
@@ -94,106 +94,111 @@ export default function ClientDetailComponent({ clientId, initialAssignments }:
|
||||
|
||||
return (
|
||||
<motion.div key={assignment.id} initial={{ opacity: 0, y: 10 }} animate={{ opacity: 1, y: 0 }}>
|
||||
<Card900 key={assignment.id} className="group hover:border-primary/30 transition-all duration-300">
|
||||
<CardContent className="py-4">
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<div className="flex items-start gap-4">
|
||||
<div className={`w-12 h-12 rounded-xl flex items-center justify-center shrink-0 ${isProject ? 'bg-orange-500/10 text-orange-500' : 'bg-purple-500/10 text-purple-500'}`}>
|
||||
{isProject ? <Briefcase className="w-6 h-6" /> : <Clock className="w-6 h-6" />}
|
||||
</div>
|
||||
<div>
|
||||
{isProject ?
|
||||
<Link href={`/task/client-detail/${clientId}/project-detail/${assignment.project.id}`}>
|
||||
<div className="flex items-center gap-3 mb-1">
|
||||
<div className='flex items-center gap-0 group-hover:gap-3 duration-300'>
|
||||
<h3 className="font-bold text-xl group-hover:underline duration-300 group-hover:text-his">{assignmentName}</h3>
|
||||
<Button size="icon" variant="secondary" className="h-8 w-8 rounded-full opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer">
|
||||
<ExternalLink className="w-4 h-4" />
|
||||
</Button>
|
||||
<Link href={`${clientId}/${assignment.id}`}>
|
||||
<Card900 key={assignment.id} className="group hover:border-primary/30 transition-all duration-300">
|
||||
<CardContent className="py-4">
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<div className="flex items-start gap-4">
|
||||
<div className={`w-12 h-12 rounded-xl flex items-center justify-center shrink-0 ${isProject ? 'bg-orange-500/10 text-orange-500' : 'bg-purple-500/10 text-purple-500'}`}>
|
||||
{isProject ? <Briefcase className="w-6 h-6" /> : <Clock className="w-6 h-6" />}
|
||||
</div>
|
||||
<div>
|
||||
{isProject ?
|
||||
<Link href={`${clientId}/project-detail/${assignment.project.id}`} onClick={(e) => e.stopPropagation()}>
|
||||
<div className="flex items-center gap-3 mb-1">
|
||||
<div className='flex items-center gap-0 group-hover:gap-3 duration-300'>
|
||||
<h3 className="font-bold text-xl group-hover:underline duration-300 group-hover:text-his">{assignmentName}</h3>
|
||||
<Button size="icon" variant="secondary" className="h-8 w-8 rounded-full opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer">
|
||||
<ExternalLink className="w-4 h-4" />
|
||||
</Button>
|
||||
</div>
|
||||
<Badge variant={'default'}>{assignmentType}</Badge>
|
||||
<BadgeStatus status={assignmentStatus} />
|
||||
</div>
|
||||
<Badge variant={'default'}>{assignmentType}</Badge>
|
||||
</Link>
|
||||
:
|
||||
<div className="flex items-center gap-3 mb-1">
|
||||
<h3 className="font-bold text-xl">{assignmentName}</h3>
|
||||
<Badge variant={'info'}>{assignmentType}</Badge>
|
||||
<BadgeStatus status={assignmentStatus} />
|
||||
</div>
|
||||
</Link>
|
||||
:
|
||||
<div className="flex items-center gap-3 mb-1">
|
||||
<h3 className="font-bold text-xl">{assignmentName}</h3>
|
||||
<Badge variant={'info'}>{assignmentType}</Badge>
|
||||
<BadgeStatus status={assignmentStatus} />
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
{assignment.wo_code && (
|
||||
<p className="text-sm font-medium text-primary mb-1">
|
||||
WO: {assignment.wo_name}
|
||||
{assignment.wo_code && (
|
||||
<p className="text-sm font-medium text-primary mb-1">
|
||||
WO: {assignment.wo_name}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<p className="text-muted-foreground line-clamp-2 text-sm mb-4">
|
||||
{assignmentDesc}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<p className="text-muted-foreground line-clamp-2 text-sm mb-4">
|
||||
{assignmentDesc}
|
||||
</p>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-6 text-sm text-muted-foreground">
|
||||
<div className="flex items-center gap-2">
|
||||
<CalendarIcon className="w-4 h-4" />
|
||||
<span>
|
||||
{assignmentStartDate ? new Date(assignmentStartDate).toLocaleDateString() : 'N/A'} -
|
||||
{assignmentEndDate ? new Date(assignmentEndDate).toLocaleDateString() : 'N/A'}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Users className="w-4 h-4" />
|
||||
<div className="flex -space-x-2">
|
||||
{assignment?.users?.slice(0, 3).map(empId => {
|
||||
const emp = DUMMY_EMPLOYEES.find(e => e.id === empId);
|
||||
return (
|
||||
<div key={empId}>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<LazyImage src={emp?.avatar!} alt={emp?.name!} className="w-6 h-6 rounded-full border-2 border-background cursor-help" />
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<div className="text-xs">
|
||||
<p className="font-bold">{emp?.name}</p>
|
||||
<p className="opacity-80">{emp?.role}</p>
|
||||
</div>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<div className="flex flex-wrap items-center gap-6 text-sm text-muted-foreground">
|
||||
<div className="flex items-center gap-2">
|
||||
<CalendarIcon className="w-4 h-4" />
|
||||
<span>
|
||||
{assignmentStartDate ? new Date(assignmentStartDate).toLocaleDateString() : 'N/A'} -
|
||||
{assignmentEndDate ? new Date(assignmentEndDate).toLocaleDateString() : 'N/A'}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Users className="w-4 h-4" />
|
||||
<div className="flex -space-x-2">
|
||||
{assignment?.users?.slice(0, 3).map(empId => {
|
||||
const emp = DUMMY_EMPLOYEES.find(e => e.id === empId);
|
||||
return (
|
||||
<div key={empId}>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<LazyImage src={emp?.avatar!} alt={emp?.name!} className="w-6 h-6 rounded-full border-2 border-background cursor-help" />
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<div className="text-xs">
|
||||
<p className="font-bold">{emp?.name}</p>
|
||||
<p className="opacity-80">{emp?.role}</p>
|
||||
</div>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{assignment.project_assignment_work_order_detail?.length > 3 && (
|
||||
<div className="w-6 h-6 rounded-full bg-accent border-2 border-background flex items-center justify-center text-[10px] font-bold">
|
||||
+{assignment.project_assignment_work_order_detail?.length - 3}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{assignment.project_assignment_work_order_detail?.length > 3 && (
|
||||
<div className="w-6 h-6 rounded-full bg-accent border-2 border-background flex items-center justify-center text-[10px] font-bold">
|
||||
+{assignment.project_assignment_work_order_detail?.length - 3}
|
||||
</div>
|
||||
)}
|
||||
{assignment.project_assignment_work_order_detail && assignment.project_assignment_work_order_detail.length === 0 && <span>No employees assigned</span>}
|
||||
)}
|
||||
{assignment.project_assignment_work_order_detail && assignment.project_assignment_work_order_detail.length === 0 && <span>No employees assigned</span>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" size="icon">
|
||||
<MoreVertical className="w-5 h-5" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`/task/client-detail/${clientId}/${assignment.id}`}>View Assignment Details</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`${clientId}/project-detail/${assignment.project.id}`}>View Project Details</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`${clientId}/project-assignments?is_edit=true&assignment_id=${assignment.id}`}>Edit Assignment</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => { setSelectedData(assignment); setAction('MANAGE_EMPLOYEE') }}>Manage Employees</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => { setSelectedData(assignment); setAction('UPDATE_STATUS') }}>Update Assignment Status</DropdownMenuItem>
|
||||
<DropdownMenuItem className="text-destructive">Delete</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" size="icon">
|
||||
<MoreVertical className="w-5 h-5" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`/task/client-detail/${clientId}/${assignment.id}`}>View Details Assignment</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`/task/client-detail/${clientId}/project-assignments?is_edit=true&assignment_id=${assignment.id}`}>Edit Assignment</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => { setSelectedData(assignment); setAction('MANAGE_EMPLOYEE') }}>Manage Employees</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => { setSelectedData(assignment); setAction('UPDATE_STATUS') }}>Update Assignment Status</DropdownMenuItem>
|
||||
<DropdownMenuItem className="text-destructive">Delete</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card900>
|
||||
</CardContent>
|
||||
</Card900>
|
||||
</Link>
|
||||
</motion.div>
|
||||
)
|
||||
})}
|
||||
@@ -263,7 +268,7 @@ export default function ClientDetailComponent({ clientId, initialAssignments }:
|
||||
{assignment.wo_end_date ? new Date(assignment.wo_end_date).toLocaleDateString() : '-'}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<BadgeStatus status={assignment.status.name} />
|
||||
<BadgeStatus status={assignment.project.status || assignment.project_status.name} />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<DropdownMenu>
|
||||
@@ -274,13 +279,16 @@ export default function ClientDetailComponent({ clientId, initialAssignments }:
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`/task/client-detail/${clientId}/${assignment.id}`}>View Details</Link>
|
||||
<Link href={`${clientId}/${assignment.id}`}>View Assignment Details</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`/task/client-detail/${clientId}/project-assignments?is_edit=true&assignment_id=${assignment.id}`}>Edit Assignment</Link>
|
||||
<Link href={`${clientId}/project-detail/${assignment.project.id}`}>View Project Details</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => { setSelectedData(assignment); setAction('MANAGE_EMPLOYEE') }}>Manage Employees</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => { setSelectedData(assignment); setAction('UPDATE_STATUS') }}>Update Assignment Status</DropdownMenuItem>
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`${clientId}/project-assignments?is_edit=true&assignment_id=${assignment.id}`}>Edit Assignment</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => { setSelectedData(assignment); setAction('MANAGE_EMPLOYEE') }}>Add Team</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => { setSelectedData(assignment); setAction('UPDATE_STATUS') }}>Update Status</DropdownMenuItem>
|
||||
<DropdownMenuItem className="text-destructive">Delete</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
|
||||
+28
-17
@@ -2,7 +2,7 @@
|
||||
"use client"
|
||||
|
||||
import { motion } from 'motion/react';
|
||||
import { ArrowLeft, Briefcase, Calendar, CheckCircle2, History, AlertCircle } from 'lucide-react';
|
||||
import { ArrowLeft, Briefcase, Calendar, CheckCircle2, History, AlertCircle, UserPlus, ExternalLink } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent, CardHeader, CardTitle, CardDescription, Card900 } from '@/components/ui/card';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
@@ -15,6 +15,8 @@ import { IProjectAssignment } from '../../../type.assignment';
|
||||
import { useState } from 'react';
|
||||
import FormUpdateStatus from '../../../component/FormUpdateStatus';
|
||||
import BadgeStatus from '@/components/ui/badge-status';
|
||||
import Link from 'next/link';
|
||||
import ManageEmployee from '../../../component/ManageEmployee';
|
||||
|
||||
interface Props {
|
||||
client: IClient | undefined;
|
||||
@@ -22,7 +24,7 @@ interface Props {
|
||||
}
|
||||
|
||||
export default function AssignmentDetail({ client, initialAssignment: assignment }: Props) {
|
||||
const [action, setAction] = useState<'ASSIGNMENT' | 'WO' | undefined>()
|
||||
const [action, setAction] = useState<'MANAGE_EMPLOYEE' | 'UPDATE_STATUS' | undefined>()
|
||||
const [selectedData, setSelectedData] = useState<IProjectAssignment>()
|
||||
|
||||
const router = useRouter();
|
||||
@@ -57,7 +59,7 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
>
|
||||
{/* Header */}
|
||||
<div className="flex flex-col md:flex-row md:items-center justify-between gap-6">
|
||||
<div className="space-y-1">
|
||||
<div className="space-y-2">
|
||||
<Button variant="ghost" size="sm" onClick={() => router.back()}
|
||||
className="p-0 h-auto hover:bg-transparent text-muted-foreground mb-2"
|
||||
>
|
||||
@@ -71,7 +73,16 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
</Badge>
|
||||
</div>
|
||||
<div className="flex items-center gap-3 mt-2">
|
||||
<h2 className="text-xl font-medium text-muted-foreground">{assignmentName}</h2>
|
||||
{!isProject ?
|
||||
<h2 className="text-xl font-medium text-muted-foreground">{assignmentName}</h2>
|
||||
:
|
||||
<Link href={`/task/client-detail/${client?.id}/project-detail/${assignment.id}`} className='flex group gap-3'>
|
||||
<h2 className="text-xl font-medium text-muted-foreground group-hover:underline duration-300 hover:text-his">{assignmentName}</h2>
|
||||
<Button size="icon" variant="secondary" className="h-8 w-8 rounded-full opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer duration-300">
|
||||
<ExternalLink className="w-4 h-4" />
|
||||
</Button>
|
||||
</Link>
|
||||
}
|
||||
</div>
|
||||
<div className="flex items-center gap-4 text-muted-foreground">
|
||||
<p className="flex items-center gap-1">
|
||||
@@ -84,9 +95,9 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-3">
|
||||
<Button variant="outline" onClick={() => setAction('ASSIGNMENT')} className="gap-2">
|
||||
<Button variant="outline" onClick={() => setAction('UPDATE_STATUS')} className="gap-2">
|
||||
<History className="w-4 h-4" />
|
||||
Update {assignmentType} Status
|
||||
Update Assignment Status
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -150,7 +161,6 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
<div className="space-y-3 flex-1">
|
||||
<div className="flex items-center gap-3">
|
||||
<h3 className="text-xl font-bold">{assignment.wo_name}</h3>
|
||||
<BadgeStatus status={assignment.project_status.name} />
|
||||
</div>
|
||||
<p className="text-muted-foreground text-sm">{assignment.wo_description}</p>
|
||||
<div className="flex flex-wrap gap-4 text-xs text-muted-foreground">
|
||||
@@ -163,17 +173,18 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-start">
|
||||
<Button variant="outline" size="sm" onClick={() => setAction('WO')}>
|
||||
Update WO Status
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* WO Status History Mini-Timeline */}
|
||||
{assignment.project_assignment_status_detail && assignment.project_assignment_status_detail.length > 0 && (
|
||||
<div className="mt-6 pt-6 border-t">
|
||||
<p className="text-xs font-bold uppercase text-muted-foreground mb-4">Team</p>
|
||||
<div className='flex items-center justify-between'>
|
||||
<p className="text-xs font-bold uppercase text-muted-foreground mb-4">Team</p>
|
||||
<Button variant="outline" onClick={() => setAction('MANAGE_EMPLOYEE')} className="gap-2">
|
||||
<UserPlus className="w-4 h-4" />
|
||||
Add Team
|
||||
</Button>
|
||||
</div>
|
||||
<div className="space-y-4">
|
||||
{assignment.project_assignment_work_order_detail && assignment.project_assignment_work_order_detail.length === 0 && <span className='text-muted-foreground'>No employees assigned</span>}
|
||||
{assignment.project_assignment_work_order_detail.map((history) => (
|
||||
@@ -241,13 +252,13 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
</div>
|
||||
</motion.div>
|
||||
|
||||
{action === 'ASSIGNMENT' ?
|
||||
<FormUpdateStatus data={assignment} title={assignmentType} onCancel={handleClose} onSuccess={handleSuccess} />
|
||||
{action === 'UPDATE_STATUS' ?
|
||||
<FormUpdateStatus data={assignment} title={assignmentName} onCancel={handleClose} onSuccess={handleSuccess} />
|
||||
: null
|
||||
}
|
||||
|
||||
{action === 'WO' ?
|
||||
<FormUpdateStatus data={assignment} title={assignment.wo_name} onCancel={handleClose} onSuccess={handleSuccess} />
|
||||
{action === 'MANAGE_EMPLOYEE' ?
|
||||
<ManageEmployee data={assignment} title={assignment.wo_name} onCancel={handleClose} onSuccess={handleSuccess} />
|
||||
: null
|
||||
}
|
||||
</>
|
||||
|
||||
+3
-3
@@ -175,21 +175,21 @@ export default function CreateAssignmentForm({ client, clientId, projectList, is
|
||||
"im_name": assignmentType === 'IM' ? payload.name : isEdit ? existAssignment?.im_name : "",
|
||||
"im_year": assignmentType === 'IM' ? Number(payload.year) : isEdit ? existAssignment?.im_year : 2026,
|
||||
"im_start_date": assignmentType === 'IM' ? dayjs(payload.startDate).format('YYYY-MM-DD') : isEdit ? existAssignment?.im_start_date : "",
|
||||
"im_end_date": assignmentType === 'IM' ? dayjs(payload.endDate).format('YYYY-MM-DD') : isEdit ? existAssignment?.im_end_date : "",
|
||||
"im_end_date": assignmentType === 'IM' ? payload.endDate ? dayjs(payload.endDate).format('YYYY-MM-DD') : "" : isEdit ? existAssignment?.im_end_date : "",
|
||||
"im_description": assignmentType === 'IM' ? payload.description : isEdit ? existAssignment?.im_description : "",
|
||||
|
||||
"project_code": assignmentType === 'Project' ? payload.code : '',
|
||||
"project_name": assignmentType === 'Project' ? payload.name : '',
|
||||
"project_year": assignmentType === 'Project' ? Number(payload.year) : 2026,
|
||||
"project_start_date": assignmentType === 'Project' ? dayjs(payload.startDate).format('YYYY-MM-DD') : '',
|
||||
"project_end_date": assignmentType === 'Project' ? dayjs(payload.endDate).format('YYYY-MM-DD') : '',
|
||||
"project_end_date": assignmentType === 'Project' ? payload.endDate ? dayjs(payload.endDate).format('YYYY-MM-DD') : '' : '',
|
||||
"project_description": assignmentType === 'Project' ? payload.description : '',
|
||||
"project_status_id": isEdit ? existAssignment?.project_status.id : 1,
|
||||
|
||||
"wo_code": (payload.workOrder as any).code,
|
||||
"wo_name": (payload.workOrder as any).name,
|
||||
"wo_start_date": (payload.workOrder as any).startDate ? dayjs((payload.workOrder as any).startDate).format('YYYY-MM-DD') : '',
|
||||
"wo_end_date": (payload.workOrder as any).endDate ? dayjs((payload.workOrder as any).endDate).format('YYYY-MM-DD') : '',
|
||||
"wo_end_date": (payload.workOrder as any).endDate ? (payload.workOrder as any).endDate ? dayjs((payload.workOrder as any).endDate).format('YYYY-MM-DD') : '' : '',
|
||||
"wo_description": (payload.workOrder as any).description,
|
||||
"wo_warranty": isEdit ? existAssignment?.wo_warranty : '',
|
||||
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ const getInitials = (name: string) =>
|
||||
const AssignedPeople = ({ people }: AssignedPeopleProps) => {
|
||||
if (people.length === 0) {
|
||||
return (
|
||||
<div className="text-center py-8 text-sm text-muted-foreground bg-muted/20 rounded-lg border border-dashed border-border">
|
||||
<div className="text-center py-8 text-sm text-muted-foreground bg-muted/40 rounded-lg border border-dashed border-border">
|
||||
No people assigned yet
|
||||
</div>
|
||||
);
|
||||
@@ -50,7 +50,7 @@ const AssignedPeople = ({ people }: AssignedPeopleProps) => {
|
||||
</div>
|
||||
<div className="text-sm">
|
||||
<p className="font-semibold text-foreground">{people.length} People</p>
|
||||
<p className="text-xs text-muted-foreground">assigned to this work order</p>
|
||||
<p className="text-muted-foreground">assigned to this work order</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ const StatusTimeline = ({ history }: StatusTimelineProps) => {
|
||||
<div className="flex-1 min-w-0 pb-1">
|
||||
<div className="flex flex-wrap items-center gap-2 mb-1">
|
||||
<BadgeStatus status={item.status} />
|
||||
{isLatest && <span className="text-[10px] font-bold uppercase tracking-wider text-primary">Current</span>}
|
||||
{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" />
|
||||
|
||||
+12
-10
@@ -1,3 +1,5 @@
|
||||
"use client"
|
||||
|
||||
import { useState } from 'react';
|
||||
import { ChevronDown, Calendar, FileText, History, Users, StickyNote } from 'lucide-react';
|
||||
import { Card900 } from '@/components/ui/card';
|
||||
@@ -20,12 +22,12 @@ const WorkOrderCard = ({ workOrder, index, defaultOpen = false }: WorkOrderCardP
|
||||
new Date(date).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' });
|
||||
|
||||
return (
|
||||
<Card900 className="overflow-hidden border-border/60 bg-card/80 backdrop-blur-sm hover:shadow-xl transition-all">
|
||||
<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">
|
||||
{/* Header (always visible) */}
|
||||
<div className="p-4 sm:p-6">
|
||||
<div className="flex items-start gap-3 sm:gap-4">
|
||||
{/* Index badge */}
|
||||
<div className={`w-10 h-10 sm:w-12 sm:h-12 shrink-0 rounded-xl bg-primary text-primary flex items-center justify-center shadow-lg`}>
|
||||
<div className={`w-10 h-10 sm:w-12 sm:h-12 shrink-0 rounded-xl bg-zinc-500 text-primary flex items-center justify-center shadow-lg`}>
|
||||
<span className="text-sm sm:text-lg font-bold text-white">
|
||||
{String(index + 1).padStart(2, '0')}
|
||||
</span>
|
||||
@@ -38,7 +40,7 @@ const WorkOrderCard = ({ workOrder, index, defaultOpen = false }: WorkOrderCardP
|
||||
</h3>
|
||||
<BadgeStatus status={workOrder.project_status.name} />
|
||||
</div>
|
||||
<div className="flex flex-col sm:flex-row sm:items-center gap-1.5 sm:gap-3 text-xs text-muted-foreground sm:flex-wrap">
|
||||
<div className="flex flex-col sm:flex-row sm:items-center gap-1.5 sm:gap-3 text-muted-foreground sm:flex-wrap">
|
||||
<span className="inline-flex items-center gap-1.5 font-mono">
|
||||
<FileText className="w-3 h-3 shrink-0" />
|
||||
{workOrder.wo_code}
|
||||
@@ -80,7 +82,7 @@ const WorkOrderCard = ({ workOrder, index, defaultOpen = false }: WorkOrderCardP
|
||||
<div className="mb-6 flex items-start gap-3 p-3 rounded-lg bg-amber-500/5 border border-amber-500/20">
|
||||
<StickyNote className="w-4 h-4 text-amber-400 shrink-0 mt-0.5" />
|
||||
<div>
|
||||
<p className="text-xs font-semibold uppercase tracking-wider text-amber-400 mb-0.5">Note</p>
|
||||
<p className="font-semibold uppercase tracking-wider text-amber-400 mb-0.5">Note</p>
|
||||
<p className="text-sm text-foreground/90">{workOrder.note}</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -89,13 +91,13 @@ const WorkOrderCard = ({ workOrder, index, defaultOpen = false }: WorkOrderCardP
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
{/* Status history */}
|
||||
<div>
|
||||
<div className="flex items-center gap-2 mb-4">
|
||||
<div className="flex items-center gap-2 mb-6">
|
||||
<div className="w-8 h-8 rounded-lg bg-linear-to-br from-primary/20 to-primary/10 flex items-center justify-center ring-1 ring-primary/20">
|
||||
<History className="w-4 h-4 text-primary" />
|
||||
</div>
|
||||
<div>
|
||||
<h4 className="text-sm font-bold text-foreground">Status History</h4>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
<h4 className="text-base font-bold text-foreground">Status History</h4>
|
||||
<p className="text-muted-foreground">
|
||||
{workOrder.project_assignment_status_detail.length} status changes
|
||||
</p>
|
||||
</div>
|
||||
@@ -105,13 +107,13 @@ const WorkOrderCard = ({ workOrder, index, defaultOpen = false }: WorkOrderCardP
|
||||
|
||||
{/* Assigned people */}
|
||||
<div>
|
||||
<div className="flex items-center gap-2 mb-4">
|
||||
<div className="flex items-center gap-2 mb-6">
|
||||
<div className="w-8 h-8 rounded-lg bg-linear-to-br from-emerald-500/20 to-emerald-500/10 flex items-center justify-center ring-1 ring-emerald-500/20">
|
||||
<Users className="w-4 h-4 text-emerald-400" />
|
||||
</div>
|
||||
<div>
|
||||
<h4 className="text-sm font-bold text-foreground">Assigned People</h4>
|
||||
<p className="text-xs text-muted-foreground">Team members on this work order</p>
|
||||
<h4 className="text-base font-bold text-foreground">Assigned People</h4>
|
||||
<p className="text-muted-foreground">Team members on this work order</p>
|
||||
</div>
|
||||
</div>
|
||||
<AssignedPeople people={workOrder.project_assignment_work_order_detail} />
|
||||
|
||||
+193
-1
@@ -2,6 +2,14 @@ import { Button } from '@/components/ui/button';
|
||||
import Link from 'next/link';
|
||||
import fetchData from '@/lib/fetchData';
|
||||
import ProjectDetailComponent from './ProjectDetailComponent';
|
||||
import { ArrowLeft, Briefcase, Building2, Calendar, CheckCircle2, ClipboardList, Clock3, Hash, Users } from 'lucide-react';
|
||||
import { COMPLETE_STATUS_LIST, ONPROGRESS_STATUS_LIST } from '@/app/(dashboard)/task/type.assignment';
|
||||
import { motion } from 'motion/react';
|
||||
import { Card900 } from '@/components/ui/card';
|
||||
import WorkOrderCard from './WorkOrderCard';
|
||||
import { MotionDiv } from '@/components/ui/motion-wrapper';
|
||||
import { LazyImage } from '@/components/ui/lazy-image';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
|
||||
type Props = {
|
||||
params: Promise<{ client_id: string; project_id: string }>
|
||||
@@ -27,9 +35,193 @@ export default async function ProjectDetailPage({ params }: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
const formatDate = (date: string) =>
|
||||
new Date(date).toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' });
|
||||
|
||||
// Aggregate stats
|
||||
const totalWorkOrders = project.project_assignment.length;
|
||||
const completedWO = project.project_assignment.filter((wo: any) => COMPLETE_STATUS_LIST.includes(wo.project_status.name.toUpperCase())).length;
|
||||
const inProgressWO = project.project_assignment.filter((wo: any) => ONPROGRESS_STATUS_LIST.includes(wo.project_status.name.toUpperCase())).length;
|
||||
const totalAssigned = new Set(
|
||||
project.project_assignment.flatMap((wo: any) =>
|
||||
wo.project_assignment_work_order_detail.map((p: any) => p.id),
|
||||
),
|
||||
).size;
|
||||
|
||||
// Days remaining
|
||||
const today = new Date();
|
||||
const endDate = new Date(project.end_date);
|
||||
const daysRemaining = Math.ceil((endDate.getTime() - today.getTime()) / (1000 * 60 * 60 * 24));
|
||||
|
||||
const stats = [
|
||||
{
|
||||
label: 'Total Work Orders',
|
||||
value: totalWorkOrders,
|
||||
icon: ClipboardList,
|
||||
gradient: 'from-rose-500 to-red-600',
|
||||
glow: 'shadow-[0_0_30px_-5px_hsl(270_70%_60%/0.4)]',
|
||||
ring: 'ring-rose-500/20',
|
||||
},
|
||||
{
|
||||
label: 'In Progress',
|
||||
value: inProgressWO,
|
||||
icon: Clock3,
|
||||
gradient: 'from-sky-500 to-blue-600',
|
||||
glow: 'shadow-[0_0_30px_-5px_hsl(210_90%_55%/0.4)]',
|
||||
ring: 'ring-sky-500/20',
|
||||
},
|
||||
{
|
||||
label: 'Completed',
|
||||
value: completedWO,
|
||||
icon: CheckCircle2,
|
||||
gradient: 'from-emerald-500 to-green-600',
|
||||
glow: 'shadow-[0_0_30px_-5px_hsl(160_84%_45%/0.4)]',
|
||||
ring: 'ring-emerald-500/20',
|
||||
},
|
||||
{
|
||||
label: 'Team Members',
|
||||
value: totalAssigned,
|
||||
icon: Users,
|
||||
gradient: 'from-amber-500 to-orange-600',
|
||||
glow: 'shadow-[0_0_30px_-5px_hsl(38_95%_55%/0.4)]',
|
||||
ring: 'ring-amber-500/20',
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
// 4. Pass the fetched data to the interactive Client Component
|
||||
return (
|
||||
<ProjectDetailComponent client={client} project={project} />
|
||||
<>
|
||||
<MotionDiv
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
className="flex-1 p-6 sm:p-8 pt-6 space-y-12"
|
||||
>
|
||||
{/* Back link */}
|
||||
<Link href="..">
|
||||
<Button variant="ghost" size="sm" className="mb-4 -ml-2 text-muted-foreground hover:text-foreground">
|
||||
<ArrowLeft className="w-4 h-4 mr-1" />
|
||||
Back to {client?.name}
|
||||
</Button>
|
||||
</Link>
|
||||
|
||||
<Card900 className="relative overflow-hidden border-border/60 bg-card/80 backdrop-blur-sm">
|
||||
{/* <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" /> */}
|
||||
|
||||
<div className="relative p-6 sm:p-8">
|
||||
<div className="flex items-start justify-between gap-6 flex-wrap">
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2 mb-3 flex-wrap">
|
||||
<Badge>Project</Badge>
|
||||
<span className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-muted text-muted-foreground">
|
||||
Year {project.year}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<h1 className="text-3xl sm:text-4xl lg:text-5xl font-bold tracking-tight mb-2 bg-linear-to-r from-foreground via-foreground to-foreground/70 bg-clip-text">
|
||||
{project.name}
|
||||
</h1>
|
||||
|
||||
<div className="flex items-center gap-4 text-muted-foreground flex-wrap mb-5">
|
||||
<span className="inline-flex items-center gap-1.5 font-mono">
|
||||
<Hash className="w-3.5 h-3.5" />
|
||||
Code: {project.code}
|
||||
</span>
|
||||
<span className="inline-flex items-center gap-1.5">
|
||||
<Calendar className="w-3.5 h-3.5" />
|
||||
{formatDate(project.start_date)} → {formatDate(project.end_date)}
|
||||
</span>
|
||||
{daysRemaining > 0 && (
|
||||
<span className="inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-primary/10 text-primary ring-1 ring-primary/20 text-xs font-semibold">
|
||||
{daysRemaining} days remaining
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Client card */}
|
||||
<div className="inline-flex items-center gap-5 p-5 rounded-xl bg-muted/40 border border-border/60 backdrop-blur-sm">
|
||||
<div className="w-14 h-14 rounded-lg bg-linear-to-br from-primary to-his shadow-lg shrink-0">
|
||||
<LazyImage alt={client.name} src={client.photo} className='w-full h-full object-cover rounded-lg' />
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-[10px] uppercase tracking-wider text-muted-foreground font-semibold">
|
||||
Client
|
||||
</p>
|
||||
<p className="text-base font-bold text-foreground">{client?.name}</p>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
End user: {client?.end_user_name}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Description */}
|
||||
<div className="mt-6 pt-6 border-t border-border/60">
|
||||
<p className="text-xs uppercase tracking-wider font-semibold text-muted-foreground mb-2">
|
||||
Description
|
||||
</p>
|
||||
<p className="text-sm text-foreground/80 leading-relaxed max-w-3xl">
|
||||
{project.description ?? "No description available for this project."}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</Card900>
|
||||
|
||||
{/* Stats grid */}
|
||||
<div className="grid grid-cols-2 lg:grid-cols-4 gap-3 sm:gap-8">
|
||||
{stats.map((stat) => {
|
||||
const Icon = stat.icon;
|
||||
return (
|
||||
<Card900
|
||||
key={stat.label}
|
||||
className={`relative overflow-hidden border-border/60 bg-card/80 backdrop-blur-sm p-4 sm:p-5 hover:scale-[1.02] transition-transform ${stat.glow} ring-1 ${stat.ring}`}
|
||||
>
|
||||
<div className={`absolute -top-8 -right-8 w-24 h-24 rounded-full bg-linear-to-br ${stat.gradient} opacity-10 blur-2xl`} />
|
||||
<div className="relative flex items-center gap-3">
|
||||
<div
|
||||
className={`w-10 h-10 sm:w-12 sm:h-12 rounded-xl bg-linear-to-br ${stat.gradient} flex items-center justify-center shadow-lg shrink-0`}
|
||||
>
|
||||
<Icon className="w-5 h-5 sm:w-6 sm:h-6 text-white" />
|
||||
</div>
|
||||
<div className="min-w-0">
|
||||
<p className="text-[10px] uppercase tracking-wider text-muted-foreground font-semibold truncate">
|
||||
{stat.label}
|
||||
</p>
|
||||
<p className="text-2xl sm:text-3xl font-bold font-mono text-foreground">
|
||||
{stat.value}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</Card900>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* Work Orders section */}
|
||||
<div className="mb-4 flex items-center justify-between flex-wrap gap-3">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-10 h-10 rounded-xl bg-linear-to-br from-primary to-his flex items-center justify-center shadow-lg">
|
||||
<ClipboardList className="w-5 h-5 text-white" />
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="text-xl sm:text-2xl font-bold text-foreground">Work Orders</h2>
|
||||
<p className="text-muted-foreground">
|
||||
{totalWorkOrders} work order{totalWorkOrders !== 1 ? 's' : ''} in this project
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4">
|
||||
{project.project_assignment.map((wo: any, i: number) =>
|
||||
<WorkOrderCard key={wo.id} workOrder={wo} index={i} defaultOpen={i === 0} />
|
||||
)}
|
||||
</div>
|
||||
|
||||
</MotionDiv>
|
||||
{/* <ProjectDetailComponent client={client} project={project} /> */}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
export const STATUS_LIST = ["Not Started", "On Progress", "On Going", "Halted", "Issue", "SIT", "UAT", "PTR", "BAST", "Warranty", "End Of Support", "Canceled"]
|
||||
export const COMPLETE_STATUS_LIST = ['BAST', 'WARRANTY', 'END OF SUPPORT']
|
||||
export const ONPROGRESS_STATUS_LIST = ['ON PROGRESS', 'ON GOING', 'HALTED', 'ISSUE', 'SIT', 'UAT', 'PTR']
|
||||
|
||||
export interface IProjectAssignment {
|
||||
id: number
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// components/motion-wrapper.tsx
|
||||
"use client";
|
||||
|
||||
import { motion } from 'motion/react';
|
||||
import { ComponentProps } from 'react';
|
||||
|
||||
// This automatically extracts every possible prop that motion.div accepts,
|
||||
// including standard HTML div props (className, onClick, etc.)
|
||||
type MotionWrapperProps = ComponentProps<typeof motion.div>;
|
||||
|
||||
export function MotionDiv({ children, ...props }: MotionWrapperProps) {
|
||||
return (
|
||||
<motion.div {...props}>
|
||||
{children}
|
||||
</motion.div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user