Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update frontend/src/pages/SuperAdminPanel.jsx
Browse files
frontend/src/pages/SuperAdminPanel.jsx
CHANGED
|
@@ -876,6 +876,19 @@ const SuperAdminPanel = () => {
|
|
| 876 |
}
|
| 877 |
};
|
| 878 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 879 |
const handleOpenReschedule = (booking) => {
|
| 880 |
const rawDate = booking.meeting_date || '';
|
| 881 |
const rawTime = booking.meeting_time || '';
|
|
@@ -923,24 +936,36 @@ const SuperAdminPanel = () => {
|
|
| 923 |
}
|
| 924 |
};
|
| 925 |
|
| 926 |
-
const handleDeleteBooking =
|
| 927 |
-
|
| 928 |
-
|
| 929 |
-
|
| 930 |
-
|
| 931 |
-
|
| 932 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 933 |
}
|
| 934 |
-
|
| 935 |
-
if (res.ok) {
|
| 936 |
-
toast.success("Demo lead deleted successfully");
|
| 937 |
-
fetchStats();
|
| 938 |
-
} else {
|
| 939 |
-
toast.error("Failed to delete demo lead");
|
| 940 |
}
|
| 941 |
-
}
|
| 942 |
-
toast.error("Error deleting lead");
|
| 943 |
-
}
|
| 944 |
};
|
| 945 |
|
| 946 |
return (
|
|
@@ -1422,7 +1447,7 @@ const SuperAdminPanel = () => {
|
|
| 1422 |
{/* Cancel / Couldn't Conduct Button */}
|
| 1423 |
{b.status !== 'cancelled' && (
|
| 1424 |
<button
|
| 1425 |
-
onClick={() =>
|
| 1426 |
className="bg-red-500/10 text-red-600 hover:bg-red-600 hover:text-white border border-red-500/30 py-1 px-2.5 rounded font-bold cursor-pointer text-[11px] transition-all flex items-center gap-1"
|
| 1427 |
title="Mark as Cancelled or Couldn't Show Demo"
|
| 1428 |
>
|
|
@@ -1443,7 +1468,7 @@ const SuperAdminPanel = () => {
|
|
| 1443 |
|
| 1444 |
{/* Delete Lead Button */}
|
| 1445 |
<button
|
| 1446 |
-
onClick={() => handleDeleteBooking(b
|
| 1447 |
className="text-on-surface-variant hover:text-red-600 border-0 bg-transparent p-1 cursor-pointer transition-colors"
|
| 1448 |
title="Delete Lead"
|
| 1449 |
>
|
|
|
|
| 876 |
}
|
| 877 |
};
|
| 878 |
|
| 879 |
+
const handleCancelBooking = (booking) => {
|
| 880 |
+
setConfirmModal({
|
| 881 |
+
isOpen: true,
|
| 882 |
+
title: 'Cancel Demo Booking',
|
| 883 |
+
desc: `Are you sure you want to cancel the demo call booking for ${booking.email || 'this lead'}?`,
|
| 884 |
+
type: 'error',
|
| 885 |
+
onConfirm: async () => {
|
| 886 |
+
await handleUpdateBookingStatus(booking.id, 'cancelled');
|
| 887 |
+
closeConfirm();
|
| 888 |
+
}
|
| 889 |
+
});
|
| 890 |
+
};
|
| 891 |
+
|
| 892 |
const handleOpenReschedule = (booking) => {
|
| 893 |
const rawDate = booking.meeting_date || '';
|
| 894 |
const rawTime = booking.meeting_time || '';
|
|
|
|
| 936 |
}
|
| 937 |
};
|
| 938 |
|
| 939 |
+
const handleDeleteBooking = (booking) => {
|
| 940 |
+
const bookingId = typeof booking === 'object' ? booking.id : booking;
|
| 941 |
+
const email = typeof booking === 'object' && booking.email ? booking.email : '';
|
| 942 |
+
setConfirmModal({
|
| 943 |
+
isOpen: true,
|
| 944 |
+
title: 'Delete Demo Lead',
|
| 945 |
+
desc: email
|
| 946 |
+
? `Are you sure you want to permanently delete the demo lead for ${email}?`
|
| 947 |
+
: 'Are you sure you want to permanently delete this demo booking lead?',
|
| 948 |
+
type: 'error',
|
| 949 |
+
onConfirm: async () => {
|
| 950 |
+
try {
|
| 951 |
+
const res = await fetch(`/api/demo/bookings/${bookingId}`, {
|
| 952 |
+
method: 'DELETE',
|
| 953 |
+
headers: {
|
| 954 |
+
'Authorization': `Bearer ${localStorage.getItem('wss_token')}`
|
| 955 |
+
}
|
| 956 |
+
});
|
| 957 |
+
if (res.ok) {
|
| 958 |
+
toast.success("Demo lead deleted successfully");
|
| 959 |
+
fetchStats();
|
| 960 |
+
} else {
|
| 961 |
+
toast.error("Failed to delete demo lead");
|
| 962 |
+
}
|
| 963 |
+
} catch (err) {
|
| 964 |
+
toast.error("Error deleting lead");
|
| 965 |
}
|
| 966 |
+
closeConfirm();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 967 |
}
|
| 968 |
+
});
|
|
|
|
|
|
|
| 969 |
};
|
| 970 |
|
| 971 |
return (
|
|
|
|
| 1447 |
{/* Cancel / Couldn't Conduct Button */}
|
| 1448 |
{b.status !== 'cancelled' && (
|
| 1449 |
<button
|
| 1450 |
+
onClick={() => handleCancelBooking(b)}
|
| 1451 |
className="bg-red-500/10 text-red-600 hover:bg-red-600 hover:text-white border border-red-500/30 py-1 px-2.5 rounded font-bold cursor-pointer text-[11px] transition-all flex items-center gap-1"
|
| 1452 |
title="Mark as Cancelled or Couldn't Show Demo"
|
| 1453 |
>
|
|
|
|
| 1468 |
|
| 1469 |
{/* Delete Lead Button */}
|
| 1470 |
<button
|
| 1471 |
+
onClick={() => handleDeleteBooking(b)}
|
| 1472 |
className="text-on-surface-variant hover:text-red-600 border-0 bg-transparent p-1 cursor-pointer transition-colors"
|
| 1473 |
title="Delete Lead"
|
| 1474 |
>
|