- {item.number}
+
+ handleToggleStatus(item)}
+ />
+
+ {item.isActive ? "Active" : "Hidden"}
+
-
-
- {item.isActive ? "Active" : "Hidden"}
-
-
@@ -275,15 +277,6 @@ export default function CareerPage() {
>
-
-
handleDelete(item.id)}
- >
-
-
diff --git a/frontend/src/pages/Department.tsx b/frontend/src/pages/Department.tsx
index 51eef61..d2b415a 100644
--- a/frontend/src/pages/Department.tsx
+++ b/frontend/src/pages/Department.tsx
@@ -6,7 +6,6 @@ import {
getDepartmentsApi,
createDepartmentApi,
updateDepartmentApi,
- deleteDepartmentApi,
} from "@/api/department";
import {
@@ -40,7 +39,6 @@ import {
RefreshCw,
Plus,
Pencil,
- Trash,
Eye,
ChevronLeft,
ChevronRight,
@@ -134,10 +132,18 @@ export default function DepartmentPage() {
setForm({...form, [e.target.name]: value});
}
- function truncate(text: string, limit = 60) {
- if (!text) return "-";
- return text.length > limit ? text.substring(0, limit) + "..." : text;
- }
+ const handleToggleStatus = async (dep: Department) => {
+ try {
+ const {departmentId, ...updateData} = dep;
+ await updateDepartmentApi(departmentId, {
+ ...updateData,
+ isActive: !dep.isActive,
+ } as any);
+ fetchDepartments();
+ } catch (error) {
+ console.error("Failed to toggle status", error);
+ }
+ };
function openAdd() {
setEditing(null);
@@ -175,7 +181,7 @@ export default function DepartmentPage() {
try {
if (editing) {
const {departmentId, ...updateData} = form;
- await updateDepartmentApi(editing.departmentId, updateData);
+ await updateDepartmentApi(editing.departmentId, form as any);
} else {
await createDepartmentApi(form);
}
@@ -187,17 +193,6 @@ export default function DepartmentPage() {
}
}
- async function handleDelete(id: string) {
- if (!confirm("Delete this department?")) return;
-
- try {
- await deleteDepartmentApi(id);
- fetchDepartments();
- } catch (error) {
- console.error(error);
- }
- }
-
return (
@@ -241,25 +236,19 @@ export default function DepartmentPage() {
-
+
-
+
Priority
-
+
Name
-
- Status
+
+ Status (Active)
-
- Para 1
-
-
- Facilities
-
-
+
Actions
@@ -268,14 +257,14 @@ export default function DepartmentPage() {
{loading ? (
-
+
) : currentItems.length === 0 ? (
No departments found
@@ -302,22 +291,17 @@ export default function DepartmentPage() {
{dep.departmentId}
-
-
- {dep.isActive ? "Active" : "Hidden"}
-
-
-
-
-
- {truncate(dep.para1)}
-
-
-
-
-
- {truncate(dep.facilities)}
+
+ handleToggleStatus(dep)}
+ />
+
+ {dep.isActive ? "Active" : "Hidden"}
+
@@ -340,15 +324,6 @@ export default function DepartmentPage() {
>
-
-
handleDelete(dep.departmentId)}
- >
-
-
@@ -469,7 +444,6 @@ export default function DepartmentPage() {
placeholder="Services"
/>
- {/* Status and Priority at bottom to keep original UI flow */}
diff --git a/frontend/src/pages/Doctor.tsx b/frontend/src/pages/Doctor.tsx
index 87ae4a2..34d8d8e 100644
--- a/frontend/src/pages/Doctor.tsx
+++ b/frontend/src/pages/Doctor.tsx
@@ -7,7 +7,6 @@ import {
getDoctorsApi,
createDoctorApi,
updateDoctorApi,
- deleteDoctorApi,
getDoctorTimingApi,
} from "@/api/doctor";
import { getDepartmentsApi } from "@/api/department";
@@ -39,7 +38,6 @@ import {
RefreshCw,
Plus,
Pencil,
- Trash,
ChevronLeft,
ChevronRight,
} from "lucide-react";
@@ -139,6 +137,16 @@ export default function DoctorPage() {
setForm({ ...form, [e.target.name]: value });
}
+ const handleToggleStatus = async (doc: any) => {
+ try {
+ const updatedDoc = { ...doc, isActive: !doc.isActive };
+ await updateDoctorApi(doc.doctorId, updatedDoc);
+ fetchAll();
+ } catch (err) {
+ console.error("Failed to update status", err);
+ }
+ };
+
function handleDepartmentToggle(depId: string) {
const exists = form.departments.find((d: any) => d.departmentId === depId);
if (exists) {
@@ -236,16 +244,6 @@ export default function DoctorPage() {
}
}
- async function handleDelete(id: string) {
- if (!confirm("Delete this doctor?")) return;
- try {
- await deleteDoctorApi(id);
- fetchAll();
- } catch (error) {
- console.error(error);
- }
- }
-
return (
@@ -308,19 +306,19 @@ export default function DoctorPage() {
Priority{" "}
-
+
Doctor Info
-
- Status
-
Designation
Departments (Hierarchy)
-
+
+ Status (Active)
+
+
Actions
@@ -361,12 +359,6 @@ export default function DoctorPage() {
-
-
- {doc.isActive ? "Active" : "Hidden"}
-
-
-
+
+
+ handleToggleStatus(doc)}
+ />
+
+ {doc.isActive ? "Active" : "Hidden"}
+
+
+
+
-
handleDelete(doc.doctorId)}
- >
-
-
@@ -622,8 +620,6 @@ export default function DoctorPage() {
const depName = departments.find(
(d) => d.departmentId === dep.departmentId,
)?.name;
- console.log("doctor department sortOrder", dep.sortOrder);
- console.log("dep", dep);
return (