From a4f0087b6c16f6e7a981457ceb4d95c6c3b558ac Mon Sep 17 00:00:00 2001 From: Ichsan Kurniawan Date: Fri, 17 Apr 2026 17:16:47 +0700 Subject: [PATCH] Add project detail UI and unified status badges Introduce project detail screens and reusable status UI. Adds ProjectDetailComponent, WorkOrderCard, StatusTimeline, AssignedPeople, and a new BadgeStatus component with STATUS_BADGE_MAP and STATUS_LIST in badge.tsx to centralize status styling. Adds IProject type (type.project.ts) and project detail page routing. Update existing client/assignment views to use BadgeStatus, improve UI copy and link behavior (ExternalLink icon), handle nullable end dates in forms, include client_id in payload, and improve empty-state handling and descriptions. Misc: rename assignment page export, tweak form labels/placeholders, and small layout/UX refinements. --- .../(main)/ClientDetailComponent.tsx | 49 +++-- .../client-detail/[client_id]/(main)/page.tsx | 3 +- .../AssignmentDetailComponent.tsx | 35 +--- .../[client_id]/[assignment_id]/page.tsx | 2 +- .../ProjectAssignmentForm.tsx | 57 +++-- .../[project_id]/AssignedPeople.tsx | 105 ++++++++++ .../[project_id]/ProjectDetailComponent.tsx | 197 ++++++++++++++++++ .../[project_id]/StatusTimeline.tsx | 64 ++++++ .../[project_id]/WorkOrderCard.tsx | 126 +++++++++++ .../project-detail/[project_id]/page.tsx | 35 ++++ .../task/component/FormUpdateStatus.tsx | 2 +- app/(dashboard)/task/type.project.ts | 14 ++ components/ui/badge-status.tsx | 12 ++ components/ui/badge.tsx | 39 ++++ 14 files changed, 675 insertions(+), 65 deletions(-) create mode 100644 app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/AssignedPeople.tsx create mode 100644 app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/ProjectDetailComponent.tsx create mode 100644 app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/StatusTimeline.tsx create mode 100644 app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/WorkOrderCard.tsx create mode 100644 app/(dashboard)/task/type.project.ts create mode 100644 components/ui/badge-status.tsx diff --git a/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientDetailComponent.tsx b/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientDetailComponent.tsx index 6b103f4..4ec8d35 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientDetailComponent.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientDetailComponent.tsx @@ -3,7 +3,7 @@ import { useState } from 'react'; import { motion } from 'motion/react'; -import { Briefcase, Clock, Users, MoreVertical, Check, Calendar as CalendarIcon, LayoutGrid, Table as TableIcon } from 'lucide-react'; +import { Briefcase, Clock, Users, MoreVertical, Check, Calendar as CalendarIcon, LayoutGrid, Table as TableIcon, ExternalLink } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Card, Card900, CardContent } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; @@ -18,6 +18,7 @@ import { IProjectAssignment } from '../../../type.assignment'; import ManageEmployee from '../../../component/ManageEmployee'; import { useRouter } from 'next/navigation'; import FormUpdateStatus from '../../../component/FormUpdateStatus'; +import BadgeStatus from '@/components/ui/badge-status'; interface Props { clientId: string; @@ -85,6 +86,7 @@ export default function ClientDetailComponent({ clientId, initialAssignments }: const isProject = assignment.project.code const assignmentType = isProject ? 'Project' : 'IM' + const assignmentName = assignment.project.name || assignment.im_name const assignmentStartDate = assignment.project.start_date || assignment.im_start_date const assignmentEndDate = assignment.project.end_date || assignment.im_end_date const assignmentDesc = assignment.project.description || assignment.im_description @@ -93,26 +95,33 @@ export default function ClientDetailComponent({ clientId, initialAssignments }: return ( - +
{isProject ? : }
-
-

{assignment.project.name || assignment.im_name}

- - {assignmentType} - - - {assignmentStatus} - -
+ {isProject ? + +
+
+

{assignmentName}

+ +
+ {assignmentType} + +
+ + : +
+

{assignmentName}

+ {assignmentType} + +
+ } {assignment.wo_code && (

@@ -158,7 +167,7 @@ export default function ClientDetailComponent({ clientId, initialAssignments }: +{assignment.project_assignment_work_order_detail?.length - 3}

)} - {!assignment.project_assignment_work_order_detail && No employees assigned} + {assignment.project_assignment_work_order_detail && assignment.project_assignment_work_order_detail.length === 0 && No employees assigned}
@@ -254,13 +263,7 @@ export default function ClientDetailComponent({ clientId, initialAssignments }: {assignment.wo_end_date ? new Date(assignment.wo_end_date).toLocaleDateString() : '-'} - - {assignment.status.name} - + diff --git a/app/(dashboard)/task/client-detail/[client_id]/(main)/page.tsx b/app/(dashboard)/task/client-detail/[client_id]/(main)/page.tsx index 4e997a0..10885e5 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/(main)/page.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/(main)/page.tsx @@ -17,7 +17,8 @@ export default async function ClientDetailPage({ params }: Props) { const { client_id } = await params; const getClientById = fetchData(`/client/${client_id}`) - const getAssignmentsByClient = fetchData('/project-assignment') + // const getAssignmentsByClient = fetchData(`/client/project-assignment/${client_id}`) + const getAssignmentsByClient = fetchData(`/project-assignment`) const [client, assignmentList] = await Promise.all([getClientById, getAssignmentsByClient]); 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 29d3726..d03ae06 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 @@ -14,6 +14,7 @@ import { IClient } from '../../../types'; import { IProjectAssignment } from '../../../type.assignment'; import { useState } from 'react'; import FormUpdateStatus from '../../../component/FormUpdateStatus'; +import BadgeStatus from '@/components/ui/badge-status'; interface Props { client: IClient | undefined; @@ -27,7 +28,6 @@ export default function AssignmentDetail({ client, initialAssignment: assignment const router = useRouter(); const isProject = assignment.project.code - const title = isProject ? 'Project Detail' : 'Internal Memo Detail'; const assignmentType = isProject ? 'Project' : 'IM' const assignmentName = assignment.project.name || assignment.im_name @@ -58,17 +58,14 @@ export default function AssignmentDetail({ client, initialAssignment: assignment {/* Header */}
-
-

{title}

+

Assignment Detail

{assignmentType} @@ -107,14 +104,7 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
- - {assignmentStatus} - +
@@ -133,7 +123,7 @@ export default function AssignmentDetail({ client, initialAssignment: assignment
-

{assignmentDesc}

+

{assignmentDesc ?? 'No description available for this assignment!'}

@@ -160,13 +150,7 @@ export default function AssignmentDetail({ client, initialAssignment: assignment

{assignment.wo_name}

- - {assignment.status.name || 'Active'} - +

{assignment.wo_description}

@@ -189,9 +173,10 @@ export default function AssignmentDetail({ client, initialAssignment: assignment {/* WO Status History Mini-Timeline */} {assignment.project_assignment_status_detail && assignment.project_assignment_status_detail.length > 0 && (
-

WO Status History

+

Team

- {assignment.project_assignment_status_detail.map((history) => ( + {assignment.project_assignment_work_order_detail && assignment.project_assignment_work_order_detail.length === 0 && No employees assigned} + {assignment.project_assignment_work_order_detail.map((history) => (
@@ -218,7 +203,7 @@ export default function AssignmentDetail({ client, initialAssignment: assignment - {assignmentType} History + Assignment History Timeline of status changes diff --git a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/page.tsx b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/page.tsx index adb0a5f..5310544 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/page.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/[assignment_id]/page.tsx @@ -7,7 +7,7 @@ type Props = { params: Promise<{ client_id: string; assignment_id: string }> }; -export default async function ProjectOrIMDetailPage({ params }: Props) { +export default async function AssignmentDetailPage({ params }: Props) { const { client_id, assignment_id } = await params; const getClientById = fetchData(`/client/${client_id}`) diff --git a/app/(dashboard)/task/client-detail/[client_id]/project-assignments/ProjectAssignmentForm.tsx b/app/(dashboard)/task/client-detail/[client_id]/project-assignments/ProjectAssignmentForm.tsx index 5ee996c..2ab2fcc 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/project-assignments/ProjectAssignmentForm.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/project-assignments/ProjectAssignmentForm.tsx @@ -41,7 +41,7 @@ export const assignmentSchema = yup.object({ code: yup.string().required('Project code is required'), year: yup.string().required('Year is required'), startDate: yup.date().required('Start date is required'), - endDate: yup.date().min(yup.ref('startDate'), 'End date cannot be before start date').required('End date is required'), + endDate: yup.date().nullable().min(yup.ref('startDate'), 'End date cannot be before start date').default(null), description: yup.string().optional().nullable().default(''), // Work Orders Step (Conditional based on 'type') @@ -51,7 +51,7 @@ export const assignmentSchema = yup.object({ name: yup.string().required('Work order name is required'), code: yup.string().required('Work order code is required'), startDate: yup.date().required('Start date is required'), - endDate: yup.date().required('End date is required'), + endDate: yup.date().nullable().default(null), description: yup.string().optional().nullable().default(''), }), otherwise: (schema) => schema.nullable().notRequired() @@ -104,7 +104,6 @@ export default function CreateAssignmentForm({ client, clientId, projectList, is const currentStepIndex = steps.findIndex(s => s.id === step); - useEffect(() => { if (!isEdit) return @@ -171,6 +170,7 @@ export default function CreateAssignmentForm({ client, clientId, projectList, is setIsLoading(true); const newPayload = { + "client_id": clientId, "im_code": assignmentType === 'IM' ? payload.code : isEdit ? existAssignment?.im_code : "", "im_name": assignmentType === 'IM' ? payload.name : isEdit ? existAssignment?.im_name : "", "im_year": assignmentType === 'IM' ? Number(payload.year) : isEdit ? existAssignment?.im_year : 2026, @@ -191,7 +191,7 @@ export default function CreateAssignmentForm({ client, clientId, projectList, is "wo_start_date": (payload.workOrder as any).startDate ? dayjs((payload.workOrder as any).startDate).format('YYYY-MM-DD') : '', "wo_end_date": (payload.workOrder as any).endDate ? dayjs((payload.workOrder as any).endDate).format('YYYY-MM-DD') : '', "wo_description": (payload.workOrder as any).description, - "wo_warranty": isEdit ? existAssignment?.wo_warranty : '2026-04-16', + "wo_warranty": isEdit ? existAssignment?.wo_warranty : '', "note": isEdit ? existAssignment?.note : "", } @@ -224,7 +224,7 @@ export default function CreateAssignmentForm({ client, clientId, projectList, is
-

Create Project Assignment

+

{isEdit ? 'Update' : 'Create Project'} Assignment

For {client.name}

@@ -321,11 +321,11 @@ export default function CreateAssignmentForm({ client, clientId, projectList, is name="name" render={({ field }) => ( - Assignment Name + {assignmentType === 'Project' ? "Project" : "Internal Memo"} Name
- + {assignmentType === 'Project' && (
@@ -403,7 +403,7 @@ export default function CreateAssignmentForm({ client, clientId, projectList, is ( End Date - + )} /> @@ -492,7 +492,7 @@ export default function CreateAssignmentForm({ client, clientId, projectList, is
- {formValues.type} + {formValues.type}
@@ -504,6 +504,24 @@ export default function CreateAssignmentForm({ client, clientId, projectList, is

{formValues.name || 'Untitled Assignment'}

+
+
+ +

{formValues.code || 'N/A'}

+
+
+ +

{formValues.year || 'N/A'}

+
+
+ +

{formValues.startDate ? dayjs(formValues.startDate).format('MMMM DD, YYYY') : 'N/A'}

+
+
+ +

{formValues.endDate ? dayjs(formValues.endDate).format('MMMM DD, YYYY') : 'N/A'}

+
+

{formValues.description || 'No description provided.'}

@@ -514,13 +532,24 @@ export default function CreateAssignmentForm({ client, clientId, projectList, is
-
-
- 1 +
+
+ +

{(formValues.workOrder as any).name || 'Untitled Work Order'} ({(formValues.workOrder as any).code})

+
+
+
+ +

{(formValues.workOrder as any).startDate ? dayjs((formValues.workOrder as any).startDate).format('MMMM DD, YYYY') : 'N/A'}

+
+
+ +

{(formValues.workOrder as any).endDate ? dayjs((formValues.workOrder as any).endDate).format('MMMM DD, YYYY') : 'N/A'}

+
-

{(formValues.workOrder as any).name}

-

{(formValues.workOrder as any).description}

+ +

{(formValues.workOrder as any).description || 'No description provided.'}

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 new file mode 100644 index 0000000..cb8cb9a --- /dev/null +++ b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/AssignedPeople.tsx @@ -0,0 +1,105 @@ +import { Mail, Phone, Calendar } from 'lucide-react'; + +interface AssignedPeopleProps { + people: any[]; +} + +const avatarGradients = [ + 'from-rose-500 to-pink-600', + 'from-sky-500 to-blue-600', + 'from-amber-500 to-orange-600', + 'from-emerald-500 to-green-600', + 'from-violet-500 to-purple-600', + 'from-cyan-500 to-teal-600', +]; + +const getInitials = (name: string) => + name.split(' ').map((n) => n[0]).slice(0, 2).join('').toUpperCase(); + +const AssignedPeople = ({ people }: AssignedPeopleProps) => { + if (people.length === 0) { + return ( +
+ No people assigned yet +
+ ); + } + + const formatDate = (date: string) => + new Date(date).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' }); + + return ( +
+ {/* Stacked avatars */} +
+
+ {people.slice(0, 5).map((person, i) => ( +
+ {getInitials(person.name)} +
+ ))} + {people.length > 5 && ( +
+ +{people.length - 5} +
+ )} +
+
+

{people.length} People

+

assigned to this work order

+
+
+ + {/* Detailed list */} +
+ {people.map((person, i) => ( +
+
+ {getInitials(person.name)} +
+ +
+
+

{person.name}

+ + {person.role} + +
+
+ + + {person.email} + + + + {person.phone} + +
+
+ +
+ + Assigned + + + + {formatDate(person.assigned_date)} + +
+
+ ))} +
+
+ ); +}; + +export default AssignedPeople; diff --git a/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/ProjectDetailComponent.tsx b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/ProjectDetailComponent.tsx new file mode 100644 index 0000000..b71ba54 --- /dev/null +++ b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/ProjectDetailComponent.tsx @@ -0,0 +1,197 @@ +"use client" + +import { motion } from 'motion/react'; +import { ArrowLeft, Briefcase, Calendar, CheckCircle2, History, AlertCircle } 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 { useState } from 'react'; +import FormUpdateStatus from '@/app/(dashboard)/task/component/FormUpdateStatus'; +import { IClient } from '@/app/(dashboard)/task/types'; +import { IProjectAssignment } from '@/app/(dashboard)/task/type.assignment'; +import { IProject } from '@/app/(dashboard)/task/type.project'; +import BadgeStatus from '@/components/ui/badge-status'; + +interface Props { + client: IClient | undefined; + project: IProject; +} + +export default function ProjectDetailComponent({ client, project }: Props) { + const [action, setAction] = useState<'ASSIGNMENT' | 'WO' | undefined>() + const [selectedData, setSelectedData] = useState() + + const router = useRouter(); + + const handleClose = () => { + setSelectedData(undefined) + setAction(undefined) + } + + const handleSuccess = () => { + router.refresh() + handleClose() + } + + return ( + <> + + {/* Header */} +
+
+ +
+

Project Detail

+ Project +
+
+

{project.name}

+
+
+

+ Code: {project.code || 'N/A'} +

+ +

+ Year: {project.year || 'N/A'} +

+
+
+
+ +
+ {/* Left Column: Details & Work Orders */} +
+ {/* Overview Card */} + + + Overview + + +
+
+ +
+ +
+
+
+ +

{project.start_date ? new Date(project.start_date).toLocaleDateString() : 'N/A'}

+
+
+ +

{project.end_date ? new Date(project.end_date).toLocaleDateString() : 'N/A'}

+
+
+ +

{client?.name}

+
+
+ +
+ +

{project.description ?? 'No description available for this project!'}

+
+
+
+ + {/* Work Orders Section */} +
+
+

+ Work Orders ({project.project_assignment.length}) +

+
+ + {!project.project_assignment || project.project_assignment.length === 0 ? + + + No work orders defined for this assignment. + + + : + project.project_assignment.map((assignment, key) => +
+ + +
+
+
+

{assignment.wo_name}

+ +
+

{assignment.wo_description ?? 'No description available for this project!'}

+
+ + 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'} + +
+
+
+ +
+
+ + {/* WO Status History Mini-Timeline */} + {assignment.project_assignment_status_detail && assignment.project_assignment_status_detail.length > 0 && ( +
+

WO Status History

+
+ {assignment.project_assignment_status_detail.map((history) => ( +
+
+
+
+ {history.status} + {new Date(history.date_status_changed).toLocaleDateString()} +
+

{history.status_remarks}

+
+
+ ))} +
+
+ )} + + +
+ ) + } +
+
+
+ + + {action === 'ASSIGNMENT' ? + + : null + } + + {action === 'WO' ? + + : null + } + + ); +} \ No newline at end of file diff --git a/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/StatusTimeline.tsx b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/StatusTimeline.tsx new file mode 100644 index 0000000..3a97567 --- /dev/null +++ b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/StatusTimeline.tsx @@ -0,0 +1,64 @@ +import { ProjectAssignmentStatusDetail } from '@/app/(dashboard)/task/type.assignment'; +import BadgeStatus from '@/components/ui/badge-status'; +import { Clock } from 'lucide-react'; + +interface StatusTimelineProps { + history: ProjectAssignmentStatusDetail[]; +} + +const StatusTimeline = ({ history }: StatusTimelineProps) => { + const formatDate = (date: string) => { + const d = new Date(date); + return { + date: d.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' }), + time: d.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' }), + }; + }; + + return ( +
+ {/* Vertical connector line */} +
+ +
+ {history.map((item, i) => { + const { date, time } = formatDate(item.date_status_changed); + const isLatest = i === history.length - 1; + + return ( +
+ {/* Dot */} +
+
+
+
+ {isLatest &&
} +
+ + {/* Content */} +
+
+ + {isLatest && Current} +
+
+ + {date} + · + {time} +
+ {item.status_remarks && +

+ {item.status_remarks} +

+ } +
+
+ ); + })} +
+
+ ); +}; + +export default StatusTimeline; diff --git a/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/WorkOrderCard.tsx b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/WorkOrderCard.tsx new file mode 100644 index 0000000..b6d3144 --- /dev/null +++ b/app/(dashboard)/task/client-detail/[client_id]/project-detail/[project_id]/WorkOrderCard.tsx @@ -0,0 +1,126 @@ +import { useState } from 'react'; +import { ChevronDown, Calendar, FileText, History, Users, StickyNote } from 'lucide-react'; +import { Card900 } from '@/components/ui/card'; +import { Button } from '@/components/ui/button'; +import StatusTimeline from './StatusTimeline'; +import AssignedPeople from './AssignedPeople'; +import BadgeStatus from '@/components/ui/badge-status'; +import { IProjectAssignment } from '@/app/(dashboard)/task/type.assignment'; + +interface WorkOrderCardProps { + workOrder: IProjectAssignment; + index: number; + defaultOpen?: boolean; +} + +const WorkOrderCard = ({ workOrder, index, defaultOpen = false }: WorkOrderCardProps) => { + const [isOpen, setIsOpen] = useState(defaultOpen); + + const formatDate = (date: string) => + new Date(date).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' }); + + return ( + + {/* Header (always visible) */} +
+
+ {/* Index badge */} +
+ + {String(index + 1).padStart(2, '0')} + +
+ +
+
+

+ {workOrder.wo_name} +

+ +
+
+ + + {workOrder.wo_code} + + + + + {formatDate(workOrder.wo_start_date)} → {formatDate(workOrder.wo_end_date)} + + + + + {workOrder.project_assignment_work_order_detail.length} assigned + +
+
+
+ + {/* Description */} + {workOrder.wo_description && +

+ {workOrder.wo_description} +

+ } + + {/* Toggle button - full width on mobile */} + +
+ + {/* Expandable content */} + {isOpen && +
+ {workOrder.note && ( +
+ +
+

Note

+

{workOrder.note}

+
+
+ )} + +
+ {/* Status history */} +
+
+
+ +
+
+

Status History

+

+ {workOrder.project_assignment_status_detail.length} status changes +

+
+
+ +
+ + {/* Assigned people */} +
+
+
+ +
+
+

Assigned People

+

Team members on this work order

+
+
+ +
+
+
+ } +
+ ); +}; + +export default WorkOrderCard; 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 e69de29..5b654bd 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 @@ -0,0 +1,35 @@ +import { Button } from '@/components/ui/button'; +import Link from 'next/link'; +import fetchData from '@/lib/fetchData'; +import ProjectDetailComponent from './ProjectDetailComponent'; + +type Props = { + params: Promise<{ client_id: string; project_id: string }> +}; + +export default async function ProjectDetailPage({ params }: Props) { + const { client_id, project_id } = await params; + + const getClientById = fetchData(`/client/${client_id}`) + const getAssignmentByProjectId = fetchData(`/project/${project_id}`) + + const [client, project] = await Promise.all([getClientById, getAssignmentByProjectId]); + + // 3. Handle 404 Securely on the server + if (!project) { + return ( +
+

Project not found

+ + + +
+ ); + } + + + // 4. Pass the fetched data to the interactive Client Component + return ( + + ); +} \ No newline at end of file diff --git a/app/(dashboard)/task/component/FormUpdateStatus.tsx b/app/(dashboard)/task/component/FormUpdateStatus.tsx index 08f5250..0dc8e37 100644 --- a/app/(dashboard)/task/component/FormUpdateStatus.tsx +++ b/app/(dashboard)/task/component/FormUpdateStatus.tsx @@ -55,7 +55,7 @@ const FormUpdateStatus: FC = ({ title, data, onCancel, onSuccess }) => { ( - Kategori + Status