mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:56:28 +00:00
update
This commit is contained in:
@@ -43,6 +43,7 @@ export default function ClientDetailComponent({ clientId, assignmentLists }: Pro
|
||||
handleClose()
|
||||
}
|
||||
|
||||
console.log(assignmentLists)
|
||||
return (
|
||||
<>
|
||||
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-2">
|
||||
@@ -154,7 +155,7 @@ export default function ClientDetailComponent({ clientId, assignmentLists }: Pro
|
||||
<TooltipContent>
|
||||
<div className="text-xs">
|
||||
<p className="font-bold">{user?.user.fullname}</p>
|
||||
<p className="opacity-80">{user?.user.role?.name}</p>
|
||||
<p className="opacity-80">{user?.user.position?.name}</p>
|
||||
</div>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
@@ -284,7 +285,7 @@ export default function ClientDetailComponent({ clientId, assignmentLists }: Pro
|
||||
<TooltipContent>
|
||||
<div className="text-xs">
|
||||
<p className="font-bold">{user?.user.fullname}</p>
|
||||
<p className="opacity-80">{user?.user.role?.name}</p>
|
||||
<p className="opacity-80">{user?.user.position?.name}</p>
|
||||
</div>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
@@ -296,7 +297,9 @@ export default function ClientDetailComponent({ clientId, assignmentLists }: Pro
|
||||
+{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?.length === 0 &&
|
||||
<span className="text-[10px] text-muted-foreground italic">No team assigned</span>
|
||||
}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
|
||||
+7
-13
@@ -2,7 +2,7 @@
|
||||
"use client"
|
||||
|
||||
import { motion } from 'motion/react';
|
||||
import { ArrowLeft, Briefcase, Calendar, CheckCircle2, History, AlertCircle, UserPlus, ExternalLink, Mail, Phone } 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';
|
||||
@@ -17,8 +17,6 @@ import FormUpdateStatus from '../../../component/FormUpdateStatus';
|
||||
import BadgeStatus from '@/components/ui/badge-status';
|
||||
import Link from 'next/link';
|
||||
import ManageEmployee from '../../../component/ManageEmployee';
|
||||
import dayjs from 'dayjs';
|
||||
import { LazyImage } from '@/components/ui/lazy-image';
|
||||
import AssignedPeople from '../project-detail/[project_id]/AssignedPeople';
|
||||
|
||||
interface Props {
|
||||
@@ -63,23 +61,19 @@ 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-2">
|
||||
<Button variant="ghost" size="sm" onClick={() => router.back()}
|
||||
className="p-0 h-auto hover:bg-transparent text-muted-foreground mb-2"
|
||||
>
|
||||
<Button variant="ghost" size="sm" onClick={() => router.back()} className="p-0 h-auto hover:bg-transparent text-muted-foreground mb-2">
|
||||
<ArrowLeft className="w-4 h-4 mr-1" />
|
||||
Back to {client?.name}
|
||||
</Button>
|
||||
<div className="flex items-center gap-3">
|
||||
<h1 className="text-4xl font-bold tracking-tight">Assignment Detail</h1>
|
||||
<Badge variant={isProject ? 'default' : 'info'} className="text-lg px-3 py-0">
|
||||
{assignmentType}
|
||||
</Badge>
|
||||
<Badge variant={isProject ? 'default' : 'info'} className="text-lg px-3 py-0">{assignmentType}</Badge>
|
||||
</div>
|
||||
<div className="flex items-center gap-3 mt-2">
|
||||
{!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'>
|
||||
<Link href={`/task/client-detail/${client?.id}/project-detail/${assignment.project?.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" />
|
||||
@@ -98,7 +92,7 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-3">
|
||||
<Button variant="outline" onClick={() => setAction('UPDATE_STATUS')} className="gap-2">
|
||||
<Button onClick={() => setAction('UPDATE_STATUS')} className="gap-2">
|
||||
<History className="w-4 h-4" />
|
||||
Update Assignment Status
|
||||
</Button>
|
||||
@@ -181,7 +175,7 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
<div className="mt-6 pt-6 border-t">
|
||||
<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">
|
||||
<Button onClick={() => setAction('MANAGE_EMPLOYEE')} className="gap-2" size='sm'>
|
||||
<UserPlus className="w-4 h-4" />
|
||||
Manage Team
|
||||
</Button>
|
||||
@@ -202,7 +196,7 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
|
||||
<Card900>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<History className="w-5 h-5 text-primary" /> Assignment History
|
||||
<History className="w-5 h-5 text-primary" /> Assignment Timeline
|
||||
</CardTitle>
|
||||
<CardDescription>Timeline of status changes</CardDescription>
|
||||
</CardHeader>
|
||||
|
||||
+5
-3
@@ -18,7 +18,7 @@ const AssignedPeople = ({ people }: Props) => {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-6">
|
||||
{/* Stacked avatars */}
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex -space-x-3">
|
||||
@@ -45,12 +45,14 @@ const AssignedPeople = ({ people }: Props) => {
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-start gap-2 flex-wrap">
|
||||
<p className="text-sm font-semibold text-foreground truncate min-w-0">{user.user.fullname}</p>
|
||||
<Badge variant='violet'>{user.user.role?.name}</Badge>
|
||||
<Badge variant='violet'>{user.user.position?.name}</Badge>
|
||||
</div>
|
||||
<div className="flex flex-col sm:flex-row sm:items-center gap-1 sm:gap-3 mt-1 text-xs text-muted-foreground sm:flex-wrap min-w-0">
|
||||
<span className="inline-flex items-center gap-1 min-w-0">
|
||||
<Mail className="w-3 h-3 shrink-0" />
|
||||
<span className="truncate">{user.user.email}</span>
|
||||
<a href={`mailto:${user.user.email}`} referrerPolicy="no-referrer" className='hover:text-his duration-300'>
|
||||
<span className="truncate">{user.user.email}</span>
|
||||
</a>
|
||||
</span>
|
||||
<span className="inline-flex items-center gap-1">
|
||||
<Phone className="w-3 h-3 shrink-0" />
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ const StatusTimeline = ({ history }: StatusTimelineProps) => {
|
||||
<div className="space-y-5">
|
||||
{history.map((item, i) => {
|
||||
const { date, time } = formatDate(item.date_status_changed);
|
||||
const isLatest = i === history.length - 1;
|
||||
const isLatest = i === 0;
|
||||
|
||||
return (
|
||||
<div key={item.id} className="relative flex items-start gap-4 group">
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ const WorkOrderCard = ({ workOrder, index, defaultOpen = false }: WorkOrderCardP
|
||||
<div className="flex items-center gap-3 sm:gap-4">
|
||||
<History className="w-5 h-5" />
|
||||
<div>
|
||||
<h4 className="text-base font-bold text-foreground">Status History</h4>
|
||||
<h4 className="text-base font-bold text-foreground">Assignment Timeline</h4>
|
||||
<p className="text-muted-foreground">
|
||||
{workOrder.project_assignment_status_detail.length} status changes
|
||||
</p>
|
||||
|
||||
@@ -7,6 +7,8 @@ import BadgeStatus from '@/components/ui/badge-status';
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { IProjectAssignment } from '../type.assignment';
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
|
||||
import { LazyImage } from '@/components/ui/lazy-image';
|
||||
|
||||
export default function AssignmentTable({ data }: { data: IProjectAssignment[] }) {
|
||||
if (data.length === 0) {
|
||||
@@ -42,6 +44,7 @@ export default function AssignmentTable({ data }: { data: IProjectAssignment[] }
|
||||
<TableHead>WO End</TableHead>
|
||||
<TableHead>Last Status</TableHead>
|
||||
<TableHead>Status Remarks</TableHead>
|
||||
<TableHead>Team</TableHead>
|
||||
<TableHead className="w-[50px]"></TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
@@ -95,7 +98,34 @@ export default function AssignmentTable({ data }: { data: IProjectAssignment[] }
|
||||
<BadgeStatus status={assignment.project?.status || assignment.project_status.name} />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{assignment.project_assignment_status_detail[0].status_remarks}
|
||||
{assignment.project_assignment_status_detail[0]?.status_remarks}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="flex -space-x-2 overflow-hidden">
|
||||
{assignment.project_assignment_work_order_detail?.slice(0, 5).map((user, key) => {
|
||||
return (
|
||||
<div key={key}>
|
||||
<Tooltip>
|
||||
<TooltipTrigger>
|
||||
<LazyImage src={user?.user?.avatar ? `${process.env.BASE_URL_IMG}/${user?.user?.avatar}` : '/assets/no-avatar.jpg'} alt={user?.user?.fullname!} className="inline-block h-8 w-8 rounded-full border-2 border-background cursor-help hover:scale-110 hover:z-10 transition-transform" />
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p className="text-xs font-bold">{user?.user?.name}</p>
|
||||
<p className="text-[10px] opacity-80">{user?.user?.position?.name}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{assignment.project_assignment_work_order_detail?.length! > 5 &&
|
||||
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-accent ring-2 ring-background text-[10px] font-bold">
|
||||
+{assignment.project_assignment_work_order_detail?.length! - 5}
|
||||
</div>
|
||||
}
|
||||
{assignment.project_assignment_work_order_detail?.length === 0 &&
|
||||
<span className="text-[10px] text-muted-foreground italic">No team assigned</span>
|
||||
}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<DropdownMenu>
|
||||
|
||||
@@ -19,7 +19,7 @@ import { useRouter } from 'next/navigation';
|
||||
import FormClient from './FormClient';
|
||||
import { ConfirmDeleteWithInput } from '@/components/modal/ConfirmDeleteWithInput';
|
||||
|
||||
export default function ClientGrid({ clients, assignments }: { clients: IClient[], assignments: any[] }) {
|
||||
export default function ClientGrid({ clients }: { clients: IClient[] }) {
|
||||
const router = useRouter();
|
||||
const [action, setAction] = useState<'EDIT' | 'DELETE' | undefined>(undefined)
|
||||
const [selectedData, setShowSelectedData] = useState<IClient>()
|
||||
@@ -42,13 +42,10 @@ export default function ClientGrid({ clients, assignments }: { clients: IClient[
|
||||
<>
|
||||
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
|
||||
{clients.map((client, i) => {
|
||||
const clientAssignments = assignments.filter(a => a.clientId === client.id);
|
||||
const imCount = 0
|
||||
const projectCount = client.total_project;
|
||||
// const woCount = clientAssignments.reduce((acc, a) => acc + a.workOrders.length, 0);
|
||||
const woCount = client.total_work_order
|
||||
const assignedEmployeeIds = Array.from(new Set(clientAssignments.flatMap(a => a.assignedEmployees)));
|
||||
console.log(client)
|
||||
const userCount = client.total_user_assigned
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
@@ -106,7 +103,7 @@ export default function ClientGrid({ clients, assignments }: { clients: IClient[
|
||||
{woCount! > 0 && (
|
||||
<>
|
||||
A dedicated team of{" "}
|
||||
<span className="font-bold text-foreground">{assignedEmployeeIds.length} experts</span> is handling{" "}
|
||||
<span className="font-bold text-foreground">{userCount} experts</span> is handling{" "}
|
||||
<span className="font-bold text-foreground">{woCount} work order{woCount! > 1 ? 's' : ''}</span>{" "}to ensure successful delivery for <span className="italic">{client.end_user_name}</span>.
|
||||
</>
|
||||
)}
|
||||
@@ -123,27 +120,25 @@ export default function ClientGrid({ clients, assignments }: { clients: IClient[
|
||||
return (
|
||||
<div key={key}>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<LazyImage src={user?.avatar!} alt={user?.fullname!}
|
||||
className="inline-block h-8 w-8 rounded-full ring-2 ring-background object-cover"
|
||||
/>
|
||||
<TooltipTrigger>
|
||||
<LazyImage src={user?.avatar ? `${process.env.BASE_URL_IMG}/${user?.avatar}` : '/assets/no-avatar.jpg'} alt={user?.fullname!} className="inline-block h-8 w-8 rounded-full border-2 border-background cursor-help hover:scale-110 hover:z-10 transition-transform" />
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p className="text-xs font-bold">{user?.fullname}</p>
|
||||
<p className="text-[10px] opacity-80">{user?.role?.name}</p>
|
||||
<p className="text-xs font-bold">{user?.name}</p>
|
||||
<p className="text-[10px] opacity-80">{user?.position?.name}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{client.users?.length! > 5 && (
|
||||
{client.users?.length! > 5 &&
|
||||
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-accent ring-2 ring-background text-[10px] font-bold">
|
||||
+{client.users?.length! - 5}
|
||||
</div>
|
||||
)}
|
||||
{client.users?.length === 0 && (
|
||||
}
|
||||
{client.users?.length === 0 &&
|
||||
<span className="text-[10px] text-muted-foreground italic">No team assigned</span>
|
||||
)}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 self-end">
|
||||
|
||||
@@ -37,7 +37,7 @@ export default async function ClientsPage({ searchParams }: Props) {
|
||||
{/* Render the correct view based on the URL */}
|
||||
<Suspense fallback={<div className="animate-pulse h-96 bg-accent rounded-xl" />}>
|
||||
{view === 'grid' ?
|
||||
<ClientGrid clients={filteredClients} assignments={allAssignments} />
|
||||
<ClientGrid clients={filteredClients} />
|
||||
:
|
||||
<AssignmentTable data={filterAssignments} />
|
||||
}
|
||||
|
||||
@@ -36,4 +36,5 @@ export interface IUser {
|
||||
resign_date?: string
|
||||
resign_reason?: string
|
||||
post_company?: string
|
||||
name?: string
|
||||
}
|
||||
@@ -3,10 +3,7 @@ import { Badge, STATUS_BADGE_MAP } from "@/components/ui/badge"
|
||||
export default function BadgeStatus({ status, className }: { status: string, className?: string }) { // e.g. status = "UAT"
|
||||
return (
|
||||
<Badge variant={STATUS_BADGE_MAP[status?.toLowerCase()] || "default"} className={className}>
|
||||
{status?.toLowerCase()
|
||||
.split(' ')
|
||||
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
||||
.join(' ')}
|
||||
{status}
|
||||
</Badge>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user