From fccb901e2afa6483417755b0f4ca93fe0a42f580 Mon Sep 17 00:00:00 2001 From: Ichsan Kurniawan Date: Tue, 13 Oct 2026 16:56:20 +0700 Subject: [PATCH] Fix assignment deletion and team removal This update changes assignment deletion labels to prefer WO/IM names, adds a configurable payload to ConfirmDelete for non-DELETE API calls, and switches team member removal to a PUT endpoint with status REMOVED. It also shortens project autofill toast duration, cleans out stale commented code on the client detail page, and updates the task error badge wording to better reflect app-level failures. --- .../(main)/ClientDetailComponent.tsx | 4 +- .../client-detail/[client_id]/(main)/page.tsx | 52 ------------------- .../ProjectAssignmentForm.tsx | 4 +- app/(dashboard)/task/component/ManageTeam.tsx | 10 +++- app/(dashboard)/task/error.tsx | 2 +- components/modal/ConfirmDelete.tsx | 5 +- 6 files changed, 17 insertions(+), 60 deletions(-) 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 902a271..d94fa52 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientDetailComponent.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/(main)/ClientDetailComponent.tsx @@ -171,8 +171,8 @@ export default function ClientDetailComponent({ clientId, assignmentLists }: Pro 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.`} + title={selectedData.wo_name || selectedData.im_name || selectedData.project?.name || 'Project Assignment'} + description={`This action cannot be undone. This will permanently delete and remove project assignment ${selectedData.wo_name || selectedData.im_name || selectedData.project?.name || ''} from our servers.`} titleButton="I understand the consequences, delete this assignment" /> ) : null} 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 5e99a1f..2cbd39d 100644 --- a/app/(dashboard)/task/client-detail/[client_id]/(main)/page.tsx +++ b/app/(dashboard)/task/client-detail/[client_id]/(main)/page.tsx @@ -63,58 +63,6 @@ export default async function ClientDetailPage({ params, searchParams }: Props) clientId={client_id} assignmentLists={filterAssignments} /> - {/*
- -
- -
- -
- - - Client Info - - -
- -

{client.name}

-
-
- -

{client.end_user_name}

-
- -
- -

{new Date(client.created_at).toLocaleDateString()}

-
-
-
- - - - Quick Stats - - -
- Total Projects - {client?.total_project || 0} -
-
- Total IMs - {client?.total_im || 0} -
-
- Total WOs - {client?.total_work_order || 0} -
-
-
-
-
*/} ); } \ No newline at end of file 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 a9c64b2..59ef240 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 @@ -631,7 +631,7 @@ export default function ProjectAssignmentForm( setOpenProjectSearch(false); setIsExistProject(p); - toast.info(`Autofilled details from ${p.name}`); + toast.info(`Autofilled details from ${p.name}`, { duration: 1500 }); }} className="cursor-pointer py-2.5 px-3" > @@ -702,7 +702,7 @@ export default function ProjectAssignmentForm( setOpenProjectSearch(false); setIsExistProject(p); - toast.info(`Switched project to ${p.name}`); + toast.info(`Switched project to ${p.name}`, { duration: 1500 }); }} className="cursor-pointer py-2.5 px-3" > diff --git a/app/(dashboard)/task/component/ManageTeam.tsx b/app/(dashboard)/task/component/ManageTeam.tsx index e53c186..7063b0d 100644 --- a/app/(dashboard)/task/component/ManageTeam.tsx +++ b/app/(dashboard)/task/component/ManageTeam.tsx @@ -311,7 +311,15 @@ export function ManageTeam({ assignmentId, onClose, startDate, endDate }: { assi } {deletedId ? - : null diff --git a/app/(dashboard)/task/error.tsx b/app/(dashboard)/task/error.tsx index f2edbba..7347e1f 100644 --- a/app/(dashboard)/task/error.tsx +++ b/app/(dashboard)/task/error.tsx @@ -77,7 +77,7 @@ export default function TaskError({ error, reset }: TaskErrorProps) { rawMessage.toLowerCase().includes('timeout'); // Context-sensitive status title and human-friendly explanation - let badgeText = 'Backend Service Disconnected'; + let badgeText = 'Application Error'; let headline = 'Unable to Load Task & Client Data'; let friendlyDescription = 'The system was unable to retrieve client records and task assignments from the backend service. This usually occurs when the backend server is temporarily unreachable, restarting, or under maintenance.'; diff --git a/components/modal/ConfirmDelete.tsx b/components/modal/ConfirmDelete.tsx index 7b85073..bf1c203 100644 --- a/components/modal/ConfirmDelete.tsx +++ b/components/modal/ConfirmDelete.tsx @@ -14,16 +14,17 @@ interface Props { title?: string description?: string, method?: any + payload?: any } -export function ConfirmDelete({ endpoint, title, description, onSuccess, onCancel, method }: Props) { +export function ConfirmDelete({ endpoint, title, description, onSuccess, onCancel, method, payload }: Props) { const [isLoading, setIsLoading] = useState(false); const handleDelete = async () => { setIsLoading(true) const toastId = toast.loading('Deleting data...'); try { - const res = await serverApiCall(method || 'DELETE', endpoint!) + const res = await serverApiCall(method || 'DELETE', endpoint!, payload) if (res.success) { toast.success("Data deleted successfully ☺️", { id: toastId });