mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:46:29 +00:00
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.
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -63,58 +63,6 @@ export default async function ClientDetailPage({ params, searchParams }: Props)
|
||||
clientId={client_id}
|
||||
assignmentLists={filterAssignments}
|
||||
/>
|
||||
{/* <div className="grid gap-8 lg:grid-cols-3">
|
||||
|
||||
<div className="lg:col-span-2 space-y-6">
|
||||
<ClientDetailComponent
|
||||
clientId={client_id}
|
||||
assignmentLists={filterData()}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-6">
|
||||
<Card900>
|
||||
<CardHeader>
|
||||
<CardTitle>Client Info</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div>
|
||||
<Label className="text-xs text-muted-foreground uppercase tracking-wider">Client Name</Label>
|
||||
<p className="font-medium">{client.name}</p>
|
||||
</div>
|
||||
<div>
|
||||
<Label className="text-xs text-muted-foreground uppercase tracking-wider">End User</Label>
|
||||
<p className="font-medium">{client.end_user_name}</p>
|
||||
</div>
|
||||
<Separator />
|
||||
<div>
|
||||
<Label className="text-xs text-muted-foreground uppercase tracking-wider">Created At</Label>
|
||||
<p className="font-medium">{new Date(client.created_at).toLocaleDateString()}</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card900>
|
||||
|
||||
<Card900>
|
||||
<CardHeader>
|
||||
<CardTitle>Quick Stats</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-sm text-muted-foreground">Total Projects</span>
|
||||
<span className="font-bold">{client?.total_project || 0}</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-sm text-muted-foreground">Total IMs</span>
|
||||
<span className="font-bold">{client?.total_im || 0}</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-sm text-muted-foreground">Total WOs</span>
|
||||
<span className="font-bold">{client?.total_work_order || 0}</span>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card900>
|
||||
</div>
|
||||
</div> */}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+2
-2
@@ -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"
|
||||
>
|
||||
|
||||
@@ -311,7 +311,15 @@ export function ManageTeam({ assignmentId, onClose, startDate, endDate }: { assi
|
||||
}
|
||||
|
||||
{deletedId ?
|
||||
<ConfirmDelete description="This action cannot be undone. This will permanently delete this user from this assignment." endpoint={`/project-assignment/assign-user/delete/${deletedId}`}
|
||||
<ConfirmDelete description="This action cannot be undone. This will permanently delete this user from this assignment."
|
||||
endpoint={`/project-assignment/assign-user/update/${deletedId}`}
|
||||
method='PUT'
|
||||
payload={
|
||||
{
|
||||
"project_assignment_id": assignmentId,
|
||||
"status": "REMOVED",
|
||||
}
|
||||
}
|
||||
onCancel={handleCancel} onSuccess={handleSuccess}
|
||||
/>
|
||||
: null
|
||||
|
||||
@@ -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.';
|
||||
|
||||
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user