fix: doctor toggle logic
This commit is contained in:
@@ -8,8 +8,10 @@ export interface Doctor {
|
||||
designation?: string;
|
||||
workingStatus?: string;
|
||||
qualification?: string;
|
||||
isActive: boolean;
|
||||
globalSortOrder: number;
|
||||
|
||||
departments: {
|
||||
departments?: {
|
||||
departmentId: string;
|
||||
timing?: {
|
||||
monday?: string;
|
||||
|
||||
@@ -158,8 +158,14 @@ export default function DoctorPage() {
|
||||
|
||||
const handleToggleStatus = async (doc: any) => {
|
||||
try {
|
||||
const updatedDoc = { ...doc, isActive: !doc.isActive };
|
||||
await updateDoctorApi(doc.doctorId, updatedDoc);
|
||||
const newStatus = !doc.isActive;
|
||||
|
||||
const payload = {
|
||||
isActive: newStatus,
|
||||
};
|
||||
|
||||
await updateDoctorApi(doc.doctorId, payload);
|
||||
|
||||
fetchAll();
|
||||
} catch (err) {
|
||||
console.error("Failed to update status", err);
|
||||
|
||||
Reference in New Issue
Block a user