mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:46:29 +00:00
Refactor task views with layout toggles
This commit reorganizes client and project-assignment screens into dedicated grid/list components, adds a shared layout toggle via the URL query string, and updates task pages to render the selected view consistently. It also moves shared client form logic into a client folder, improves status badge formatting, extends LazyImage with custom image classes, and updates the illustration assets and Lucide dependency used in the task UI.
This commit is contained in:
@@ -1,24 +1,19 @@
|
||||
"use client"
|
||||
"use client";
|
||||
|
||||
import { useState } from 'react';
|
||||
import { motion } from 'motion/react';
|
||||
import { Briefcase, Clock, Users, MoreVertical, Calendar as CalendarIcon, LayoutGrid, Table as TableIcon, ExternalLink } from 'lucide-react';
|
||||
import { Briefcase } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, Card900, CardContent } from '@/components/ui/card';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import Link from 'next/link';
|
||||
import { LazyImage } from '@/components/ui/lazy-image';
|
||||
import { IProjectAssignment } from '../../../type.assignment';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import BadgeStatus from '@/components/ui/badge-status';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import FilterComponent from '../../../component/FilterComponent';
|
||||
import { ConfirmDeleteWithInput } from '@/components/modal/ConfirmDeleteWithInput';
|
||||
import UpdateTimelineStatus from '../../../component/UpdateTimelineStatus';
|
||||
import { ManageTeam } from '../../../component/ManageTeam';
|
||||
import AssignmentGrid from '../../../component/project-assignment/AssignmentGrid';
|
||||
import AssignmentList from '../../../component/project-assignment/AssignmentList';
|
||||
|
||||
interface Props {
|
||||
clientId: string;
|
||||
@@ -26,45 +21,36 @@ interface Props {
|
||||
}
|
||||
|
||||
export default function ClientDetailComponent({ clientId, assignmentLists }: Props) {
|
||||
const [viewMode, setViewMode] = useState<'grid' | 'table'>('grid');
|
||||
const [action, setAction] = useState<'MANAGE_EMPLOYEE' | 'UPDATE_STATUS' | 'DELETE' | undefined>()
|
||||
const [selectedData, setSelectedData] = useState<IProjectAssignment>()
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const urlLayout = searchParams?.get('layout') as 'grid' | 'list' | null;
|
||||
|
||||
const router = useRouter()
|
||||
const [viewMode] = useState<'grid' | 'list'>(urlLayout || 'grid');
|
||||
const [action, setAction] = useState<'MANAGE_EMPLOYEE' | 'UPDATE_STATUS' | 'DELETE' | undefined>();
|
||||
const [selectedData, setSelectedData] = useState<IProjectAssignment>();
|
||||
|
||||
const activeLayout = urlLayout || viewMode;
|
||||
|
||||
// Call Server Action (this will automatically refresh the server data if you use revalidatePath in the action)
|
||||
const handleClose = () => {
|
||||
setSelectedData(undefined)
|
||||
setAction(undefined)
|
||||
}
|
||||
|
||||
const handleSuccess = () => {
|
||||
router.refresh()
|
||||
handleClose()
|
||||
}
|
||||
setSelectedData(undefined);
|
||||
setAction(undefined);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-2">
|
||||
<h2 className="text-2xl font-bold">Project Assignments</h2>
|
||||
<div className="flex items-center gap-4">
|
||||
<Tabs value={viewMode} onValueChange={(v) => setViewMode(v as 'grid' | 'table')}>
|
||||
<TabsList className="grid w-24 grid-cols-2">
|
||||
<TabsTrigger value="grid" className="p-1"><LayoutGrid className="w-4 h-4" /></TabsTrigger>
|
||||
<TabsTrigger value="table" className="p-1"><TableIcon className="w-4 h-4" /></TabsTrigger>
|
||||
</TabsList>
|
||||
</Tabs>
|
||||
<Badge variant="outline" className="px-3 py-1">
|
||||
{assignmentLists.length} Total
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<FilterComponent />
|
||||
<FilterComponent showLayoutToggle />
|
||||
|
||||
{/* --- EMPTY STATE --- */}
|
||||
{assignmentLists.length === 0 ?
|
||||
{assignmentLists.length === 0 ? (
|
||||
<Card className="border-dashed bg-accent/20">
|
||||
<CardContent className="flex flex-col items-center justify-center py-16 space-y-4">
|
||||
<div className="w-16 h-16 rounded-full bg-accent flex items-center justify-center">
|
||||
@@ -81,287 +67,68 @@ export default function ClientDetailComponent({ clientId, assignmentLists }: Pro
|
||||
</Link>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
: viewMode === 'grid' ?
|
||||
/* --- GRID VIEW --- */
|
||||
<div className="grid md:grid-cols-2 gap-8 auto-rows-fr h-full">
|
||||
{assignmentLists.map((assignment) => {
|
||||
const isProject = assignment.wo_name
|
||||
|
||||
const assignmentType = isProject ? 'Project' : 'IM'
|
||||
const assignmentName = assignment.wo_name || assignment.im_name
|
||||
const assignmentStartDate = assignment.wo_start_date || assignment.im_start_date
|
||||
const assignmentEndDate = assignment.wo_end_date || assignment.im_end_date
|
||||
const assignmentDesc = assignment.wo_description || assignment.im_description
|
||||
const assignmentStatus = assignment.project?.status || assignment.project_assignment_status?.name
|
||||
|
||||
return (
|
||||
<motion.div key={assignment.id} initial={{ opacity: 0, y: 10 }} animate={{ opacity: 1, y: 0 }} className="h-full">
|
||||
<Link href={`${clientId}/${assignment.id}`} className='h-full'>
|
||||
<Card900 key={assignment.id} className="h-full group hover:border-primary/30 transition-all duration-300 hover:scale-101">
|
||||
<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>
|
||||
<div className="flex flex-col sm:flex-row items-start sm:items-center gap-3 mb-1">
|
||||
<h3 className="font-bold text-xl">{assignmentName}</h3>
|
||||
{!isProject ? <Badge variant={'info'}>{assignmentType}</Badge> : null}
|
||||
{assignmentStatus ? <BadgeStatus status={assignmentStatus} /> : null}
|
||||
</div>
|
||||
|
||||
{assignment.wo_name &&
|
||||
<Link href={`${clientId}/project-detail/${assignment.project?.id}`} onClick={(e) => e.stopPropagation()}>
|
||||
<div className="flex flex-col sm:flex-row items-start sm:items-center gap-3 mb-1 group/in">
|
||||
<div className='flex items-center gap-0 group-hover/in:gap-3 duration-300'>
|
||||
<p className="text-sm font-medium text-primary mb-1 group-hover/in:underline group-hover/in:text-his duration-300">Project Name: {assignment.project?.name}</p>
|
||||
<Button size="icon" variant="secondary" className="h-8 w-8 rounded-full opacity-0 group-hover/in:opacity-100 transition-opacity cursor-pointer">
|
||||
<ExternalLink className="w-4 h-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
}
|
||||
|
||||
<p className="text-muted-foreground line-clamp-2 text-sm mb-4">{assignmentDesc}</p>
|
||||
|
||||
<div className="inline-flex flex-col sm:flex-row items-center gap-3 rounded-xl backdrop-blur-sm mb-3">
|
||||
<div className="h-20 sm:h-8 rounded-sm bg-linear-to-br from-primary to-his shadow-lg shrink-0 hidden sm:flex">
|
||||
<LazyImage alt={assignment.end_user.name} src={assignment.end_user.photo ? assignment.end_user.photo : '/assets/ilustration.png'} className='w-full h-full object-cover rounded-lg' />
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-[10px] tracking-wider text-muted-foreground font-semibold">End User</p>
|
||||
<p className="sm:text-base font-bold text-foreground">{assignment.end_user.name}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-3 sm: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?.project_assignment_work_order_detail?.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="w-7 h-7 rounded-full border-2 border-background cursor-help hover:scale-110 hover:z-10 transition-transform" />
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<div className="text-xs">
|
||||
<p className="font-bold">{user?.user.fullname}</p>
|
||||
<p className="opacity-80">{user?.user.position?.name}</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 && 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>
|
||||
{isProject ?
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`${clientId}/project-detail/${assignment.project?.id}`}>View Project Details</Link>
|
||||
</DropdownMenuItem> : null
|
||||
}
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`${clientId}/project-assignments?is_edit=true&assignment_id=${assignment.id}`}>Edit Assignment</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={(e) => e.stopPropagation()} onSelect={() => { setSelectedData(assignment); setAction('MANAGE_EMPLOYEE') }}>Manage Team</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={(e) => e.stopPropagation()} onSelect={() => { setSelectedData(assignment); setAction('UPDATE_STATUS') }}>Update Status</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={(e) => e.stopPropagation()} onSelect={() => { setSelectedData(assignment); setAction('DELETE') }} className="text-destructive">Delete</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card900>
|
||||
</Link>
|
||||
</motion.div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
|
||||
:
|
||||
/* --- TABLE VIEW --- */
|
||||
<Card className="overflow-hidden">
|
||||
<div className="overflow-x-auto">
|
||||
<Table>
|
||||
<TableHeader className="bg-accent/50">
|
||||
<TableRow>
|
||||
<TableHead className="min-w-25">End User</TableHead>
|
||||
<TableHead className="min-w-50">IM Name</TableHead>
|
||||
<TableHead>IM Code</TableHead>
|
||||
<TableHead className="min-w-50">Description</TableHead>
|
||||
<TableHead>IM Year</TableHead>
|
||||
<TableHead>IM Start</TableHead>
|
||||
<TableHead>IM End</TableHead>
|
||||
<TableHead className="min-w-50">Project Name</TableHead>
|
||||
<TableHead>Project Code</TableHead>
|
||||
<TableHead className="min-w-50">Description</TableHead>
|
||||
<TableHead>Year</TableHead>
|
||||
<TableHead>Proj Start</TableHead>
|
||||
<TableHead>Proj End</TableHead>
|
||||
<TableHead className="min-w-37.5">Work Order</TableHead>
|
||||
<TableHead>WO Code</TableHead>
|
||||
<TableHead>WO Start</TableHead>
|
||||
<TableHead>WO End</TableHead>
|
||||
<TableHead>Team</TableHead>
|
||||
<TableHead>Status</TableHead>
|
||||
<TableHead className="w-12.5"></TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{assignmentLists.map((assignment) => {
|
||||
return (
|
||||
<TableRow key={assignment.id}>
|
||||
<TableCell className="font-medium">{assignment.end_user?.name}</TableCell>
|
||||
<TableCell className="font-medium">{assignment.im_name}</TableCell>
|
||||
<TableCell>{assignment.im_code || ''}</TableCell>
|
||||
<TableCell className="max-w-75 truncate" title={assignment.im_description}>
|
||||
{assignment.im_description}
|
||||
</TableCell>
|
||||
<TableCell>{assignment.im_year || ''}</TableCell>
|
||||
<TableCell className="whitespace-nowrap">
|
||||
{assignment.im_start_date ? new Date(assignment.im_start_date).toLocaleDateString() : ''}
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap">
|
||||
{assignment.im_end_date ? new Date(assignment.im_end_date).toLocaleDateString() : ''}
|
||||
</TableCell>
|
||||
<TableCell className="font-medium">
|
||||
<Link href={`${clientId}/project-detail/${assignment.project?.id}`} className='text-blue-500 hover:text-his duration-300'>
|
||||
{assignment.project?.name}
|
||||
</Link>
|
||||
</TableCell>
|
||||
<TableCell>{assignment.project?.code || ''}</TableCell>
|
||||
<TableCell className="max-w-75 truncate" title={assignment.project?.description}>
|
||||
{assignment.project?.description}
|
||||
</TableCell>
|
||||
<TableCell>{assignment.project?.year || ''}</TableCell>
|
||||
<TableCell className="whitespace-nowrap">
|
||||
{assignment.project?.start_date ? new Date(assignment.project?.start_date).toLocaleDateString() : ''}
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap">
|
||||
{assignment.project?.end_date ? new Date(assignment.project?.end_date).toLocaleDateString() : ''}
|
||||
</TableCell>
|
||||
<TableCell>{assignment.wo_name || ''}</TableCell>
|
||||
<TableCell>{assignment.wo_code || ''}</TableCell>
|
||||
<TableCell className="whitespace-nowrap">
|
||||
{assignment.wo_start_date ? new Date(assignment.wo_start_date).toLocaleDateString() : ''}
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap">
|
||||
{assignment.wo_end_date ? new Date(assignment.wo_end_date).toLocaleDateString() : ''}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="flex -space-x-2">
|
||||
{assignment?.project_assignment_work_order_detail?.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="w-6 h-6 rounded-full border-2 border-background cursor-help hover:scale-110 hover:z-10 transition-transform" />
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<div className="text-xs">
|
||||
<p className="font-bold">{user?.user.fullname}</p>
|
||||
<p className="opacity-80">{user?.user.position?.name}</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 === 0 &&
|
||||
<span className="text-[10px] text-muted-foreground italic">No team assigned</span>
|
||||
}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<BadgeStatus status={assignment.project?.status || assignment.project_assignment_status?.name} />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" size="icon" className="h-8 w-8">
|
||||
<MoreVertical className="w-4 h-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`${clientId}/${assignment.id}`}>View Assignment Details</Link>
|
||||
</DropdownMenuItem>
|
||||
{assignment.project?.code ?
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`${clientId}/project-detail/${assignment.project?.id}`}>View Project Details</Link>
|
||||
</DropdownMenuItem>
|
||||
:
|
||||
null
|
||||
}
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`${clientId}/project-assignments?is_edit=true&assignment_id=${assignment.id}`}>Edit Assignment</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={(e) => e.stopPropagation()} onSelect={() => { setSelectedData(assignment); setAction('MANAGE_EMPLOYEE') }}>Manage Team</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={(e) => e.stopPropagation()} onSelect={() => { setSelectedData(assignment); setAction('UPDATE_STATUS') }}>Update Status</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={(e) => e.stopPropagation()} onSelect={() => { setSelectedData(assignment); setAction('DELETE') }} className="text-destructive">Delete</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
})}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
</Card>
|
||||
}
|
||||
|
||||
{action === 'MANAGE_EMPLOYEE' ?
|
||||
<ManageTeam assignmentId={selectedData?.id!} onClose={handleClose}
|
||||
startDate={selectedData?.wo_start_date || selectedData?.im_start_date} endDate={selectedData?.wo_end_date || selectedData?.im_end_date}
|
||||
) : activeLayout === 'grid' ? (
|
||||
<AssignmentGrid
|
||||
assignments={assignmentLists}
|
||||
clientId={clientId}
|
||||
onManageTeam={(a) => {
|
||||
setSelectedData(a);
|
||||
setAction('MANAGE_EMPLOYEE');
|
||||
}}
|
||||
onUpdateStatus={(a) => {
|
||||
setSelectedData(a);
|
||||
setAction('UPDATE_STATUS');
|
||||
}}
|
||||
onDelete={(a) => {
|
||||
setSelectedData(a);
|
||||
setAction('DELETE');
|
||||
}}
|
||||
/>
|
||||
: null
|
||||
}
|
||||
) : (
|
||||
<AssignmentList
|
||||
assignments={assignmentLists}
|
||||
clientId={clientId}
|
||||
onManageTeam={(a) => {
|
||||
setSelectedData(a);
|
||||
setAction('MANAGE_EMPLOYEE');
|
||||
}}
|
||||
onUpdateStatus={(a) => {
|
||||
setSelectedData(a);
|
||||
setAction('UPDATE_STATUS');
|
||||
}}
|
||||
onDelete={(a) => {
|
||||
setSelectedData(a);
|
||||
setAction('DELETE');
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{action === 'UPDATE_STATUS' ?
|
||||
<UpdateTimelineStatus assignmentId={selectedData?.id!} onClose={handleClose} />
|
||||
: null
|
||||
}
|
||||
{action === 'MANAGE_EMPLOYEE' && selectedData ? (
|
||||
<ManageTeam
|
||||
assignmentId={selectedData.id}
|
||||
onClose={handleClose}
|
||||
startDate={selectedData.wo_start_date || selectedData.im_start_date}
|
||||
endDate={selectedData.wo_end_date || selectedData.im_end_date}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{action === 'DELETE' ? <ConfirmDeleteWithInput endpoint={`/project-assignment/${selectedData?.id}`} onCancel={handleClose} onSuccess={() => { router.refresh(); handleClose() }}
|
||||
title={selectedData?.project?.name || selectedData?.im_name!} description={`This action cannot be undone. This will permanently delete and remove project assignment ${selectedData?.project?.name || selectedData?.im_name!} from our servers.`}
|
||||
titleButton={`I understand the consequences, delete this assignment`}
|
||||
/> : null}
|
||||
{action === 'UPDATE_STATUS' && selectedData ? (
|
||||
<UpdateTimelineStatus assignmentId={selectedData.id} onClose={handleClose} />
|
||||
) : null}
|
||||
|
||||
{action === 'DELETE' && selectedData ? (
|
||||
<ConfirmDeleteWithInput
|
||||
endpoint={`/project-assignment/${selectedData.id}`}
|
||||
onCancel={handleClose}
|
||||
onSuccess={() => {
|
||||
router.refresh();
|
||||
handleClose();
|
||||
}}
|
||||
title={selectedData.project?.name || selectedData.im_name || 'Project Assignment'}
|
||||
description={`This action cannot be undone. This will permanently delete and remove project assignment ${selectedData.project?.name || selectedData.im_name || ''} from our servers.`}
|
||||
titleButton="I understand the consequences, delete this assignment"
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
+1
-1
@@ -35,7 +35,7 @@ import { ComboboxCustomUI } from '@/components/ui/combobox-custom-ui';
|
||||
import { LazyImage } from '@/components/ui/lazy-image';
|
||||
import FormEndUser from '../../../component/FormEndUser';
|
||||
import { IProject } from '../../../type.project';
|
||||
import FormClient from '../../../component/FormClient';
|
||||
import FormClient from '../../../component/client/FormClient';
|
||||
|
||||
type IStep = 'type' | 'clients' | 'details' | 'work-orders' | 'review';
|
||||
|
||||
|
||||
@@ -1,164 +0,0 @@
|
||||
// app/clients/components/assignment-table.tsx
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table';
|
||||
import Link from 'next/link';
|
||||
import { BookOpenCheck, MoreVertical } from 'lucide-react';
|
||||
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) {
|
||||
return <Card className="py-12 text-center border-2 border-dashed rounded-xl">
|
||||
<BookOpenCheck className="w-12 h-12 mx-auto text-muted-foreground opacity-20" />
|
||||
<div className="text-center">
|
||||
<h3 className="text-xl font-semibold">No Project Assignment Found</h3>
|
||||
<p className="text-muted-foreground max-w-sm mx-auto mt-2">
|
||||
Try to change the filter or create one to get started.
|
||||
</p>
|
||||
</div>
|
||||
</Card>
|
||||
}
|
||||
|
||||
return (
|
||||
<Card className="overflow-hidden">
|
||||
<div className="overflow-x-auto">
|
||||
<Table>
|
||||
<TableHeader className="bg-accent/50">
|
||||
<TableRow>
|
||||
<TableHead className="min-w-37.5">Client</TableHead>
|
||||
<TableHead className="min-w-30">End User</TableHead>
|
||||
<TableHead className="min-w-50">IM Name</TableHead>
|
||||
<TableHead>IM Code</TableHead>
|
||||
<TableHead className="min-w-50">Description</TableHead>
|
||||
<TableHead>IM Year</TableHead>
|
||||
<TableHead>IM Start</TableHead>
|
||||
<TableHead>IM End</TableHead>
|
||||
<TableHead className="min-w-50">Project Name</TableHead>
|
||||
<TableHead>Project Code</TableHead>
|
||||
<TableHead className="min-w-50">Description</TableHead>
|
||||
<TableHead>Year</TableHead>
|
||||
<TableHead>Proj Start</TableHead>
|
||||
<TableHead>Proj End</TableHead>
|
||||
<TableHead className="min-w-37.5">Work Order</TableHead>
|
||||
<TableHead>WO Code</TableHead>
|
||||
<TableHead>WO Start</TableHead>
|
||||
<TableHead>WO End</TableHead>
|
||||
<TableHead>Last Status</TableHead>
|
||||
<TableHead>Status Remarks</TableHead>
|
||||
<TableHead>Team</TableHead>
|
||||
<TableHead className="w-12.5"></TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{data.map((assignment, idx) => {
|
||||
return (
|
||||
<TableRow key={idx} className="hover:bg-accent/30">
|
||||
<TableCell className="font-medium">
|
||||
<Link href={`/task/client-detail/${assignment.client.id}`} className="hover:underline text-blue-500 hover:text-his">
|
||||
{assignment.client?.name}
|
||||
</Link>
|
||||
</TableCell>
|
||||
<TableCell className="font-bold text-primary">{assignment.end_user.name}</TableCell>
|
||||
<TableCell className="font-medium">{assignment.im_name}</TableCell>
|
||||
<TableCell>{assignment.im_code || ''}</TableCell>
|
||||
<TableCell className="max-w-74 truncate" title={assignment.im_description}>
|
||||
{assignment.im_description}
|
||||
</TableCell>
|
||||
<TableCell>{assignment.im_year || ''}</TableCell>
|
||||
<TableCell className="whitespace-nowrap">
|
||||
{assignment.im_start_date ? new Date(assignment.im_start_date).toLocaleDateString() : ''}
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap">
|
||||
{assignment.im_end_date ? new Date(assignment.im_end_date).toLocaleDateString() : ''}
|
||||
</TableCell>
|
||||
<TableCell className="font-medium">
|
||||
<Link href={`/task/client-detail/${assignment.client?.id}/project-detail/${assignment.project?.id}`} className='text-blue-500 hover:text-his duration-300'>
|
||||
{assignment.project?.name}
|
||||
</Link>
|
||||
</TableCell>
|
||||
<TableCell>{assignment.project?.code || ''}</TableCell>
|
||||
<TableCell className="max-w-75 truncate" title={assignment.project?.description}>
|
||||
{assignment.project?.description}
|
||||
</TableCell>
|
||||
<TableCell>{assignment.project?.year || ''}</TableCell>
|
||||
<TableCell className="whitespace-nowrap">
|
||||
{assignment.project?.start_date ? new Date(assignment.project?.start_date).toLocaleDateString() : ''}
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap">
|
||||
{assignment.project?.end_date ? new Date(assignment.project?.end_date).toLocaleDateString() : ''}
|
||||
</TableCell>
|
||||
<TableCell>{assignment.wo_name || ''}</TableCell>
|
||||
<TableCell>{assignment.wo_code || ''}</TableCell>
|
||||
<TableCell className="whitespace-nowrap">
|
||||
{assignment.wo_start_date ? new Date(assignment.wo_start_date).toLocaleDateString() : ''}
|
||||
</TableCell>
|
||||
<TableCell className="whitespace-nowrap">
|
||||
{assignment.wo_end_date ? new Date(assignment.wo_end_date).toLocaleDateString() : ''}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<BadgeStatus status={assignment.project?.status || assignment.project_assignment_status?.name} />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{assignment.note ? <span className="text-sm text-muted-foreground italic max-w-xs truncate" title={assignment.note}>{assignment.note}</span> : ''}
|
||||
</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?.fullname}</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>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" size="icon" className="h-8 w-8">
|
||||
<MoreVertical className="w-4 h-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`/task/client-detail/${assignment.client?.id}/${assignment.id}`}>View Assignment Details</Link>
|
||||
</DropdownMenuItem>
|
||||
{assignment.project?.name ?
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`/task/client-detail/${assignment.client?.id}/project-detail/${assignment.project?.id}`}>View Project Details</Link>
|
||||
</DropdownMenuItem>
|
||||
:
|
||||
null
|
||||
}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
})}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -1,226 +0,0 @@
|
||||
// app/clients/components/client-grid.tsx
|
||||
"use client" // Keep as client component if using motion/react animations
|
||||
|
||||
import { motion } from 'motion/react';
|
||||
import { Card, Card900, CardContent } from '@/components/ui/card';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { ExternalLink, MoreHorizontal, Users } from 'lucide-react';
|
||||
import Link from 'next/link';
|
||||
import { LazyImage } from '@/components/ui/lazy-image';
|
||||
import {
|
||||
DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Tooltip, TooltipContent, TooltipTrigger,
|
||||
} from '@/components/ui/tooltip';
|
||||
import { IClient } from '../types';
|
||||
import { useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import FormClient from './FormClient';
|
||||
import { ConfirmDeleteWithInput } from '@/components/modal/ConfirmDeleteWithInput';
|
||||
import {
|
||||
HoverCard, HoverCardContent, HoverCardTrigger,
|
||||
} from "@/components/ui/hover-card"
|
||||
import { cn } from '@/lib/utils';
|
||||
import BadgeStatus from '@/components/ui/badge-status';
|
||||
|
||||
export default function ClientGrid({ clients }: { clients: IClient[] }) {
|
||||
const router = useRouter();
|
||||
const [action, setAction] = useState<'EDIT' | 'DELETE' | undefined>(undefined)
|
||||
const [selectedData, setShowSelectedData] = useState<IClient>()
|
||||
|
||||
const handleClose = () => {
|
||||
setAction(undefined)
|
||||
setShowSelectedData(undefined)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{clients.length === 0 ?
|
||||
<div className="py-12 text-center border-2 border-dashed rounded-xl">
|
||||
<Users className="w-12 h-12 mx-auto text-muted-foreground mb-4 opacity-20" />
|
||||
<div className="text-center">
|
||||
<h3 className="text-xl font-semibold">No Client Found</h3>
|
||||
<p className="text-muted-foreground max-w-sm mx-auto mt-2">
|
||||
Try to change the filter or create one to get started.
|
||||
</p>
|
||||
<Button variant="outline" className="mt-4" onClick={() => { setAction('EDIT'); setShowSelectedData(undefined) }}>Create New Client</Button>
|
||||
</div>
|
||||
</div> : null
|
||||
}
|
||||
|
||||
{clients.length > 0 ?
|
||||
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
|
||||
{clients.map((client, i) => {
|
||||
const imCount = 0
|
||||
const projectCount = client.total_project;
|
||||
const woCount = client.total_work_order
|
||||
const userCount = client.total_user_assigned
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
key={client.id}
|
||||
initial={{ opacity: 0, scale: 0.95 }}
|
||||
animate={{ opacity: 1, scale: 1 }}
|
||||
transition={{ delay: i * 0.05 }}
|
||||
className="h-full"
|
||||
>
|
||||
<Link href={`/task/client-detail/${client.id}`} className="h-full">
|
||||
<Card900 className="h-full group overflow-hidden hover:shadow-lg transition-all duration-300 border-primary/5 hover:border-primary/20 flex flex-col py-0">
|
||||
<CardContent className="p-0 flex flex-col h-full">
|
||||
<div className="relative h-32 bg-accent/50 overflow-hidden">
|
||||
<LazyImage
|
||||
src={client.photo!}
|
||||
alt={client.name}
|
||||
className="w-full h-full object-cover group-hover:scale-110 transition-transform duration-500"
|
||||
/>
|
||||
<div className="absolute inset-0 bg-linear-to-t from-black/80 via-black/40 to-transparent" />
|
||||
<div className="absolute top-3 right-3 z-20">
|
||||
<HoverCard openDelay={10} closeDelay={100}>
|
||||
<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" />}
|
||||
<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'
|
||||
)} />
|
||||
</div>
|
||||
<span className="text-[10px] font-black text-white/90 uppercase tracking-widest whitespace-nowrap">
|
||||
{client.status_name}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</HoverCardTrigger>
|
||||
<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-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} />
|
||||
<div className='font-bold'>{item.total}</div>
|
||||
</div>
|
||||
)}
|
||||
<div></div>
|
||||
</div>
|
||||
</HoverCardContent>
|
||||
</HoverCard>
|
||||
</div>
|
||||
<div className="absolute bottom-4 left-4 right-4 flex items-end justify-between">
|
||||
<div className="text-white">
|
||||
<h3 className="font-bold text-lg leading-tight">{client.name}</h3>
|
||||
{/* <p className="text-xs opacity-80">{client.end_user_name}</p> */}
|
||||
</div>
|
||||
<Link href={`/task/client-detail/${client.id}`}>
|
||||
<Button size="icon" variant="secondary" className="h-8 w-8 rounded-full opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
<ExternalLink className="w-4 h-4" />
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
<div className="p-5 flex flex-col flex-1 justify-between gap-4">
|
||||
<div className="space-y-2">
|
||||
{/* <p className="text-sm leading-relaxed text-muted-foreground line-clamp-3 h-16">
|
||||
Currently managing a portfolio of <span className="font-bold text-foreground">{projectCount} projects</span> and <span className="font-bold text-foreground">{imCount} internal memos</span>.
|
||||
A dedicated team of <span className="font-bold text-foreground">{assignedEmployeeIds.length} experts</span> is handling <span className="font-bold text-foreground">{woCount} work orders</span> to ensure successful delivery for <span className="italic">{client.endUser}</span>.
|
||||
</p> */}
|
||||
<p className="text-sm leading-relaxed text-muted-foreground line-clamp-3 h-16">
|
||||
{projectCount === 0 && imCount === 0 && woCount === 0 ?
|
||||
"No active projects, internal memos, or work orders recorded for this client yet."
|
||||
:
|
||||
<>
|
||||
{(projectCount! > 0 || imCount > 0) && (
|
||||
<>
|
||||
Currently managing a portfolio of{" "}
|
||||
{projectCount! > 0 &&
|
||||
<span className="font-bold text-foreground">{projectCount} project{projectCount! > 1 ? 's' : ''}</span>
|
||||
}
|
||||
{projectCount! > 0 && imCount > 0 && " and "}
|
||||
{imCount > 0 &&
|
||||
<span className="font-bold text-foreground">{imCount} internal memo{imCount > 1 ? 's' : ''}</span>
|
||||
}
|
||||
.{" "}
|
||||
</>
|
||||
)}
|
||||
{woCount! > 0 && (
|
||||
<>
|
||||
A dedicated team of{" "}
|
||||
<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.name}</span>.
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between pt-4 pb-2 border-t border-border">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-[10px] uppercase tracking-wider font-semibold text-muted-foreground">Assigned Team</span>
|
||||
<div className="flex -space-x-2 overflow-hidden">
|
||||
{client.users?.slice(0, 5).map((user, key) => {
|
||||
return (
|
||||
<div key={key}>
|
||||
<Tooltip>
|
||||
<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?.name}</p>
|
||||
<p className="text-[10px] opacity-80">{user?.position?.name}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{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 &&
|
||||
<span className="text-[10px] text-muted-foreground italic">No team assigned</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 self-end">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={(e) => e.stopPropagation()}>
|
||||
<MoreHorizontal className="w-4 h-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem asChild onClick={(e) => e.stopPropagation()}>
|
||||
<Link href={`/task/client-detail/${client.id}`}>View Client Detail</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onSelect={() => { setShowSelectedData(client); setAction('EDIT') }} onClick={(e) => e.stopPropagation()}>
|
||||
Edit Client
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onSelect={() => { setShowSelectedData(client); setAction('DELETE') }} className="text-destructive" onClick={(e) => e.stopPropagation()}>
|
||||
Delete Client
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card900>
|
||||
</Link>
|
||||
</motion.div>
|
||||
);
|
||||
})}
|
||||
</div> : null
|
||||
}
|
||||
|
||||
{action === 'EDIT' && <FormClient data={selectedData} onCancel={handleClose} onSuccess={() => { router.refresh(); handleClose() }} />}
|
||||
|
||||
{action === 'DELETE' ? <ConfirmDeleteWithInput endpoint={`/client/${selectedData?.id}`} onCancel={handleClose} onSuccess={() => { router.refresh(); handleClose() }}
|
||||
title={selectedData?.name!} description={`This action cannot be undone. This will permanently delete and remove client ${selectedData?.name} from our servers.`}
|
||||
titleButton={`I understand the consequences, delete this client`}
|
||||
/> : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
"use client"
|
||||
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Search } from 'lucide-react';
|
||||
import { Search, LayoutGrid, List } from 'lucide-react';
|
||||
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
|
||||
import { type FC, useEffect, useState } from 'react';
|
||||
import {
|
||||
Select, SelectContent, SelectItem, SelectTrigger, SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { cn } from '@/lib/utils';
|
||||
import useDebounce from '@/hooks/useDebounce';
|
||||
import { FilterModal } from './FilterModal';
|
||||
|
||||
@@ -21,15 +23,29 @@ type Props = {
|
||||
hideCategory?: boolean;
|
||||
hideFilterModal?: boolean
|
||||
hideSort?: boolean
|
||||
showLayoutToggle?: boolean
|
||||
};
|
||||
|
||||
const FilterComponent: FC<Props> = ({ hideFilterModal, hideClient, hideEndUser, hideStatus, hideAssignedTo, hideProjectDateFilter, hideWoDateFilter, hideImDateFilter, hideCategory, hideSort }) => {
|
||||
const FilterComponent: FC<Props> = ({
|
||||
hideFilterModal,
|
||||
hideClient,
|
||||
hideEndUser,
|
||||
hideStatus,
|
||||
hideAssignedTo,
|
||||
hideProjectDateFilter,
|
||||
hideWoDateFilter,
|
||||
hideImDateFilter,
|
||||
hideCategory,
|
||||
hideSort,
|
||||
showLayoutToggle,
|
||||
}) => {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
const currentQuery = searchParams?.get('q') || '';
|
||||
const currentSort = searchParams?.get('sort') || '';
|
||||
const currentLayout = searchParams?.get('layout') === 'list' ? 'list' : 'grid';
|
||||
|
||||
const [searchText, setSearchText] = useState(currentQuery);
|
||||
|
||||
@@ -59,6 +75,18 @@ const FilterComponent: FC<Props> = ({ hideFilterModal, hideClient, hideEndUser,
|
||||
router.replace(`${pathname}?${params.toString()}`, { scroll: false });
|
||||
};
|
||||
|
||||
const handleLayoutChange = (val: 'grid' | 'list') => {
|
||||
const params = new URLSearchParams(searchParams?.toString() || '');
|
||||
|
||||
if (val === 'list') {
|
||||
params.set('layout', 'list');
|
||||
} else {
|
||||
params.delete('layout');
|
||||
}
|
||||
|
||||
router.replace(`${pathname}?${params.toString()}`, { scroll: false });
|
||||
};
|
||||
|
||||
return (
|
||||
<div className='flex flex-col sm:flex-row justify-between items-center gap-5'>
|
||||
<div className='flex flex-col sm:flex-row items-center gap-5 w-full sm:w-auto'>
|
||||
@@ -81,20 +109,55 @@ const FilterComponent: FC<Props> = ({ hideFilterModal, hideClient, hideEndUser,
|
||||
}
|
||||
</div>
|
||||
|
||||
{!hideSort ?
|
||||
<Select value={currentSort} onValueChange={handleSortChange}>
|
||||
<SelectTrigger className="w-full md:w-max bg-white dark:bg-zinc-900">
|
||||
<SelectValue placeholder="Sort by" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="default">Default</SelectItem>
|
||||
<SelectItem value="latest">Latest</SelectItem>
|
||||
<SelectItem value="oldest">Oldest</SelectItem>
|
||||
<SelectItem value="participants_desc">Most Participants</SelectItem>
|
||||
<SelectItem value="participants_asc">Fewest Participants</SelectItem>
|
||||
</SelectContent>
|
||||
</Select> : null
|
||||
}
|
||||
<div className='flex items-center gap-3 w-full sm:w-auto justify-end'>
|
||||
{showLayoutToggle ? (
|
||||
<div className="flex items-center p-0.5 bg-muted/60 dark:bg-zinc-800/80 rounded-lg border border-border shrink-0">
|
||||
<Button
|
||||
type="button"
|
||||
variant={currentLayout === 'grid' ? 'default' : 'ghost'}
|
||||
size="icon"
|
||||
className={cn(
|
||||
"h-8 w-8 rounded-md transition-all",
|
||||
currentLayout === 'grid' && "bg-his text-white dark:text-foreground shadow-xs font-medium"
|
||||
)}
|
||||
onClick={() => handleLayoutChange('grid')}
|
||||
title="Grid view"
|
||||
aria-label="Grid view"
|
||||
>
|
||||
<LayoutGrid className="w-4 h-4" />
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant={currentLayout === 'list' ? 'default' : 'ghost'}
|
||||
size="icon"
|
||||
className={cn(
|
||||
"h-8 w-8 rounded-md transition-all",
|
||||
currentLayout === 'list' && "bg-his text-white dark:text-foreground shadow-xs font-medium"
|
||||
)}
|
||||
onClick={() => handleLayoutChange('list')}
|
||||
title="List view"
|
||||
aria-label="List view"
|
||||
>
|
||||
<List className="w-4 h-4" />
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{!hideSort ? (
|
||||
<Select value={currentSort} onValueChange={handleSortChange}>
|
||||
<SelectTrigger className="w-full sm:w-auto md:w-max bg-white dark:bg-zinc-900">
|
||||
<SelectValue placeholder="Sort by" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="default">Default</SelectItem>
|
||||
<SelectItem value="latest">Latest</SelectItem>
|
||||
<SelectItem value="oldest">Oldest</SelectItem>
|
||||
<SelectItem value="participants_desc">Most Participants</SelectItem>
|
||||
<SelectItem value="participants_asc">Fewest Participants</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@ import { useState } from 'react';
|
||||
import { useRouter, usePathname, useSearchParams } from 'next/navigation';
|
||||
import { Plus } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
// import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import FormClient from './FormClient';
|
||||
import FormClient from './client/FormClient';
|
||||
import FilterComponent from './FilterComponent';
|
||||
import {
|
||||
Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue,
|
||||
@@ -41,12 +40,6 @@ export default function HomeTask({ currentView }: ShellProps) {
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
{/* <Tabs value={currentView} onValueChange={handleTabChange} className="w-auto">
|
||||
<TabsList>
|
||||
<TabsTrigger value="grid" className="gap-2"><LayoutGrid className="w-4 h-4" /> Clients</TabsTrigger>
|
||||
<TabsTrigger value="table" className="gap-2"><List className="w-4 h-4" /> Assignments</TabsTrigger>
|
||||
</TabsList>
|
||||
</Tabs> */}
|
||||
<Select value={currentView} onValueChange={handleTabChange}>
|
||||
<SelectTrigger className="w-full md:w-max bg-white dark:bg-zinc-900">
|
||||
<SelectValue placeholder="Show by" />
|
||||
@@ -73,7 +66,10 @@ export default function HomeTask({ currentView }: ShellProps) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<FilterComponent hideFilterModal={currentView === 'clients'} />
|
||||
<FilterComponent
|
||||
hideFilterModal={currentView === 'clients'}
|
||||
showLayoutToggle={true}
|
||||
/>
|
||||
|
||||
{showForm && <FormClient isRedirectToDetail onCancel={() => setShowForm(false)} onSuccess={() => { setShowForm(false); router.refresh() }} />}
|
||||
</>
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from 'react';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import { Users } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { IClient } from '../../types';
|
||||
import FormClient from './FormClient';
|
||||
import { ConfirmDeleteWithInput } from '@/components/modal/ConfirmDeleteWithInput';
|
||||
import ClientGrid from './ClientGrid';
|
||||
import ClientList from './ClientList';
|
||||
|
||||
interface ClientProps {
|
||||
clients: IClient[];
|
||||
initialLayout?: 'grid' | 'list';
|
||||
}
|
||||
|
||||
export default function Client({ clients, initialLayout = 'grid' }: ClientProps) {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const layout = searchParams?.get('layout') === 'list' ? 'list' : initialLayout;
|
||||
|
||||
const [action, setAction] = useState<'EDIT' | 'DELETE' | undefined>(undefined);
|
||||
const [selectedData, setSelectedData] = useState<IClient>();
|
||||
|
||||
const handleClose = () => {
|
||||
setAction(undefined);
|
||||
setSelectedData(undefined);
|
||||
};
|
||||
|
||||
const handleEdit = (client: IClient) => {
|
||||
setSelectedData(client);
|
||||
setAction('EDIT');
|
||||
};
|
||||
|
||||
const handleDelete = (client: IClient) => {
|
||||
setSelectedData(client);
|
||||
setAction('DELETE');
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{clients.length === 0 ? (
|
||||
<div className="py-12 text-center border-2 border-dashed rounded-xl">
|
||||
<Users className="w-12 h-12 mx-auto text-muted-foreground mb-4 opacity-20" />
|
||||
<div className="text-center">
|
||||
<h3 className="text-xl font-semibold">No Client Found</h3>
|
||||
<p className="text-muted-foreground max-w-sm mx-auto mt-2">
|
||||
Try to change the filter or create one to get started.
|
||||
</p>
|
||||
<Button
|
||||
variant="outline"
|
||||
className="mt-4"
|
||||
onClick={() => {
|
||||
setAction('EDIT');
|
||||
setSelectedData(undefined);
|
||||
}}
|
||||
>
|
||||
Create New Client
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{clients.length > 0 && layout === 'list' ?
|
||||
<ClientList clients={clients} onEdit={handleEdit} onDelete={handleDelete} />
|
||||
: null}
|
||||
|
||||
{clients.length > 0 && layout === 'grid' ?
|
||||
<ClientGrid clients={clients} onEdit={handleEdit} onDelete={handleDelete} />
|
||||
: null}
|
||||
|
||||
{action === 'EDIT' && (
|
||||
<FormClient
|
||||
data={selectedData}
|
||||
onCancel={handleClose}
|
||||
onSuccess={() => {
|
||||
router.refresh();
|
||||
handleClose();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{action === 'DELETE' && selectedData ?
|
||||
<ConfirmDeleteWithInput
|
||||
endpoint={`/client/${selectedData.id}`}
|
||||
onCancel={handleClose}
|
||||
onSuccess={() => {
|
||||
router.refresh();
|
||||
handleClose();
|
||||
}}
|
||||
title={selectedData.name}
|
||||
description={`This action cannot be undone. This will permanently delete and remove client ${selectedData.name} from our servers.`}
|
||||
titleButton="I understand the consequences, delete this client"
|
||||
/>
|
||||
: null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
"use client";
|
||||
|
||||
import { motion } from 'motion/react';
|
||||
import { Card900, CardContent } from '@/components/ui/card';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { ExternalLink, MoreHorizontal } from 'lucide-react';
|
||||
import Link from 'next/link';
|
||||
import { LazyImage } from '@/components/ui/lazy-image';
|
||||
import {
|
||||
DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Tooltip, TooltipContent, TooltipTrigger,
|
||||
} from '@/components/ui/tooltip';
|
||||
import {
|
||||
HoverCard, HoverCardContent, HoverCardTrigger,
|
||||
} from "@/components/ui/hover-card";
|
||||
import { cn } from '@/lib/utils';
|
||||
import BadgeStatus from '@/components/ui/badge-status';
|
||||
import { IClient } from '../../types';
|
||||
|
||||
interface ClientGridProps {
|
||||
clients: IClient[];
|
||||
onEdit: (client: IClient) => void;
|
||||
onDelete: (client: IClient) => void;
|
||||
}
|
||||
|
||||
export default function ClientGrid({ clients, onEdit, onDelete }: ClientGridProps) {
|
||||
return (
|
||||
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
|
||||
{clients.map((client, i) => {
|
||||
const imCount = 0;
|
||||
const projectCount = client.total_project;
|
||||
const woCount = client.total_work_order;
|
||||
const userCount = client.total_user_assigned;
|
||||
const isActive = client.status_name.toLowerCase() === 'active';
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
key={client.id}
|
||||
initial={{ opacity: 0, scale: 0.95 }}
|
||||
animate={{ opacity: 1, scale: 1 }}
|
||||
transition={{ delay: i * 0.05 }}
|
||||
className="h-full"
|
||||
>
|
||||
<Card900 className="h-full group overflow-hidden hover:shadow-lg transition-all duration-300 border-border/80 hover:border-primary/20 flex flex-col py-0">
|
||||
<CardContent className="p-0 flex flex-col h-full">
|
||||
{/* Uncropped Image banner */}
|
||||
<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!}
|
||||
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"
|
||||
/>
|
||||
</Link>
|
||||
<div className="absolute top-3 right-3 z-20">
|
||||
<HoverCard openDelay={10} closeDelay={100}>
|
||||
<HoverCardTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className="group/pill flex items-center gap-2 bg-background/80 dark:bg-zinc-900/80 hover:bg-background border border-border/80 rounded-full py-1 px-3 transition-all duration-300 cursor-help shadow-xs"
|
||||
>
|
||||
<span className={cn(
|
||||
"w-2 h-2 rounded-full",
|
||||
isActive ? 'bg-emerald-500' : 'bg-amber-500'
|
||||
)} />
|
||||
<span className="text-[10px] font-bold text-foreground uppercase tracking-wider whitespace-nowrap">
|
||||
{client.status_name}
|
||||
</span>
|
||||
</button>
|
||||
</HoverCardTrigger>
|
||||
<HoverCardContent side="bottom" align='end' className="flex flex-col gap-0.5 text-sm w-68">
|
||||
<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-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} />
|
||||
<div className='font-bold'>{item.total}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</HoverCardContent>
|
||||
</HoverCard>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="p-5 flex flex-col flex-1 justify-between gap-4">
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
{client.code && (
|
||||
<span className="text-[11px] font-mono font-medium px-2 py-0.5 rounded bg-accent text-accent-foreground border border-border/60 shrink-0">
|
||||
{client.code}
|
||||
</span>
|
||||
)}
|
||||
<Link
|
||||
href={`/task/client-detail/${client.id}`}
|
||||
className="font-bold text-base sm:text-lg leading-tight text-foreground hover:text-primary transition-colors truncate"
|
||||
>
|
||||
{client.name}
|
||||
</Link>
|
||||
</div>
|
||||
<Link href={`/task/client-detail/${client.id}`} className="shrink-0">
|
||||
<Button size="icon" variant="ghost" className="h-8 w-8 rounded-full text-muted-foreground hover:text-foreground">
|
||||
<ExternalLink className="w-4 h-4" />
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<p className="text-sm leading-relaxed text-muted-foreground line-clamp-3 h-16">
|
||||
{projectCount === 0 && imCount === 0 && woCount === 0 ? (
|
||||
"No active projects, internal memos, or work orders recorded for this client yet."
|
||||
) : (
|
||||
<>
|
||||
{(projectCount! > 0 || imCount > 0) && (
|
||||
<>
|
||||
Currently managing a portfolio of{" "}
|
||||
{projectCount! > 0 && (
|
||||
<span className="font-bold text-foreground">
|
||||
{projectCount} project{projectCount! > 1 ? 's' : ''}
|
||||
</span>
|
||||
)}
|
||||
{projectCount! > 0 && imCount > 0 && " and "}
|
||||
{imCount > 0 && (
|
||||
<span className="font-bold text-foreground">
|
||||
{imCount} internal memo{imCount > 1 ? 's' : ''}
|
||||
</span>
|
||||
)}
|
||||
.{" "}
|
||||
</>
|
||||
)}
|
||||
{woCount! > 0 && (
|
||||
<>
|
||||
A dedicated team of{" "}
|
||||
<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.name}</span>.
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between pt-4 pb-2 border-t border-border">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-[10px] uppercase tracking-wider font-semibold text-muted-foreground">Assigned Team</span>
|
||||
<div className="flex -space-x-2 overflow-hidden">
|
||||
{client.users?.slice(0, 5).map((user, key) => (
|
||||
<div key={key}>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div className="inline-block relative">
|
||||
<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"
|
||||
/>
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<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 && (
|
||||
<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 && (
|
||||
<span className="text-[10px] text-muted-foreground italic mr-1">No team assigned</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 self-end">
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" size="icon" className="h-8 w-8" onClick={(e) => e.stopPropagation()}>
|
||||
<MoreHorizontal className="w-4 h-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem asChild onClick={(e) => e.stopPropagation()}>
|
||||
<Link href={`/task/client-detail/${client.id}`}>View Client Detail</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onSelect={() => onEdit(client)} onClick={(e) => e.stopPropagation()}>
|
||||
Edit Client
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onSelect={() => onDelete(client)} className="text-destructive" onClick={(e) => e.stopPropagation()}>
|
||||
Delete Client
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card900>
|
||||
</motion.div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
import { IClient } from '../../types';
|
||||
import { motion } from 'motion/react';
|
||||
import { Card900, CardContent } from '@/components/ui/card';
|
||||
import Link from 'next/link';
|
||||
import { LazyImage } from '@/components/ui/lazy-image';
|
||||
import { ExternalLink, MoreHorizontal, FolderGit2, FileText, Users } from 'lucide-react';
|
||||
import {
|
||||
DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Tooltip, TooltipContent, TooltipTrigger,
|
||||
} from '@/components/ui/tooltip';
|
||||
import {
|
||||
HoverCard, HoverCardContent, HoverCardTrigger,
|
||||
} from "@/components/ui/hover-card";
|
||||
import { cn } from '@/lib/utils';
|
||||
import BadgeStatus from '@/components/ui/badge-status';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
|
||||
interface ClientListProps {
|
||||
clients: IClient[];
|
||||
onEdit: (client: IClient) => void;
|
||||
onDelete: (client: IClient) => void;
|
||||
}
|
||||
|
||||
export default function ClientList({ clients, onEdit, onDelete }: ClientListProps) {
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
{clients.map((client, index) => {
|
||||
const imCount = 0;
|
||||
const projectCount = client.total_project || 0;
|
||||
const woCount = client.total_work_order || 0;
|
||||
const userCount = client.total_user_assigned || client.users?.length || 0;
|
||||
const isActive = client.status_name?.toLowerCase() === 'active';
|
||||
|
||||
const hasDescription = typeof client.description === 'string' && client.description.trim().length > 0;
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 8 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.25, delay: index * 0.04 }}
|
||||
className="w-full"
|
||||
key={index}
|
||||
>
|
||||
<Card900 className="group overflow-hidden hover:shadow-md transition-all duration-300 border-border/80 hover:border-primary/30 flex flex-col lg:flex-row py-1.5">
|
||||
<CardContent className="p-0 flex flex-col lg:flex-row w-full items-stretch">
|
||||
{/* Left Column: Photo / Thumbnail (uncropped) */}
|
||||
<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!}
|
||||
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"
|
||||
/>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{/* Middle Column: Details, Description, Metrics & Breakdown */}
|
||||
<div className="p-4 sm:p-5 flex-1 flex flex-col justify-between gap-3 min-w-0">
|
||||
{/* Header Row: Code + Name + Status */}
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="flex items-center gap-2.5 min-w-0">
|
||||
{client.code && (
|
||||
<span className="text-xs font-mono font-medium px-2 py-0.5 rounded-md bg-accent text-accent-foreground border border-border/60 shrink-0">
|
||||
{client.code}
|
||||
</span>
|
||||
)}
|
||||
<Link
|
||||
href={`/task/client-detail/${client.id}`}
|
||||
className="font-semibold text-base sm:text-lg text-foreground hover:text-primary transition-colors tracking-tight truncate"
|
||||
>
|
||||
{client.name}
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{/* Status Pill with HoverCard */}
|
||||
<div className="shrink-0">
|
||||
<HoverCard openDelay={10} closeDelay={100}>
|
||||
<HoverCardTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className="group/pill inline-flex items-center gap-2 bg-muted/60 dark:bg-zinc-800/80 hover:bg-muted dark:hover:bg-zinc-800 border border-border/80 rounded-full py-1 px-3 transition-colors text-xs font-medium cursor-help"
|
||||
>
|
||||
<span className={cn(
|
||||
"w-2 h-2 rounded-full",
|
||||
isActive ? 'bg-emerald-500' : 'bg-amber-500'
|
||||
)} />
|
||||
<span className="uppercase tracking-wider text-[10px] font-bold text-foreground">
|
||||
{client.status_name}
|
||||
</span>
|
||||
</button>
|
||||
</HoverCardTrigger>
|
||||
<HoverCardContent side="bottom" align="end" className="w-72 p-3 text-xs">
|
||||
<div className="font-semibold text-foreground">Status Summary</div>
|
||||
<p className="text-muted-foreground mt-0.5">Status summary from WO or IM related to this client.</p>
|
||||
<div className="flex flex-col mt-3 gap-2">
|
||||
{client.project_status_summary?.length > 0 ? (
|
||||
client.project_status_summary.map((item, key) => (
|
||||
<div className="flex justify-between items-center gap-2" key={key}>
|
||||
<BadgeStatus status={item.project_status} />
|
||||
<span className="font-bold">{item.total}</span>
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
<span className="italic text-muted-foreground">No status summary recorded.</span>
|
||||
)}
|
||||
</div>
|
||||
</HoverCardContent>
|
||||
</HoverCard>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Description & Narrative */}
|
||||
<div className="space-y-1.5">
|
||||
{hasDescription && (
|
||||
<p className="text-xs sm:text-sm text-foreground/90 line-clamp-2 leading-relaxed">
|
||||
{client.description}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<p className="text-xs leading-relaxed text-muted-foreground line-clamp-2 pt-0.5">
|
||||
{projectCount === 0 && imCount === 0 && woCount === 0 ? (
|
||||
"No active projects, internal memos, or work orders recorded for this client yet."
|
||||
) : (
|
||||
<>
|
||||
{(projectCount > 0 || imCount > 0) && (
|
||||
<>
|
||||
Currently managing a portfolio of{" "}
|
||||
{projectCount > 0 && (
|
||||
<span className="font-semibold text-foreground">
|
||||
{projectCount} project{projectCount > 1 ? 's' : ''}
|
||||
</span>
|
||||
)}
|
||||
{projectCount > 0 && imCount > 0 && " and "}
|
||||
{imCount > 0 && (
|
||||
<span className="font-semibold text-foreground">
|
||||
{imCount} internal memo{imCount > 1 ? 's' : ''}
|
||||
</span>
|
||||
)}
|
||||
.{" "}
|
||||
</>
|
||||
)}
|
||||
{woCount > 0 && (
|
||||
<>
|
||||
A dedicated team of{" "}
|
||||
<span className="font-semibold text-foreground">{userCount} experts</span> is handling{" "}
|
||||
<span className="font-semibold text-foreground">
|
||||
{woCount} work order{woCount > 1 ? 's' : ''}
|
||||
</span>{" "}
|
||||
to ensure successful delivery for <span className="italic">{client.name}</span>.
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Metrics Bar & Status Breakdown */}
|
||||
<div className="flex flex-wrap items-center gap-2 pt-2 border-t border-border/50">
|
||||
<div className="flex items-center gap-1.5 text-xs text-muted-foreground bg-accent/40 dark:bg-zinc-800/60 px-2.5 py-1 rounded-md border border-border/40">
|
||||
<FolderGit2 className="w-3.5 h-3.5 text-muted-foreground" />
|
||||
<span className="font-semibold text-foreground">{projectCount}</span>
|
||||
<span>Projects</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5 text-xs text-muted-foreground bg-accent/40 dark:bg-zinc-800/60 px-2.5 py-1 rounded-md border border-border/40">
|
||||
<FileText className="w-3.5 h-3.5 text-muted-foreground" />
|
||||
<span className="font-semibold text-foreground">{woCount}</span>
|
||||
<span>Work Orders</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5 text-xs text-muted-foreground bg-accent/40 dark:bg-zinc-800/60 px-2.5 py-1 rounded-md border border-border/40">
|
||||
<Users className="w-3.5 h-3.5 text-muted-foreground" />
|
||||
<span className="font-semibold text-foreground">{userCount}</span>
|
||||
<span>Assigned</span>
|
||||
</div>
|
||||
|
||||
{/* Project Status Summary items inline */}
|
||||
{client.project_status_summary && client.project_status_summary.length > 0 && (
|
||||
<div className="hidden sm:flex items-center gap-1.5 ml-auto">
|
||||
{client.project_status_summary.slice(0, 3).map((item, key) => (
|
||||
<div key={key} className="flex items-center gap-1">
|
||||
<BadgeStatus status={item.project_status} />
|
||||
<span className="text-[11px] font-semibold text-muted-foreground">({item.total})</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Right Column: Assigned Team & Action Buttons */}
|
||||
<div className="p-4 sm:p-5 lg:w-72 shrink-0 flex flex-col justify-between border-t lg:border-t-0 lg:border-l border-border/60 bg-muted/15 dark:bg-zinc-900/30 gap-4">
|
||||
{/* Assigned Team */}
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-[10px] uppercase tracking-wider font-semibold text-muted-foreground">
|
||||
Assigned Team
|
||||
</span>
|
||||
<span className="text-xs font-semibold text-foreground">
|
||||
{client.users?.length || 0}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="flex -space-x-2 overflow-hidden items-center">
|
||||
{client.users?.slice(0, 5).map((user, key) => (
|
||||
<div key={key}>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div className="inline-block relative">
|
||||
<LazyImage
|
||||
src={user?.avatar ? `${process.env.BASE_URL_IMG}/${user?.avatar}` : '/assets/no-avatar.jpg'}
|
||||
alt={user?.fullname || user?.name || 'User'}
|
||||
className="inline-block h-8 w-8 rounded-full border-2 border-background cursor-help hover:scale-110 hover:z-10 transition-transform object-cover"
|
||||
/>
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p className="text-xs font-bold">{user?.name || user?.fullname}</p>
|
||||
<p className="text-[10px] opacity-80">{user?.position?.name || 'Team Member'}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
))}
|
||||
{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 || client.users.length === 0) && (
|
||||
<span className="text-xs text-muted-foreground italic mr-1">No team assigned</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Action buttons */}
|
||||
<div className="flex items-center justify-between sm:justify-end lg:justify-between gap-2 pt-3 border-t border-border/40">
|
||||
<Link href={`/task/client-detail/${client.id}`} className="flex-1 sm:flex-none">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="w-full sm:w-auto text-xs h-8 gap-1.5 hover:bg-accent"
|
||||
>
|
||||
<span>View Detail</span>
|
||||
<ExternalLink className="w-3.5 h-3.5" />
|
||||
</Button>
|
||||
</Link>
|
||||
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8 text-muted-foreground hover:text-foreground"
|
||||
aria-label="Client actions menu"
|
||||
>
|
||||
<MoreHorizontal className="w-4 h-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`/task/client-detail/${client.id}`}>View Client Detail</Link>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onSelect={() => onEdit(client)}>
|
||||
Edit Client
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onSelect={() => onDelete(client)}
|
||||
className="text-destructive focus:text-destructive"
|
||||
>
|
||||
Delete Client
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card900>
|
||||
</motion.div>
|
||||
);
|
||||
})
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ import {
|
||||
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form";
|
||||
import * as Yup from 'yup'
|
||||
import { yupResolver } from '@hookform/resolvers/yup';
|
||||
import { IClient } from '../types';
|
||||
import { IClient } from '../../types';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { toast } from 'sonner';
|
||||
import { Button } from '@/components/ui/button';
|
||||
@@ -1,36 +0,0 @@
|
||||
'use client'
|
||||
|
||||
// import Image from 'next/image';
|
||||
import { FC } from 'react';
|
||||
// import { LazyLoadImage } from 'react-lazy-load-image-component';
|
||||
|
||||
type Props = {
|
||||
projectList: {
|
||||
id: number
|
||||
title: string
|
||||
img: string
|
||||
cover?: boolean
|
||||
dark?: boolean
|
||||
}[]
|
||||
};
|
||||
|
||||
const TaskComponent: FC<Props> = ({ projectList }) => {
|
||||
return (
|
||||
<>
|
||||
<div className='grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5 sm:gap-6 mb-20'>
|
||||
{projectList.map(item =>
|
||||
<div key={item.id} className='border border-border rounded-2xl shadow overflow-hidden cursor-pointer hover:border-primary duration-500'>
|
||||
{/* <Image alt={item.title} height={0} width={0} quality={100} src={item.img} className='h-48 w-full object-cover rounded-t-2xl' /> */}
|
||||
<img alt={item.title} src={item.img} className='h-48 w-full rounded-t-2xl hover:scale-90 duration-500' />
|
||||
<div className='flex flex-col p-6 overflow-hidden space-y-2 rounded-b-2xl bg-white dark:bg-zinc-900 z-10'>
|
||||
<h3 className='text-lg font-semibold'>{item.title}</h3>
|
||||
<p className='text-muted-foreground line-clamp-2 sm:line-clamp-3'>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's.</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default TaskComponent;
|
||||
@@ -0,0 +1,290 @@
|
||||
"use client";
|
||||
|
||||
import { IProjectAssignment } from '../../type.assignment';
|
||||
import { motion } from 'motion/react';
|
||||
import { Card900 } from '@/components/ui/card';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Tooltip, TooltipContent, TooltipTrigger,
|
||||
} from '@/components/ui/tooltip';
|
||||
import { LazyImage } from '@/components/ui/lazy-image';
|
||||
import { Briefcase, Calendar, ExternalLink, MoreVertical, Building, FolderGit2, FileText, BuildingComplex } from 'lucide-react';
|
||||
import Link from 'next/link';
|
||||
import BadgeStatus from '@/components/ui/badge-status';
|
||||
import { formatAssignmentDate } from './AssignmentList';
|
||||
|
||||
interface AssignmentGridProps {
|
||||
assignments: IProjectAssignment[];
|
||||
clientId?: string;
|
||||
onManageTeam?: (assignment: IProjectAssignment) => void;
|
||||
onUpdateStatus?: (assignment: IProjectAssignment) => void;
|
||||
onDelete?: (assignment: IProjectAssignment) => void;
|
||||
}
|
||||
|
||||
export default function AssignmentGrid({
|
||||
assignments,
|
||||
clientId,
|
||||
onManageTeam,
|
||||
onUpdateStatus,
|
||||
onDelete,
|
||||
}: AssignmentGridProps) {
|
||||
return (
|
||||
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6 auto-rows-fr">
|
||||
{assignments.map((assignment, index) => {
|
||||
const isProject = !!assignment.wo_name;
|
||||
const assignmentType = isProject ? 'Work Order' : 'Internal Memo';
|
||||
const assignmentName = assignment.wo_name || assignment.im_name || assignment.project?.name || 'Untitled Assignment';
|
||||
const assignmentCode = assignment.wo_code || assignment.im_code || assignment.project?.code;
|
||||
const assignmentStartDate = assignment.wo_start_date || assignment.im_start_date || assignment.project?.start_date;
|
||||
const assignmentEndDate = assignment.wo_end_date || assignment.im_end_date || assignment.project?.end_date;
|
||||
const assignmentDesc = assignment.wo_description || assignment.im_description || assignment.project?.description;
|
||||
const assignmentStatus = assignment.project?.status || assignment.project_assignment_status?.name;
|
||||
|
||||
const illustrationSrc = isProject
|
||||
? '/assets/illustrations/work_order.jpg'
|
||||
: '/assets/illustrations/internal_memo.jpg';
|
||||
|
||||
const effectiveClientId = clientId || assignment.client?.id;
|
||||
const assignmentDetailUrl = effectiveClientId ? `/task/client-detail/${effectiveClientId}/${assignment.id}` : '#';
|
||||
const projectDetailUrl = effectiveClientId && assignment.project?.id
|
||||
? `/task/client-detail/${effectiveClientId}/project-detail/${assignment.project.id}`
|
||||
: null;
|
||||
const editAssignmentUrl = effectiveClientId
|
||||
? `/task/client-detail/${effectiveClientId}/project-assignments?is_edit=true&assignment_id=${assignment.id}`
|
||||
: null;
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 8 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.25, delay: index * 0.04 }}
|
||||
className="h-full"
|
||||
key={index}
|
||||
>
|
||||
<Card900 className="h-full group hover:border-his/50 transition-all duration-300 hover:shadow-xl hover:-translate-y-1 flex flex-col justify-between p-5 border-border/80 rounded-2xl bg-card gap-4">
|
||||
{/* Top Section: 3D Emblem, Badges, and Action Menu */}
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="flex items-center gap-3.5 min-w-0">
|
||||
{/* 3D App Icon / Emblem */}
|
||||
<Link
|
||||
href={assignmentDetailUrl}
|
||||
className="relative w-14 h-14 sm:w-16 sm:h-16 shrink-0 rounded-2xl overflow-hidden bg-muted/20 dark:bg-zinc-800/40 border border-border/60 flex items-center justify-center p-1 shadow-2xs group-hover:scale-105 group-hover:border-his/40 transition-all duration-300"
|
||||
>
|
||||
<LazyImage
|
||||
src={illustrationSrc}
|
||||
alt={assignmentType}
|
||||
className="w-full h-full bg-transparent"
|
||||
imgClassName="object-contain rounded-lg"
|
||||
/>
|
||||
</Link>
|
||||
|
||||
{/* Identity & Badges */}
|
||||
<div className="min-w-0 space-y-1.5">
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<Badge
|
||||
variant="outline"
|
||||
className={`text-[10px] font-semibold tracking-wide px-2 py-0.5 gap-1 ${isProject
|
||||
? 'bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/30'
|
||||
: 'bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/30'
|
||||
}`}
|
||||
>
|
||||
{isProject ? <Briefcase className="w-3 h-3" /> : <FileText className="w-3 h-3" />}
|
||||
<span>{assignmentType}</span>
|
||||
</Badge>
|
||||
|
||||
{assignmentStatus && <BadgeStatus status={assignmentStatus} />}
|
||||
</div>
|
||||
|
||||
{assignmentCode &&
|
||||
<span className="text-[11px] font-mono font-semibold px-2 py-0.5 rounded-md bg-muted/80 dark:bg-zinc-800 text-muted-foreground border border-border/60 shrink-0">
|
||||
# {assignmentCode}
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Actions Menu */}
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8 text-muted-foreground hover:text-foreground shrink-0 rounded-full hover:bg-muted"
|
||||
aria-label="Assignment actions"
|
||||
>
|
||||
<MoreVertical className="w-4 h-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-48">
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={assignmentDetailUrl}>View Assignment Details</Link>
|
||||
</DropdownMenuItem>
|
||||
{projectDetailUrl && (
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={projectDetailUrl}>View Project Details</Link>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{!clientId && assignment.client?.id && (
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`/task/client-detail/${assignment.client.id}`}>View Client</Link>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{editAssignmentUrl && (
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={editAssignmentUrl}>Edit Assignment</Link>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{onManageTeam && (
|
||||
<DropdownMenuItem onSelect={() => onManageTeam(assignment)}>
|
||||
Manage Team
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{onUpdateStatus && (
|
||||
<DropdownMenuItem onSelect={() => onUpdateStatus(assignment)}>
|
||||
Update Status
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{onDelete && (
|
||||
<DropdownMenuItem
|
||||
onSelect={() => onDelete(assignment)}
|
||||
className="text-destructive focus:text-destructive"
|
||||
>
|
||||
Delete
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
|
||||
{/* Center: Title, Project, Description, Tags */}
|
||||
<div className="space-y-2.5 flex-1">
|
||||
{/* Title */}
|
||||
<div>
|
||||
<Link
|
||||
href={assignmentDetailUrl}
|
||||
className="font-bold text-base sm:text-lg leading-snug text-foreground hover:text-his transition-colors block line-clamp-2 tracking-tight"
|
||||
>
|
||||
{assignmentName}
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{/* Project Reference */}
|
||||
{assignment.project?.name && (
|
||||
<div className="flex items-center gap-1.5 text-xs text-muted-foreground pt-0.5">
|
||||
<FolderGit2 className="w-3.5 h-3.5 text-his shrink-0" />
|
||||
<span className="text-[11px] text-muted-foreground">Project:</span>
|
||||
{projectDetailUrl ? (
|
||||
<Link
|
||||
href={projectDetailUrl}
|
||||
className="font-medium text-foreground hover:text-his truncate hover:underline flex items-center gap-1"
|
||||
>
|
||||
<span className="truncate">{assignment.project.name}</span>
|
||||
<ExternalLink className="w-3 h-3 shrink-0 opacity-60" />
|
||||
</Link>
|
||||
) : (
|
||||
<span className="font-medium text-foreground truncate">{assignment.project.name}</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Description */}
|
||||
{assignmentDesc && (
|
||||
<p className="text-xs text-muted-foreground line-clamp-2 leading-relaxed pt-0.5">
|
||||
{assignmentDesc}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/* Client & End User Badges */}
|
||||
<div className="flex flex-wrap items-center gap-2 pt-1 text-xs">
|
||||
{assignment.client?.name && !clientId && (
|
||||
<Link
|
||||
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]"
|
||||
>
|
||||
{assignment.client.photo ?
|
||||
<LazyImage
|
||||
src={assignment.client.photo}
|
||||
alt={assignment.client.name}
|
||||
className="w-3 h-3 rounded-xs bg-transparent"
|
||||
imgClassName="object-cover"
|
||||
/>
|
||||
:
|
||||
<BuildingComplex className="w-3 h-3 text-muted-foreground" />
|
||||
}
|
||||
<span className="text-muted-foreground">Client:</span>
|
||||
<span className="font-medium truncate max-w-50">{assignment.client.name}</span>
|
||||
</Link>
|
||||
)}
|
||||
|
||||
{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]">
|
||||
<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>
|
||||
<span className="text-muted-foreground">End User:</span>
|
||||
<span className="font-medium truncate max-w-50">{assignment.end_user.name}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Footer: Timeline & Team Members */}
|
||||
<div className="pt-3.5 border-t border-border/60 flex items-center justify-between gap-3 text-xs">
|
||||
<div className="flex items-center gap-1.5 text-muted-foreground">
|
||||
<Calendar className="w-3.5 h-3.5 shrink-0 text-muted-foreground/80" />
|
||||
<span className="font-medium text-[11px]">
|
||||
{formatAssignmentDate(assignmentStartDate)} - {formatAssignmentDate(assignmentEndDate)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Assigned Team */}
|
||||
<div className="flex -space-x-2 overflow-hidden items-center shrink-0">
|
||||
{assignment.project_assignment_work_order_detail?.slice(0, 4).map((item, key) => (
|
||||
<div key={key}>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div className="inline-block relative">
|
||||
<LazyImage
|
||||
src={item?.user?.avatar ? `${process.env.BASE_URL_IMG}/${item.user.avatar}` : '/assets/no-avatar.jpg'}
|
||||
alt={item?.user?.fullname || item?.user?.name || 'Member'}
|
||||
className="w-7 h-7 rounded-full border-2 border-background cursor-help hover:scale-110 hover:z-10 transition-transform object-cover"
|
||||
/>
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p className="text-xs font-bold">{item?.user?.fullname || item?.user?.name}</p>
|
||||
<p className="text-[10px] opacity-80">{item?.user?.position?.name || 'Team Member'}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
))}
|
||||
{assignment.project_assignment_work_order_detail && assignment.project_assignment_work_order_detail.length > 4 && (
|
||||
<div className="w-7 h-7 rounded-full bg-accent ring-2 ring-background flex items-center justify-center text-[10px] font-bold">
|
||||
+{assignment.project_assignment_work_order_detail.length - 4}
|
||||
</div>
|
||||
)}
|
||||
{(!assignment.project_assignment_work_order_detail || assignment.project_assignment_work_order_detail.length === 0) && (
|
||||
<span className="text-[11px] text-muted-foreground italic mr-1">No team</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Card900>
|
||||
</motion.div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
"use client";
|
||||
|
||||
import { IProjectAssignment } from '../../type.assignment';
|
||||
import { motion } from 'motion/react';
|
||||
import { Card900, CardContent } from '@/components/ui/card';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Tooltip, TooltipContent, TooltipTrigger,
|
||||
} from '@/components/ui/tooltip';
|
||||
import { LazyImage } from '@/components/ui/lazy-image';
|
||||
import { Briefcase, Calendar, MoreVertical, FolderGit2, FileText, BuildingComplex } from 'lucide-react';
|
||||
import Link from 'next/link';
|
||||
import BadgeStatus from '@/components/ui/badge-status';
|
||||
|
||||
export const formatAssignmentDate = (dateStr?: string) => {
|
||||
if (!dateStr) return 'N/A';
|
||||
const d = new Date(dateStr);
|
||||
if (isNaN(d.getTime())) return 'N/A';
|
||||
const day = String(d.getDate()).padStart(2, '0');
|
||||
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
||||
const month = months[d.getMonth()];
|
||||
const year = d.getFullYear();
|
||||
return `${day} ${month} ${year}`;
|
||||
};
|
||||
|
||||
interface AssignmentListProps {
|
||||
assignments: IProjectAssignment[];
|
||||
clientId?: string;
|
||||
onManageTeam?: (assignment: IProjectAssignment) => void;
|
||||
onUpdateStatus?: (assignment: IProjectAssignment) => void;
|
||||
onDelete?: (assignment: IProjectAssignment) => void;
|
||||
}
|
||||
|
||||
export default function AssignmentList({
|
||||
assignments,
|
||||
clientId,
|
||||
onManageTeam,
|
||||
onUpdateStatus,
|
||||
onDelete,
|
||||
}: AssignmentListProps) {
|
||||
return (
|
||||
<div className="flex flex-col gap-5">
|
||||
{assignments.map((assignment, index) => {
|
||||
const isProject = !!assignment.wo_name;
|
||||
const assignmentType = isProject ? 'Work Order' : 'Internal Memo';
|
||||
const assignmentName = assignment.wo_name || assignment.im_name || assignment.project?.name || 'Untitled Assignment';
|
||||
const assignmentCode = assignment.wo_code || assignment.im_code || assignment.project?.code;
|
||||
const assignmentStartDate = assignment.wo_start_date || assignment.im_start_date || assignment.project?.start_date;
|
||||
const assignmentEndDate = assignment.wo_end_date || assignment.im_end_date || assignment.project?.end_date;
|
||||
const assignmentStatus = assignment.project?.status || assignment.project_assignment_status?.name;
|
||||
|
||||
const illustrationSrc = isProject
|
||||
? '/assets/illustrations/work_order.jpg'
|
||||
: '/assets/illustrations/internal_memo.jpg';
|
||||
|
||||
const effectiveClientId = clientId || assignment.client?.id;
|
||||
const assignmentDetailUrl = effectiveClientId ? `/task/client-detail/${effectiveClientId}/${assignment.id}` : '#';
|
||||
const projectDetailUrl = effectiveClientId && assignment.project?.id
|
||||
? `/task/client-detail/${effectiveClientId}/project-detail/${assignment.project.id}`
|
||||
: null;
|
||||
const editAssignmentUrl = effectiveClientId
|
||||
? `/task/client-detail/${effectiveClientId}/project-assignments?is_edit=true&assignment_id=${assignment.id}`
|
||||
: null;
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 8 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.25, delay: index * 0.04 }}
|
||||
className="w-full"
|
||||
key={index}
|
||||
>
|
||||
<Card900 className="group overflow-hidden hover:shadow-md transition-all duration-300 border-border/80 hover:border-his/40 rounded-2xl py-1 bg-card">
|
||||
<CardContent className="p-4 sm:p-5 flex flex-col md:flex-row items-start md:items-center justify-between gap-4">
|
||||
{/* Left: Thumbnail & Visual Indicator */}
|
||||
<div className="flex items-start gap-4 min-w-0 flex-1">
|
||||
<Link
|
||||
href={assignmentDetailUrl}
|
||||
className="relative w-16 h-16 sm:w-20 sm:h-20 shrink-0 rounded-2xl overflow-hidden bg-muted/20 dark:bg-zinc-800/40 border border-border/60 flex items-center justify-center p-1 shadow-2xs group-hover:border-his/40 group-hover:scale-105 transition-all duration-300"
|
||||
>
|
||||
<LazyImage
|
||||
src={illustrationSrc}
|
||||
alt={assignmentType}
|
||||
className="w-full h-full bg-transparent"
|
||||
imgClassName="object-contain rounded-lg"
|
||||
/>
|
||||
</Link>
|
||||
|
||||
{/* Center Details */}
|
||||
<div className="min-w-0 flex-1 space-y-1.5">
|
||||
{/* Line 1: Type Badge, Status, Code, and Project Reference */}
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<Badge
|
||||
variant="outline"
|
||||
className={`text-[10px] font-semibold px-2 py-0.5 gap-1 ${isProject
|
||||
? 'bg-amber-500/15 text-amber-700 dark:text-amber-400 border-amber-500/30'
|
||||
: 'bg-purple-500/15 text-purple-700 dark:text-purple-400 border-purple-500/30'
|
||||
}`}
|
||||
>
|
||||
{isProject ? <Briefcase className="w-3 h-3" /> : <FileText className="w-3 h-3" />}
|
||||
<span>{assignmentType}</span>
|
||||
</Badge>
|
||||
|
||||
{assignmentStatus && <BadgeStatus status={assignmentStatus} />}
|
||||
|
||||
{assignmentCode ? (
|
||||
<span className="text-[11px] font-mono font-medium px-2 py-0.5 rounded-md bg-muted/80 dark:bg-zinc-800 text-muted-foreground border border-border/60 shrink-0">
|
||||
# {assignmentCode}
|
||||
</span>
|
||||
) : null}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
{/* Line 2: Assignment Title */}
|
||||
<div>
|
||||
<Link
|
||||
href={assignmentDetailUrl}
|
||||
className="font-semibold text-base sm:text-lg leading-snug text-foreground hover:text-his transition-colors block tracking-tight line-clamp-1 py-0.5"
|
||||
>
|
||||
{assignmentName}
|
||||
</Link>
|
||||
{assignment.project?.name && (
|
||||
<div className="flex items-center gap-1 text-xs text-muted-foreground ml-auto sm:ml-0 mt-2">
|
||||
<FolderGit2 className="w-3.5 h-3.5 text-his shrink-0" />
|
||||
<span className="text-[11px] text-muted-foreground hidden sm:inline">Project:</span>
|
||||
{projectDetailUrl ? (
|
||||
<Link
|
||||
href={projectDetailUrl}
|
||||
className="font-medium text-foreground hover:text-his truncate hover:underline inline-block"
|
||||
>
|
||||
{assignment.project.name}
|
||||
</Link>
|
||||
) : (
|
||||
<span className="font-medium text-foreground truncate">{assignment.project.name}</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Line 3: Metadata, Client, End User, Timeline, Notes */}
|
||||
<div className="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground pt-0.5">
|
||||
{assignment.client?.name && !clientId && (
|
||||
<Link
|
||||
href={`/task/client-detail/${assignment.client.id}`}
|
||||
className="flex items-center gap-1 text-[11px] font-medium text-foreground hover:text-his transition-colors"
|
||||
>
|
||||
<BuildingComplex className="w-3 h-3 text-muted-foreground" />
|
||||
<span className="text-muted-foreground">Client:</span>
|
||||
<span className="truncate max-w-50">{assignment.client.name}</span>
|
||||
</Link>
|
||||
)}
|
||||
|
||||
{assignment.end_user?.name && (
|
||||
<div className="flex items-center gap-1 text-[11px] text-foreground">
|
||||
<span className="text-muted-foreground">End User:</span>
|
||||
<span className="font-medium truncate max-w-50">{assignment.end_user.name}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex items-center gap-1 text-[11px] text-muted-foreground">
|
||||
<Calendar className="w-3.5 h-3.5 text-muted-foreground/80" />
|
||||
<span>
|
||||
{formatAssignmentDate(assignmentStartDate)} - {formatAssignmentDate(assignmentEndDate)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{assignment.note && (
|
||||
<span className="text-[11px] italic text-muted-foreground/80 line-clamp-1 max-w-50">
|
||||
Note: {assignment.note}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Right: Team Stack & Actions */}
|
||||
<div className="flex items-center justify-between md:justify-end gap-3 w-full md:w-auto shrink-0 pt-3 md:pt-0 border-t md:border-t-0 border-border/50">
|
||||
{/* Team Avatar Stack */}
|
||||
<div className="flex -space-x-2 overflow-hidden items-center">
|
||||
{assignment.project_assignment_work_order_detail?.slice(0, 4).map((item, key) => (
|
||||
<div key={key}>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div className="inline-block relative">
|
||||
<LazyImage
|
||||
src={item?.user?.avatar ? `${process.env.BASE_URL_IMG}/${item.user.avatar}` : '/assets/no-avatar.jpg'}
|
||||
alt={item?.user?.fullname || item?.user?.name || 'User'}
|
||||
className="inline-block h-8 w-8 rounded-full border-2 border-background cursor-help hover:scale-110 hover:z-10 transition-transform object-cover"
|
||||
/>
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p className="text-xs font-bold">{item?.user?.fullname || item?.user?.name}</p>
|
||||
<p className="text-[10px] opacity-80">{item?.user?.position?.name || 'Team Member'}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</div>
|
||||
))}
|
||||
{assignment.project_assignment_work_order_detail && assignment.project_assignment_work_order_detail.length > 4 && (
|
||||
<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 - 4}
|
||||
</div>
|
||||
)}
|
||||
{(!assignment.project_assignment_work_order_detail || assignment.project_assignment_work_order_detail.length === 0) && (
|
||||
<span className="text-xs text-muted-foreground italic mr-1">No team assigned</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Action Buttons */}
|
||||
<div className="flex items-center gap-1.5">
|
||||
{/* <Link href={assignmentDetailUrl}>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="text-xs h-8 px-3 gap-1 hover:text-his hover:border-his/40"
|
||||
>
|
||||
<span>Details</span>
|
||||
<ArrowRight className="w-3 h-3" />
|
||||
</Button>
|
||||
</Link> */}
|
||||
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8 text-muted-foreground hover:text-foreground rounded-full"
|
||||
aria-label="Assignment actions menu"
|
||||
>
|
||||
<MoreVertical className="w-4 h-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-48">
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={assignmentDetailUrl}>View Assignment Details</Link>
|
||||
</DropdownMenuItem>
|
||||
{projectDetailUrl && (
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={projectDetailUrl}>View Project Details</Link>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{!clientId && assignment.client?.id && (
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={`/task/client-detail/${assignment.client.id}`}>View Client</Link>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{editAssignmentUrl && (
|
||||
<DropdownMenuItem asChild>
|
||||
<Link href={editAssignmentUrl}>Edit Assignment</Link>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{onManageTeam && (
|
||||
<DropdownMenuItem onSelect={() => onManageTeam(assignment)}>
|
||||
Manage Team
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{onUpdateStatus && (
|
||||
<DropdownMenuItem onSelect={() => onUpdateStatus(assignment)}>
|
||||
Update Status
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{onDelete && (
|
||||
<DropdownMenuItem
|
||||
onSelect={() => onDelete(assignment)}
|
||||
className="text-destructive focus:text-destructive"
|
||||
>
|
||||
Delete
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card900>
|
||||
</motion.div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
"use client";
|
||||
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { BookOpenCheck } from 'lucide-react';
|
||||
import { useSearchParams } from 'next/navigation';
|
||||
import { IProjectAssignment } from '../../type.assignment';
|
||||
import AssignmentGrid from './AssignmentGrid';
|
||||
import AssignmentList from './AssignmentList';
|
||||
|
||||
interface AssignmentTableProps {
|
||||
data: IProjectAssignment[];
|
||||
initialLayout?: 'grid' | 'list';
|
||||
}
|
||||
|
||||
export default function AssignmentTable({
|
||||
data,
|
||||
initialLayout = 'grid',
|
||||
}: AssignmentTableProps) {
|
||||
const searchParams = useSearchParams();
|
||||
const layout = searchParams?.get('layout') === 'list' ? 'list' : initialLayout;
|
||||
|
||||
if (data.length === 0) {
|
||||
return (
|
||||
<Card className="py-12 text-center border-2 border-dashed rounded-xl">
|
||||
<BookOpenCheck className="w-12 h-12 mx-auto text-muted-foreground opacity-20" />
|
||||
<div className="text-center">
|
||||
<h3 className="text-xl font-semibold">No Project Assignment Found</h3>
|
||||
<p className="text-muted-foreground max-w-sm mx-auto mt-2">
|
||||
Try to change the filter or create one to get started.
|
||||
</p>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
if (layout === 'list') {
|
||||
return <AssignmentList assignments={data} />;
|
||||
}
|
||||
|
||||
return <AssignmentGrid assignments={data} />;
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
import { Suspense } from 'react';
|
||||
import HomeTask from './component/HomeTask';
|
||||
import ClientGrid from './component/ClientGrid';
|
||||
import AssignmentTable from './component/AssignmentTable';
|
||||
import { lazy, Suspense } from 'react';
|
||||
import fetchData, { getQueryStringFilteredAssignments } from '@/lib/fetchData';
|
||||
import { getFilteredAssignments, getFilteredClients } from './data';
|
||||
import { Loader2 } from 'lucide-react';
|
||||
|
||||
const HomeTask = lazy(() => import('./component/HomeTask'));
|
||||
const ProjectAssignment = lazy(() => import('./component/project-assignment/ProjectAssignment'));
|
||||
const Client = lazy(() => import('./component/client/Client'));
|
||||
|
||||
type Props = {
|
||||
searchParams: Promise<{ view?: string; q?: string, status?: string, sort?: string }>
|
||||
searchParams: Promise<{ view?: string; q?: string; status?: string; sort?: string; layout?: string }>
|
||||
};
|
||||
|
||||
export default async function ClientsPage({ searchParams }: Props) {
|
||||
@@ -16,6 +18,7 @@ export default async function ClientsPage({ searchParams }: Props) {
|
||||
const query = (searchParams_.q || '').toLowerCase();
|
||||
const sort = (searchParams_.sort || '').toLowerCase();
|
||||
const sortBy = sort || 'default';
|
||||
const layout = searchParams_.layout === 'list' ? 'list' : 'grid';
|
||||
|
||||
const queryString = getQueryStringFilteredAssignments(searchParams_)
|
||||
|
||||
@@ -30,14 +33,16 @@ export default async function ClientsPage({ searchParams }: Props) {
|
||||
return (
|
||||
<div className="flex-1 space-y-8 p-6 sm:p-8 pt-6">
|
||||
|
||||
<HomeTask currentView={view} />
|
||||
<Suspense fallback={<div className='flex justify-center items-center h-48 gap-2'><Loader2 className="animate-spin" />Loading...</div>}>
|
||||
<HomeTask currentView={view} />
|
||||
</Suspense>
|
||||
|
||||
{/* Render the correct view based on the URL */}
|
||||
<Suspense fallback={<div className="animate-pulse h-96 bg-accent rounded-xl" />}>
|
||||
{view === 'clients' ?
|
||||
<ClientGrid clients={filteredClients} />
|
||||
<Client clients={filteredClients} initialLayout={layout} />
|
||||
:
|
||||
<AssignmentTable data={filterAssignments} />
|
||||
<ProjectAssignment data={filterAssignments} />
|
||||
}
|
||||
</Suspense>
|
||||
</div>
|
||||
|
||||
@@ -16,7 +16,7 @@ import Image from 'next/image';
|
||||
import { IClient } from '@/app/(dashboard)/task/types';
|
||||
import { LazyImage } from '@/components/ui/lazy-image';
|
||||
import BadgeStatus from '@/components/ui/badge-status';
|
||||
import FormClient from '@/app/(dashboard)/task/component/FormClient';
|
||||
import FormClient from '@/app/(dashboard)/task/component/client/FormClient';
|
||||
import { ConfirmDeleteWithInput } from '@/components/modal/ConfirmDeleteWithInput';
|
||||
|
||||
type Props = {
|
||||
|
||||
@@ -1,9 +1,37 @@
|
||||
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 ? status?.toLowerCase() : ''] || "default"} className={className}>
|
||||
{status}
|
||||
</Badge>
|
||||
)
|
||||
}
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -3,7 +3,17 @@
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useState, useRef, useEffect } from "react";
|
||||
|
||||
export function LazyImage({ src, alt, className }: { src: string; alt: string; className?: string }) {
|
||||
export function LazyImage({
|
||||
src,
|
||||
alt,
|
||||
className,
|
||||
imgClassName,
|
||||
}: {
|
||||
src: string;
|
||||
alt: string;
|
||||
className?: string;
|
||||
imgClassName?: string;
|
||||
}) {
|
||||
const [isLoaded, setIsLoaded] = useState(false);
|
||||
const imgRef = useRef<HTMLImageElement>(null);
|
||||
|
||||
@@ -25,6 +35,7 @@ export function LazyImage({ src, alt, className }: { src: string; alt: string; c
|
||||
onLoad={() => setIsLoaded(true)}
|
||||
className={cn(
|
||||
"w-full h-full object-cover transition-all duration-700 ease-in-out",
|
||||
imgClassName,
|
||||
isLoaded ? "blur-0 scale-100 opacity-100" : "blur-xl scale-110 opacity-0"
|
||||
)}
|
||||
/>
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@
|
||||
"framer-motion": "^12.23.25",
|
||||
"get-orientation": "^1.1.2",
|
||||
"heic2any": "^0.0.4",
|
||||
"lucide-react": "^0.556.0",
|
||||
"lucide-react": "^1.49.0",
|
||||
"motion": "^12.38.0",
|
||||
"next": "^16.0.10",
|
||||
"next-auth": "^4.24.13",
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 430 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 501 KiB |
Reference in New Issue
Block a user