diff --git a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.old.tsx b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.old.tsx
new file mode 100644
index 0000000..73a4edc
--- /dev/null
+++ b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.old.tsx
@@ -0,0 +1,245 @@
+// app/task/client-detail/[client_id]/[assignment_id]/project-detail-client.tsx
+"use client"
+
+import { motion } from 'motion/react';
+import { ArrowLeft, Briefcase, Calendar, CheckCircle2, History, AlertCircle, UserPlus, ExternalLink } from 'lucide-react';
+import { Button } from '@/components/ui/button';
+import { Card, CardContent, CardHeader, CardTitle, CardDescription, Card900 } from '@/components/ui/card';
+import { Badge } from '@/components/ui/badge';
+import { Separator } from '@/components/ui/separator';
+import { Label } from '@/components/ui/label';
+import { cn } from '@/lib/utils';
+import { useRouter } from 'next/navigation';
+import { IClient } from '../../../types';
+import { IProjectAssignment } from '../../../type.assignment';
+import { useState } from 'react';
+import BadgeStatus from '@/components/ui/badge-status';
+import Link from 'next/link';
+import AssignedPeople from '../project-detail/[project_id]/AssignedPeople';
+import { ManageTeam } from '../../../component/ManageTeam';
+import UpdateTimelineStatus from '../../../component/UpdateTimelineStatus';
+
+interface Props {
+ client: IClient | undefined;
+ initialAssignment: IProjectAssignment;
+}
+
+export default function AssignmentDetail({ client, initialAssignment: assignment }: Props) {
+ const [action, setAction] = useState<'MANAGE_EMPLOYEE' | 'UPDATE_STATUS' | undefined>()
+
+ const router = useRouter();
+
+ const isProject = assignment.project?.code
+
+ const assignmentType = isProject ? 'Project' : 'IM'
+ const assignmentName = assignment.project?.name || assignment.im_name
+ const assignmentCode = assignment.project?.code || assignment.im_code
+ const assignmentYear = assignment.project?.year || assignment.im_year
+ 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
+
+ const statuslist = assignment.project_assignment_status_detail?.filter(status => status.start_date) || []
+
+ const handleClose = () => {
+ setAction(undefined)
+ }
+
+ console.log(assignment)
+
+ return (
+ <>
+
+ {/* Header */}
+
+
+
+
+
Assignment Detail
+ {assignmentType}
+
+
+ {!isProject ?
+
{assignmentName}
+ :
+
+ {assignmentName}
+
+
+ }
+
+
+
+ Code: {assignmentCode || 'N/A'}
+
+
+
+ Year: {assignmentYear || 'N/A'}
+
+
+
+
+
+
+
+
+
+ {/* Left Column: Details & Work Orders */}
+
+
+ {/* Overview Card */}
+
+
+ Overview
+
+
+
+
+
+
+
+
+
+
+
+
{assignmentStartDate ? new Date(assignmentStartDate).toLocaleDateString() : 'N/A'}
+
+
+
+
{assignmentEndDate ? new Date(assignmentEndDate).toLocaleDateString() : 'N/A'}
+
+
+
+
{client?.name}
+
+
+
+
+
+
{assignmentDesc ?? 'No description available for this assignment!'}
+
+
+
+
+ {/* Work Orders Section */}
+
+
+
+ Work Orders
+
+
+
+ {!assignment.wo_name ?
+
+
+ No work orders defined for this assignment.
+
+
+ :
+
+
+
+
+
+
+
{assignment.wo_name}
+
+
{assignment.wo_description}
+
+
+ Code: {assignment.wo_code || 'N/A'}
+
+
+
+ {assignment.wo_start_date ? new Date(assignment.wo_start_date).toLocaleDateString() : 'N/A'} - {assignment.wo_end_date ? new Date(assignment.wo_end_date).toLocaleDateString() : 'N/A'}
+
+
+
+
+
+
+
+
Team
+
+
+
+
+
+
+
+
+
+ }
+
+
+
+ {/* Right Column: Status History */}
+
+
+
+
+ Assignment Timeline
+
+ Timeline of status changes
+
+
+
+ {statuslist?.map((history, idx) => (
+
+
+
+
+
+ {history.project_assignment_status.name}
+
+
+ {history.start_date ? new Date(history.start_date).toLocaleDateString() : 'N/A'} - {history.end_date ? new Date(history.end_date).toLocaleDateString() : 'Present'}
+
+
+
+ Recorded: {new Date(history.end_date!).toLocaleString()}
+
+
+
+ ))}
+ {(!statuslist || statuslist.length === 0) && (
+
No history recorded yet.
+ )}
+
+
+
+
+
+
+
+ {action === 'UPDATE_STATUS' ?
+
+ : null
+ }
+
+ {action === 'MANAGE_EMPLOYEE' ?
+
+ : null
+ }
+ >
+ );
+}
\ No newline at end of file
diff --git a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.tsx b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.tsx
index 14c5421..d086d62 100644
--- a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.tsx
+++ b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/AssignmentDetailComponent.tsx
@@ -1,13 +1,10 @@
-// app/task/client-detail/[client_id]/[assignment_id]/project-detail-client.tsx
"use client"
import { motion } from 'motion/react';
-import { ArrowLeft, Briefcase, Calendar, CheckCircle2, History, AlertCircle, UserPlus, ExternalLink } from 'lucide-react';
+import { ArrowLeft, Briefcase, Calendar, History, UserPlus, ExternalLink, Building2, Hash, Users, Icon, FileText, CalendarRange } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardHeader, CardTitle, CardDescription, Card900 } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
-import { Separator } from '@/components/ui/separator';
-import { Label } from '@/components/ui/label';
import { cn } from '@/lib/utils';
import { useRouter } from 'next/navigation';
import { IClient } from '../../../types';
@@ -18,6 +15,7 @@ import Link from 'next/link';
import AssignedPeople from '../project-detail/[project_id]/AssignedPeople';
import { ManageTeam } from '../../../component/ManageTeam';
import UpdateTimelineStatus from '../../../component/UpdateTimelineStatus';
+import { LazyImage } from '@/components/ui/lazy-image';
interface Props {
client: IClient | undefined;
@@ -32,9 +30,8 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
const isProject = assignment.project?.code
const assignmentType = isProject ? 'Project' : 'IM'
- const assignmentName = assignment.project?.name || assignment.im_name
- const assignmentCode = assignment.project?.code || assignment.im_code
- const assignmentYear = assignment.project?.year || assignment.im_year
+ const assignmentName = assignment.wo_name || assignment.im_name
+ const assignmentCode = assignment.wo_code || assignment.im_code
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
@@ -46,7 +43,8 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
setAction(undefined)
}
- console.log(assignment)
+ const formatDate = (date: string) =>
+ new Date(date).toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' });
return (
<>
@@ -64,28 +62,7 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
Assignment Detail
- {assignmentType}
-
-
- {!isProject ?
-
{assignmentName}
- :
-
- {assignmentName}
-
-
- }
-
-
-
- Code: {assignmentCode || 'N/A'}
-
-
-
- Year: {assignmentYear || 'N/A'}
-
+ {!isProject &&
{assignmentType}}
@@ -97,50 +74,76 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
- {/* Left Column: Details & Work Orders */}
+
- {/* Overview Card */}
-
-
- Overview
-
-
-
-
-
-
-
+
+ {/* */}
+
+
+
+ {isProject ? 'Project' : 'Internal Memo'}
+
+
+
+
+
+
+
+ {isProject ? : }
+
+
+
{isProject ? 'Work Order' : 'Internal Memo'}
+
+ {assignmentName}
+
+
{assignmentDesc}
-
-
-
{assignmentStartDate ? new Date(assignmentStartDate).toLocaleDateString() : 'N/A'}
-
-
-
-
{assignmentEndDate ? new Date(assignmentEndDate).toLocaleDateString() : 'N/A'}
-
-
-
-
{client?.name}
-
-
-
-
-
{assignmentDesc ?? 'No description available for this assignment!'}
+
+ {/* Quick meta row */}
+
+
+
+
+
-
+
+
+
+ {isProject && (
+
+
+ Project context
+
+
+
+
{assignment.project?.name}
+
+
+
+
+ {/* {assignment.project?.name} */}
+ # Code: {assignment.project?.code}
+ Year: {assignment.project?.year}
+
+
+ {formatDate(assignment.project?.start_date!)} → {`${assignment.project?.end_date ? formatDate(assignment.project.end_date) : 'N/A'}`}
+
+
+ {assignment.project?.description ?? 'No description available'}
+
+ )}
+
{/* Work Orders Section */}
-
-
- Work Orders
-
-
-
{!assignment.wo_name ?
@@ -150,36 +153,18 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
:
-
-
-
-
-
{assignment.wo_name}
-
-
{assignment.wo_description}
-
-
- Code: {assignment.wo_code || 'N/A'}
-
-
-
- {assignment.wo_start_date ? new Date(assignment.wo_start_date).toLocaleDateString() : 'N/A'} - {assignment.wo_end_date ? new Date(assignment.wo_end_date).toLocaleDateString() : 'N/A'}
-
-
+
+
+
+ Team
+
-
-
-
Team
-
-
-
-
-
+
@@ -199,7 +184,7 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
- {statuslist?.map((history, idx) => (
+ {statuslist?.map((history, idx) =>
- ))}
- {(!statuslist || statuslist.length === 0) && (
-
No history recorded yet.
)}
+ {(!statuslist || statuslist.length === 0) &&
+
No history recorded yet.
+ }
@@ -241,4 +226,46 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
}
>
);
-}
\ No newline at end of file
+}
+
+
+function MetaTile({ icon: Icon, label, value }: { icon: typeof Briefcase; label: string; value: string }) {
+ return (
+
+
+ {label}
+
+
{value}
+
+ );
+}
+
+
+function PartyCard({ label, party, accent }: { label: string; party: any; accent: string }) {
+ function initials(name: string) {
+ return name.split(" ").map((n) => n[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
+ }
+
+ return (
+
+
+ {label}
+
+
+
+ {party.photo ?
+
+ :
+
+ {initials(party.name)}
+
+ }
+
+
+
{party.name}
+
{party.description ?? 'No description available.'}
+
+
+
+ );
+}
diff --git a/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/AssignedPeople.tsx b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/AssignedPeople.tsx
index f590915..61e9b22 100644
--- a/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/AssignedPeople.tsx
+++ b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/AssignedPeople.tsx
@@ -1,14 +1,20 @@
import { ProjectAssignmentWorkOrderDetail } from '@/app/(dashboard)/task/type.assignment';
import { Badge } from '@/components/ui/badge';
+import { Button } from '@/components/ui/button';
import { LazyImage } from '@/components/ui/lazy-image';
import dayjs from 'dayjs';
-import { Mail, Phone, Calendar } from 'lucide-react';
+import { Mail, Phone, Calendar, ChevronDown } from 'lucide-react';
+import { useState } from 'react';
+import { motion, AnimatePresence } from 'motion/react';
interface Props {
people: ProjectAssignmentWorkOrderDetail[];
+ defaultOpen?: boolean;
}
-const AssignedPeople = ({ people }: Props) => {
+const AssignedPeople = ({ people, defaultOpen = true }: Props) => {
+ const [isOpen, setIsOpen] = useState(defaultOpen);
+
if (people.length === 0) {
return (
@@ -20,59 +26,75 @@ const AssignedPeople = ({ people }: Props) => {
return (
{/* Stacked avatars */}
-
-
- {people.slice(0, 5).map((user, i) =>
-
- )}
- {people.length > 5 &&
-
- +{people.length - 5}
-
- }
-
-
-
{people.length} People
-
assigned to this work order
-
-
-
- {/* Detailed list */}
-
- {people.map((user, i) => (
-
-
-
-
-
{user.user.fullname}
-
{user.user.position?.name}
+
+
+
+ {people.slice(0, 5).map((user, i) =>
+
+ )}
+ {people.length > 5 &&
+
+ +{people.length - 5}
-
-
-
-
-
- Assigned
-
-
-
- {user.start_date ? `${dayjs(user.start_date).format('MMMM DD, YYYY')} - ${user.end_date ? dayjs(user.end_date).format('MMMM DD, YYYY') : 'N/A'}` : 'N/A'}
-
-
+ }
- ))}
+
+
{people.length} People
+
assigned to this work order
+
+
+
+
+
+ {isOpen && (
+
+
+ {people.map((user) => (
+
+
+
+
+
{user.user.fullname}
+
{user.user.position?.name}
+
+
+
+
+
+
+ Assigned
+
+
+
+ {user.start_date ? `${dayjs(user.start_date).format('MMMM DD, YYYY')} - ${user.end_date ? dayjs(user.end_date).format('MMMM DD, YYYY') : 'N/A'}` : 'N/A'}
+
+
+
+ ))}
+
+
+ )}
+
);
};
diff --git a/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/page.tsx b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/page.tsx
index 9f9264b..fe39402 100644
--- a/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/page.tsx
+++ b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/page.tsx
@@ -28,8 +28,8 @@ export default async function ProjectDetailPage({ params, searchParams }: Props)
const queryString = getQueryStringFilteredAssignments(searchParams_)
const getClientById = fetchData(`/client/${client_id}`)
- const getAssignmentByProjectId = fetchData(queryString ? `/project/project-assignment/${project_id}?${queryString}` : `/project/project-assignment/${project_id}`)
- // const getAssignmentByProjectId = fetchData(`/project/${project_id}`)
+ // const getAssignmentByProjectId = fetchData(queryString ? `/project/project-assignment/${project_id}?${queryString}` : `/project/project-assignment/${project_id}`)
+ const getAssignmentByProjectId = fetchData(`/project/${project_id}`)
const [client, project] = await Promise.all([getClientById, getAssignmentByProjectId]);
diff --git a/app/(dashboard)/task/component/AddTeam.tsx b/app/(dashboard)/task/component/AddTeam.tsx
index 84c1611..3c62f9c 100644
--- a/app/(dashboard)/task/component/AddTeam.tsx
+++ b/app/(dashboard)/task/component/AddTeam.tsx
@@ -17,10 +17,11 @@ import { useForm } from 'react-hook-form';
import { serverApiCall } from '@/lib/server-api';
import { toast } from 'sonner';
import { ComboboxCustomUI } from '@/components/ui/combobox-custom-ui';
+import type { ProjectAssignmentWorkOrderDetail } from '../type.assignment';
type Props = {
assignmentId: number;
- existingTeam?: number[];
+ existingTeam?: ProjectAssignmentWorkOrderDetail[];
onCancel?: VoidFunction
onSuccess?: VoidFunction;
};
@@ -67,7 +68,10 @@ const AddTeam: FC
= ({ assignmentId, existingTeam, onCancel, onSuccess })
};
const mappedUsers = useMemo(() => {
- return userList?.user?.map((item: IUser) => ({
+ if (!userList?.user) return []
+
+ const filterUser = userList?.user.filter((item: IUser) => existingTeam?.every(team => team.user.id !== item.id)) || []
+ return filterUser?.map((item: IUser) => ({
label: item.fullname,
value: item.id,
originalData: item
diff --git a/app/(dashboard)/task/component/ManageTeam.tsx b/app/(dashboard)/task/component/ManageTeam.tsx
index 6749ef1..ad646c4 100644
--- a/app/(dashboard)/task/component/ManageTeam.tsx
+++ b/app/(dashboard)/task/component/ManageTeam.tsx
@@ -14,7 +14,6 @@ import {
Select, SelectContent, SelectItem, SelectTrigger, SelectValue
} from "@/components/ui/select";
import { DatePicker } from "@/components/ui/datepicker";
-import BadgeStatus from "@/components/ui/badge-status";
import {
AlertDialog, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle
} from "@/components/ui/alert-dialog"
diff --git a/app/(dashboard)/task/component/UpdateTimelineStatus.tsx b/app/(dashboard)/task/component/UpdateTimelineStatus.tsx
index 9957b6f..c201705 100644
--- a/app/(dashboard)/task/component/UpdateTimelineStatus.tsx
+++ b/app/(dashboard)/task/component/UpdateTimelineStatus.tsx
@@ -3,10 +3,6 @@ import {
AlertDialog, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle
} from "@/components/ui/alert-dialog"
import { Button } from '@/components/ui/button';
-import { Textarea } from '@/components/ui/textarea';
-import * as Yup from 'yup'
-import { yupResolver } from '@hookform/resolvers/yup';
-import { useForm } from 'react-hook-form';
import { DatePicker } from '@/components/ui/datepicker';
import { Edit2, Loader2, Save, X } from 'lucide-react';
import { useFetchWithAxios } from '@/lib/axios/useFetch';
@@ -76,10 +72,10 @@ const UpdateTimelineStatus: FC = ({ assignmentId, onClose }) => {
setIsSaving(false);
if (res.success) {
- toast.success('Team updated successfully')
+ toast.success('Status updated successfully')
handleSuccess!()
} else {
- toast.error(`Fail to save team`, { description: `(${res.code || '-'}) ${res.message}` })
+ toast.error(`Fail to save status`, { description: `(${res.code || '-'}) ${res.message}` })
}
};
@@ -138,7 +134,7 @@ const UpdateTimelineStatus: FC = ({ assignmentId, onClose }) => {
:
- existTimeline.map((row: IProjectAssignmentTimeline) => {
+ existTimeline.sort((a: any, b: any) => a.id - b.id).map((row: IProjectAssignmentTimeline) => {
const isEditing = editingId === row.id;
const isOtherRowEditing = editingId !== null && editingId !== row.id;
diff --git a/app/globals.css b/app/globals.css
index 1380e4f..ba99181 100644
--- a/app/globals.css
+++ b/app/globals.css
@@ -8,6 +8,9 @@
--color-his: #EA512C;
--color-soft: #f6f6f6;
+ /* --type-memo: #925cf0;
+ --type-wo: #fa832e; */
+
--color-background: var(--background);
--color-foreground: var(--foreground);
--font-sans: var(--font-geist-sans);
@@ -48,6 +51,9 @@
}
:root {
+ --type-memo: hsl(262 83% 65%);
+ --type-wo: hsl(25 95% 58%);
+
--radius: 0.625rem;
--background: oklch(1 0 0);
--foreground: oklch(0.141 0.005 285.823);