pih-appointment-widget 0.0.23 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AppointmentPage.js +20 -133
- package/dist/pih-appointment-widget.umd.js +26 -138
- package/dist/pih-appointment-widget.umd.min.js +1 -1
- package/dist/services/appointmentService.js +6 -5
- package/package.json +1 -1
- package/src/components/AppointmentPage.js +22 -11
- package/src/services/appointmentService.js +5 -4
|
@@ -455,11 +455,10 @@ const AppointmentPage = _ref => {
|
|
|
455
455
|
setSelectedAppointment(sortedAppointments[0]);
|
|
456
456
|
}
|
|
457
457
|
};
|
|
458
|
-
const fetchAppointments = (0, _react.useCallback)(async
|
|
458
|
+
const fetchAppointments = (0, _react.useCallback)(async () => {
|
|
459
459
|
if (!appToken) return;
|
|
460
460
|
console.log(doctorIdFromLogin, 'fetchAppointments -> doctorIdFromLogin');
|
|
461
461
|
const doctorId = doctorIdFromLogin;
|
|
462
|
-
const typeToUse = overrideType !== undefined ? overrideType : appointmentTypeFilter;
|
|
463
462
|
setLoading(true);
|
|
464
463
|
setError(null);
|
|
465
464
|
try {
|
|
@@ -469,7 +468,7 @@ const AppointmentPage = _ref => {
|
|
|
469
468
|
doctorId,
|
|
470
469
|
token: appToken
|
|
471
470
|
};
|
|
472
|
-
const response = await (0, _appointmentService.getAppointmentsByStatus)(activeTab, fromDate, toDate,
|
|
471
|
+
const response = await (0, _appointmentService.getAppointmentsByStatus)(activeTab, fromDate, toDate, serviceConfig);
|
|
473
472
|
if (response.status === 401 || response.status === 403) {
|
|
474
473
|
// Token expired — clear stored token and trigger re-login (SSO effect will fire)
|
|
475
474
|
try {
|
|
@@ -508,6 +507,7 @@ const AppointmentPage = _ref => {
|
|
|
508
507
|
// Handle appointment selection - no API call, just show data from list
|
|
509
508
|
const handleAppointmentSelect = appointment => {
|
|
510
509
|
setSelectedAppointment(appointment);
|
|
510
|
+
setCallError(null);
|
|
511
511
|
};
|
|
512
512
|
|
|
513
513
|
// Logout: clear storage and redirect to login page
|
|
@@ -546,21 +546,31 @@ const AppointmentPage = _ref => {
|
|
|
546
546
|
console.log(selectedAppointment, 'selectedAppointment');
|
|
547
547
|
console.log(callConfig, 'callConfig');
|
|
548
548
|
const response = await (0, _appointmentService.initiateConsultation)(selectedAppointment, callConfig);
|
|
549
|
+
console.log(response.status, 'response');
|
|
549
550
|
if (response.status === 401 || response.status === 403) {
|
|
550
|
-
|
|
551
|
-
|
|
551
|
+
// Token expired — clear stored token and trigger re-login (same as fetchAppointments)
|
|
552
|
+
try {
|
|
553
|
+
if (typeof localStorage !== "undefined") {
|
|
554
|
+
localStorage.removeItem(STORAGE_KEY_APP_TOKEN);
|
|
555
|
+
localStorage.removeItem(STORAGE_KEY_DOCTOR_ID);
|
|
556
|
+
localStorage.removeItem(STORAGE_KEY_USER_NAME);
|
|
557
|
+
}
|
|
558
|
+
} catch (e) {}
|
|
559
|
+
setAppToken(null);
|
|
560
|
+
setDoctorIdFromLogin(null);
|
|
561
|
+
setUserName(null);
|
|
562
|
+
setRefreshLoginTrigger(t => t + 1);
|
|
563
|
+
setCallError("Session expired. Re-authenticating...");
|
|
552
564
|
return;
|
|
553
565
|
}
|
|
554
566
|
if (response.err || !response.data?.token) {
|
|
555
567
|
setCallError(String(response.err || "Failed to initiate call"));
|
|
556
|
-
setCallLoading(false);
|
|
557
568
|
return;
|
|
558
569
|
}
|
|
559
570
|
const joinCallUrlBase = config.joinCallUrl || _apiConfig.JOIN_CALL_URL;
|
|
560
571
|
const joinCallUrl = response.data.token ? String(joinCallUrlBase || "").replace(/\/?$/, "/") + response.data.token : "";
|
|
561
572
|
console.log("joinCallUrl", joinCallUrl);
|
|
562
573
|
setCallToken(response.data.token);
|
|
563
|
-
// setCallUrl(response.data.url || "");
|
|
564
574
|
setCallUrl(joinCallUrl || '');
|
|
565
575
|
setShowPipVideo(true);
|
|
566
576
|
setIsPipMinimized(false);
|
|
@@ -577,7 +587,6 @@ const AppointmentPage = _ref => {
|
|
|
577
587
|
} catch (err) {
|
|
578
588
|
setCallError(err.message || "Failed to initiate call");
|
|
579
589
|
} finally {
|
|
580
|
-
setCallError(null);
|
|
581
590
|
setCallLoading(false);
|
|
582
591
|
}
|
|
583
592
|
};
|
|
@@ -807,9 +816,10 @@ const AppointmentPage = _ref => {
|
|
|
807
816
|
};
|
|
808
817
|
}, [apiBaseUrl, hospitalId, idToken, email, refreshLoginTrigger]);
|
|
809
818
|
|
|
810
|
-
// Reset page to 1 when filters change
|
|
819
|
+
// Reset page to 1 and clear call error when filters/tab change
|
|
811
820
|
(0, _react.useEffect)(() => {
|
|
812
821
|
setCurrentPage(1);
|
|
822
|
+
setCallError(null);
|
|
813
823
|
}, [activeTab, selectedDate, fromDate, toDate, searchQuery, appointmentTypeFilter]);
|
|
814
824
|
|
|
815
825
|
// Fetch appointments when we have appToken (tab/date change triggers refetch via fetchAppointments deps)
|
|
@@ -1237,130 +1247,7 @@ const AppointmentPage = _ref => {
|
|
|
1237
1247
|
justifyContent: isMobile ? "flex-start" : "flex-end",
|
|
1238
1248
|
flexWrap: "wrap"
|
|
1239
1249
|
}
|
|
1240
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1241
|
-
style: {
|
|
1242
|
-
position: "relative"
|
|
1243
|
-
},
|
|
1244
|
-
"data-appointment-type-picker": true
|
|
1245
1250
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
1246
|
-
onClick: () => setShowAppointmentTypePicker(!showAppointmentTypePicker),
|
|
1247
|
-
style: {
|
|
1248
|
-
padding: isMobile ? "8px 12px" : "8px 12px",
|
|
1249
|
-
fontFamily,
|
|
1250
|
-
fontWeight: 600,
|
|
1251
|
-
border: "1px solid #E5E5E5",
|
|
1252
|
-
borderRadius: "6px",
|
|
1253
|
-
fontSize: isMobile ? "11px" : "13px",
|
|
1254
|
-
color: "#1a1a1a",
|
|
1255
|
-
background: "#FFFFFF",
|
|
1256
|
-
display: "flex",
|
|
1257
|
-
alignItems: "center",
|
|
1258
|
-
gap: isMobile ? "4px" : "6px",
|
|
1259
|
-
cursor: "pointer",
|
|
1260
|
-
flex: "none",
|
|
1261
|
-
minWidth: isMobile ? "100px" : "auto",
|
|
1262
|
-
justifyContent: "center"
|
|
1263
|
-
}
|
|
1264
|
-
}, /*#__PURE__*/_react.default.createElement("svg", {
|
|
1265
|
-
width: isMobile ? "14" : "16",
|
|
1266
|
-
height: isMobile ? "14" : "16",
|
|
1267
|
-
viewBox: "0 0 24 24",
|
|
1268
|
-
fill: "none",
|
|
1269
|
-
stroke: "currentColor",
|
|
1270
|
-
strokeWidth: "2",
|
|
1271
|
-
strokeLinecap: "round",
|
|
1272
|
-
strokeLinejoin: "round"
|
|
1273
|
-
}, /*#__PURE__*/_react.default.createElement("path", {
|
|
1274
|
-
d: "M4.8 2A2.8 2.8 0 0 0 2 4.8v14.4A2.8 2.8 0 0 0 4.8 22h14.4a2.8 2.8 0 0 0 2.8-2.8V4.8A2.8 2.8 0 0 0 19.2 2H4.8z"
|
|
1275
|
-
}), /*#__PURE__*/_react.default.createElement("path", {
|
|
1276
|
-
d: "M8 12h8M8 16h5"
|
|
1277
|
-
})), /*#__PURE__*/_react.default.createElement("span", {
|
|
1278
|
-
style: {
|
|
1279
|
-
overflow: "hidden",
|
|
1280
|
-
textOverflow: "ellipsis",
|
|
1281
|
-
whiteSpace: "nowrap",
|
|
1282
|
-
color: "#4C4DDC"
|
|
1283
|
-
}
|
|
1284
|
-
}, appointmentTypeFilter === "all" ? "All Appointment" : appointmentTypeFilter === "ONLINE" ? "Online" : "Physical"), /*#__PURE__*/_react.default.createElement("svg", {
|
|
1285
|
-
width: isMobile ? "8" : "10",
|
|
1286
|
-
height: isMobile ? "8" : "10",
|
|
1287
|
-
viewBox: "0 0 24 24",
|
|
1288
|
-
fill: "none",
|
|
1289
|
-
stroke: "currentColor",
|
|
1290
|
-
strokeWidth: "2",
|
|
1291
|
-
strokeLinecap: "round",
|
|
1292
|
-
strokeLinejoin: "round"
|
|
1293
|
-
}, /*#__PURE__*/_react.default.createElement("polyline", {
|
|
1294
|
-
points: "6 9 12 15 18 9"
|
|
1295
|
-
}))), showAppointmentTypePicker && /*#__PURE__*/_react.default.createElement("div", {
|
|
1296
|
-
style: {
|
|
1297
|
-
position: "absolute",
|
|
1298
|
-
top: "100%",
|
|
1299
|
-
right: isMobile ? "auto" : 0,
|
|
1300
|
-
left: isMobile ? 0 : "auto",
|
|
1301
|
-
marginTop: "4px",
|
|
1302
|
-
background: "#FFFFFF",
|
|
1303
|
-
border: "1px solid #E5E5E5",
|
|
1304
|
-
borderRadius: "8px",
|
|
1305
|
-
boxShadow: "0 4px 16px rgba(0,0,0,0.15)",
|
|
1306
|
-
padding: "8px",
|
|
1307
|
-
zIndex: 1000,
|
|
1308
|
-
minWidth: isMobile ? "240px" : "200px",
|
|
1309
|
-
width: isMobile ? "calc(100vw - 24px)" : "auto",
|
|
1310
|
-
maxWidth: isMobile ? "calc(100vw - 24px)" : "240px"
|
|
1311
|
-
}
|
|
1312
|
-
}, [{
|
|
1313
|
-
value: "all",
|
|
1314
|
-
label: "All Appointment"
|
|
1315
|
-
}, {
|
|
1316
|
-
value: "ONLINE",
|
|
1317
|
-
label: "Online"
|
|
1318
|
-
}, {
|
|
1319
|
-
value: "PHYSICAL",
|
|
1320
|
-
label: "Physical"
|
|
1321
|
-
}].map(_ref2 => {
|
|
1322
|
-
let {
|
|
1323
|
-
value,
|
|
1324
|
-
label
|
|
1325
|
-
} = _ref2;
|
|
1326
|
-
return /*#__PURE__*/_react.default.createElement("button", {
|
|
1327
|
-
key: value,
|
|
1328
|
-
onClick: () => {
|
|
1329
|
-
setAppointmentTypeFilter(value);
|
|
1330
|
-
setShowAppointmentTypePicker(false);
|
|
1331
|
-
fetchAppointments(value);
|
|
1332
|
-
},
|
|
1333
|
-
style: {
|
|
1334
|
-
width: "100%",
|
|
1335
|
-
padding: "10px 12px",
|
|
1336
|
-
background: appointmentTypeFilter === value ? "#E8EEF4" : "#FFFFFF",
|
|
1337
|
-
border: "none",
|
|
1338
|
-
borderRadius: "4px",
|
|
1339
|
-
fontSize: "13px",
|
|
1340
|
-
fontFamily,
|
|
1341
|
-
cursor: "pointer",
|
|
1342
|
-
textAlign: "left",
|
|
1343
|
-
fontWeight: appointmentTypeFilter === value ? 600 : 400,
|
|
1344
|
-
color: appointmentTypeFilter === value ? "#4C4DDC" : "#1a1a1a",
|
|
1345
|
-
marginBottom: "4px",
|
|
1346
|
-
display: "flex",
|
|
1347
|
-
justifyContent: "space-between",
|
|
1348
|
-
alignItems: "center",
|
|
1349
|
-
transition: "all 0.2s ease"
|
|
1350
|
-
},
|
|
1351
|
-
onMouseEnter: e => {
|
|
1352
|
-
if (appointmentTypeFilter !== value) e.target.style.background = "#F5F5F5";
|
|
1353
|
-
},
|
|
1354
|
-
onMouseLeave: e => {
|
|
1355
|
-
if (appointmentTypeFilter !== value) e.target.style.background = "#FFFFFF";
|
|
1356
|
-
}
|
|
1357
|
-
}, /*#__PURE__*/_react.default.createElement("span", null, label), appointmentTypeFilter === value && /*#__PURE__*/_react.default.createElement("span", {
|
|
1358
|
-
style: {
|
|
1359
|
-
color: "#4C4DDC",
|
|
1360
|
-
fontSize: "16px"
|
|
1361
|
-
}
|
|
1362
|
-
}, "\u2713"));
|
|
1363
|
-
}))), /*#__PURE__*/_react.default.createElement("button", {
|
|
1364
1251
|
onClick: () => {
|
|
1365
1252
|
// Initialize temp dates and option with current values when opening picker
|
|
1366
1253
|
if (!showDatePicker) {
|
|
@@ -2231,7 +2118,7 @@ const AppointmentPage = _ref => {
|
|
|
2231
2118
|
background: "#FFFFFF",
|
|
2232
2119
|
borderRadius: isPipFullscreen ? "0" : "8px",
|
|
2233
2120
|
boxShadow: "0 8px 24px rgba(0, 0, 0, 0.3)",
|
|
2234
|
-
zIndex:
|
|
2121
|
+
zIndex: 100000,
|
|
2235
2122
|
overflow: "hidden",
|
|
2236
2123
|
display: "flex",
|
|
2237
2124
|
flexDirection: "column",
|
|
@@ -159,8 +159,8 @@
|
|
|
159
159
|
* @param {object} config - Optional configuration { apiBaseUrl, hospitalId, doctorId }
|
|
160
160
|
* @returns {Promise} Appointments data
|
|
161
161
|
*/
|
|
162
|
-
const getAppointmentsByStatus = async function (status, fromDate, toDate
|
|
163
|
-
let config = arguments.length >
|
|
162
|
+
const getAppointmentsByStatus = async function (status, fromDate, toDate) {
|
|
163
|
+
let config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
164
164
|
// Map status to API format
|
|
165
165
|
let apiStatus = (status || "").toUpperCase();
|
|
166
166
|
if (apiStatus === "INPROGRESS") {
|
|
@@ -177,9 +177,10 @@
|
|
|
177
177
|
toDate,
|
|
178
178
|
statuses: apiStatus
|
|
179
179
|
};
|
|
180
|
-
if (type && String(type).toUpperCase() !== "ALL") {
|
|
181
|
-
|
|
182
|
-
}
|
|
180
|
+
// if (type && String(type).toUpperCase() !== "ALL") {
|
|
181
|
+
// params.appointmentType = String(type).toUpperCase();
|
|
182
|
+
// }
|
|
183
|
+
params.appointmentType = 'ONLINE';
|
|
183
184
|
const url = `${baseURL}${API_PATHS.APPOINTMENTS}`;
|
|
184
185
|
|
|
185
186
|
// Return raw response (including status) so caller can detect 401 and re-login
|
|
@@ -656,11 +657,10 @@
|
|
|
656
657
|
setSelectedAppointment(sortedAppointments[0]);
|
|
657
658
|
}
|
|
658
659
|
};
|
|
659
|
-
const fetchAppointments = React.useCallback(async
|
|
660
|
+
const fetchAppointments = React.useCallback(async () => {
|
|
660
661
|
if (!appToken) return;
|
|
661
662
|
console.log(doctorIdFromLogin, 'fetchAppointments -> doctorIdFromLogin');
|
|
662
663
|
const doctorId = doctorIdFromLogin;
|
|
663
|
-
const typeToUse = overrideType !== undefined ? overrideType : appointmentTypeFilter;
|
|
664
664
|
setLoading(true);
|
|
665
665
|
setError(null);
|
|
666
666
|
try {
|
|
@@ -670,7 +670,7 @@
|
|
|
670
670
|
doctorId,
|
|
671
671
|
token: appToken
|
|
672
672
|
};
|
|
673
|
-
const response = await getAppointmentsByStatus(activeTab, fromDate, toDate,
|
|
673
|
+
const response = await getAppointmentsByStatus(activeTab, fromDate, toDate, serviceConfig);
|
|
674
674
|
if (response.status === 401 || response.status === 403) {
|
|
675
675
|
// Token expired — clear stored token and trigger re-login (SSO effect will fire)
|
|
676
676
|
try {
|
|
@@ -709,6 +709,7 @@
|
|
|
709
709
|
// Handle appointment selection - no API call, just show data from list
|
|
710
710
|
const handleAppointmentSelect = appointment => {
|
|
711
711
|
setSelectedAppointment(appointment);
|
|
712
|
+
setCallError(null);
|
|
712
713
|
};
|
|
713
714
|
|
|
714
715
|
// Handle join call — call initiate API to get LiveKit token+url, then open PiP
|
|
@@ -727,21 +728,31 @@
|
|
|
727
728
|
console.log(selectedAppointment, 'selectedAppointment');
|
|
728
729
|
console.log(callConfig, 'callConfig');
|
|
729
730
|
const response = await initiateConsultation(selectedAppointment, callConfig);
|
|
731
|
+
console.log(response.status, 'response');
|
|
730
732
|
if (response.status === 401 || response.status === 403) {
|
|
731
|
-
|
|
732
|
-
|
|
733
|
+
// Token expired — clear stored token and trigger re-login (same as fetchAppointments)
|
|
734
|
+
try {
|
|
735
|
+
if (typeof localStorage !== "undefined") {
|
|
736
|
+
localStorage.removeItem(STORAGE_KEY_APP_TOKEN);
|
|
737
|
+
localStorage.removeItem(STORAGE_KEY_DOCTOR_ID);
|
|
738
|
+
localStorage.removeItem(STORAGE_KEY_USER_NAME);
|
|
739
|
+
}
|
|
740
|
+
} catch (e) {}
|
|
741
|
+
setAppToken(null);
|
|
742
|
+
setDoctorIdFromLogin(null);
|
|
743
|
+
setUserName(null);
|
|
744
|
+
setRefreshLoginTrigger(t => t + 1);
|
|
745
|
+
setCallError("Session expired. Re-authenticating...");
|
|
733
746
|
return;
|
|
734
747
|
}
|
|
735
748
|
if (response.err || !response.data?.token) {
|
|
736
749
|
setCallError(String(response.err || "Failed to initiate call"));
|
|
737
|
-
setCallLoading(false);
|
|
738
750
|
return;
|
|
739
751
|
}
|
|
740
752
|
const joinCallUrlBase = config.joinCallUrl || JOIN_CALL_URL;
|
|
741
753
|
const joinCallUrl = response.data.token ? String(joinCallUrlBase || "").replace(/\/?$/, "/") + response.data.token : "";
|
|
742
754
|
console.log("joinCallUrl", joinCallUrl);
|
|
743
755
|
setCallToken(response.data.token);
|
|
744
|
-
// setCallUrl(response.data.url || "");
|
|
745
756
|
setCallUrl(joinCallUrl || '');
|
|
746
757
|
setShowPipVideo(true);
|
|
747
758
|
setIsPipMinimized(false);
|
|
@@ -758,7 +769,6 @@
|
|
|
758
769
|
} catch (err) {
|
|
759
770
|
setCallError(err.message || "Failed to initiate call");
|
|
760
771
|
} finally {
|
|
761
|
-
setCallError(null);
|
|
762
772
|
setCallLoading(false);
|
|
763
773
|
}
|
|
764
774
|
};
|
|
@@ -988,9 +998,10 @@
|
|
|
988
998
|
};
|
|
989
999
|
}, [apiBaseUrl, hospitalId, idToken, email, refreshLoginTrigger]);
|
|
990
1000
|
|
|
991
|
-
// Reset page to 1 when filters change
|
|
1001
|
+
// Reset page to 1 and clear call error when filters/tab change
|
|
992
1002
|
React.useEffect(() => {
|
|
993
1003
|
setCurrentPage(1);
|
|
1004
|
+
setCallError(null);
|
|
994
1005
|
}, [activeTab, selectedDate, fromDate, toDate, searchQuery, appointmentTypeFilter]);
|
|
995
1006
|
|
|
996
1007
|
// Fetch appointments when we have appToken (tab/date change triggers refetch via fetchAppointments deps)
|
|
@@ -1272,130 +1283,7 @@
|
|
|
1272
1283
|
justifyContent: isMobile ? "flex-start" : "flex-end",
|
|
1273
1284
|
flexWrap: "wrap"
|
|
1274
1285
|
}
|
|
1275
|
-
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1276
|
-
style: {
|
|
1277
|
-
position: "relative"
|
|
1278
|
-
},
|
|
1279
|
-
"data-appointment-type-picker": true
|
|
1280
1286
|
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
1281
|
-
onClick: () => setShowAppointmentTypePicker(!showAppointmentTypePicker),
|
|
1282
|
-
style: {
|
|
1283
|
-
padding: isMobile ? "8px 12px" : "8px 12px",
|
|
1284
|
-
fontFamily,
|
|
1285
|
-
fontWeight: 600,
|
|
1286
|
-
border: "1px solid #E5E5E5",
|
|
1287
|
-
borderRadius: "6px",
|
|
1288
|
-
fontSize: isMobile ? "11px" : "13px",
|
|
1289
|
-
color: "#1a1a1a",
|
|
1290
|
-
background: "#FFFFFF",
|
|
1291
|
-
display: "flex",
|
|
1292
|
-
alignItems: "center",
|
|
1293
|
-
gap: isMobile ? "4px" : "6px",
|
|
1294
|
-
cursor: "pointer",
|
|
1295
|
-
flex: "none",
|
|
1296
|
-
minWidth: isMobile ? "100px" : "auto",
|
|
1297
|
-
justifyContent: "center"
|
|
1298
|
-
}
|
|
1299
|
-
}, /*#__PURE__*/React__default["default"].createElement("svg", {
|
|
1300
|
-
width: isMobile ? "14" : "16",
|
|
1301
|
-
height: isMobile ? "14" : "16",
|
|
1302
|
-
viewBox: "0 0 24 24",
|
|
1303
|
-
fill: "none",
|
|
1304
|
-
stroke: "currentColor",
|
|
1305
|
-
strokeWidth: "2",
|
|
1306
|
-
strokeLinecap: "round",
|
|
1307
|
-
strokeLinejoin: "round"
|
|
1308
|
-
}, /*#__PURE__*/React__default["default"].createElement("path", {
|
|
1309
|
-
d: "M4.8 2A2.8 2.8 0 0 0 2 4.8v14.4A2.8 2.8 0 0 0 4.8 22h14.4a2.8 2.8 0 0 0 2.8-2.8V4.8A2.8 2.8 0 0 0 19.2 2H4.8z"
|
|
1310
|
-
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
1311
|
-
d: "M8 12h8M8 16h5"
|
|
1312
|
-
})), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
1313
|
-
style: {
|
|
1314
|
-
overflow: "hidden",
|
|
1315
|
-
textOverflow: "ellipsis",
|
|
1316
|
-
whiteSpace: "nowrap",
|
|
1317
|
-
color: "#4C4DDC"
|
|
1318
|
-
}
|
|
1319
|
-
}, appointmentTypeFilter === "all" ? "All Appointment" : appointmentTypeFilter === "ONLINE" ? "Online" : "Physical"), /*#__PURE__*/React__default["default"].createElement("svg", {
|
|
1320
|
-
width: isMobile ? "8" : "10",
|
|
1321
|
-
height: isMobile ? "8" : "10",
|
|
1322
|
-
viewBox: "0 0 24 24",
|
|
1323
|
-
fill: "none",
|
|
1324
|
-
stroke: "currentColor",
|
|
1325
|
-
strokeWidth: "2",
|
|
1326
|
-
strokeLinecap: "round",
|
|
1327
|
-
strokeLinejoin: "round"
|
|
1328
|
-
}, /*#__PURE__*/React__default["default"].createElement("polyline", {
|
|
1329
|
-
points: "6 9 12 15 18 9"
|
|
1330
|
-
}))), showAppointmentTypePicker && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1331
|
-
style: {
|
|
1332
|
-
position: "absolute",
|
|
1333
|
-
top: "100%",
|
|
1334
|
-
right: isMobile ? "auto" : 0,
|
|
1335
|
-
left: isMobile ? 0 : "auto",
|
|
1336
|
-
marginTop: "4px",
|
|
1337
|
-
background: "#FFFFFF",
|
|
1338
|
-
border: "1px solid #E5E5E5",
|
|
1339
|
-
borderRadius: "8px",
|
|
1340
|
-
boxShadow: "0 4px 16px rgba(0,0,0,0.15)",
|
|
1341
|
-
padding: "8px",
|
|
1342
|
-
zIndex: 1000,
|
|
1343
|
-
minWidth: isMobile ? "240px" : "200px",
|
|
1344
|
-
width: isMobile ? "calc(100vw - 24px)" : "auto",
|
|
1345
|
-
maxWidth: isMobile ? "calc(100vw - 24px)" : "240px"
|
|
1346
|
-
}
|
|
1347
|
-
}, [{
|
|
1348
|
-
value: "all",
|
|
1349
|
-
label: "All Appointment"
|
|
1350
|
-
}, {
|
|
1351
|
-
value: "ONLINE",
|
|
1352
|
-
label: "Online"
|
|
1353
|
-
}, {
|
|
1354
|
-
value: "PHYSICAL",
|
|
1355
|
-
label: "Physical"
|
|
1356
|
-
}].map(_ref2 => {
|
|
1357
|
-
let {
|
|
1358
|
-
value,
|
|
1359
|
-
label
|
|
1360
|
-
} = _ref2;
|
|
1361
|
-
return /*#__PURE__*/React__default["default"].createElement("button", {
|
|
1362
|
-
key: value,
|
|
1363
|
-
onClick: () => {
|
|
1364
|
-
setAppointmentTypeFilter(value);
|
|
1365
|
-
setShowAppointmentTypePicker(false);
|
|
1366
|
-
fetchAppointments(value);
|
|
1367
|
-
},
|
|
1368
|
-
style: {
|
|
1369
|
-
width: "100%",
|
|
1370
|
-
padding: "10px 12px",
|
|
1371
|
-
background: appointmentTypeFilter === value ? "#E8EEF4" : "#FFFFFF",
|
|
1372
|
-
border: "none",
|
|
1373
|
-
borderRadius: "4px",
|
|
1374
|
-
fontSize: "13px",
|
|
1375
|
-
fontFamily,
|
|
1376
|
-
cursor: "pointer",
|
|
1377
|
-
textAlign: "left",
|
|
1378
|
-
fontWeight: appointmentTypeFilter === value ? 600 : 400,
|
|
1379
|
-
color: appointmentTypeFilter === value ? "#4C4DDC" : "#1a1a1a",
|
|
1380
|
-
marginBottom: "4px",
|
|
1381
|
-
display: "flex",
|
|
1382
|
-
justifyContent: "space-between",
|
|
1383
|
-
alignItems: "center",
|
|
1384
|
-
transition: "all 0.2s ease"
|
|
1385
|
-
},
|
|
1386
|
-
onMouseEnter: e => {
|
|
1387
|
-
if (appointmentTypeFilter !== value) e.target.style.background = "#F5F5F5";
|
|
1388
|
-
},
|
|
1389
|
-
onMouseLeave: e => {
|
|
1390
|
-
if (appointmentTypeFilter !== value) e.target.style.background = "#FFFFFF";
|
|
1391
|
-
}
|
|
1392
|
-
}, /*#__PURE__*/React__default["default"].createElement("span", null, label), appointmentTypeFilter === value && /*#__PURE__*/React__default["default"].createElement("span", {
|
|
1393
|
-
style: {
|
|
1394
|
-
color: "#4C4DDC",
|
|
1395
|
-
fontSize: "16px"
|
|
1396
|
-
}
|
|
1397
|
-
}, "\u2713"));
|
|
1398
|
-
}))), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
1399
1287
|
onClick: () => {
|
|
1400
1288
|
// Initialize temp dates and option with current values when opening picker
|
|
1401
1289
|
if (!showDatePicker) {
|
|
@@ -2266,7 +2154,7 @@
|
|
|
2266
2154
|
background: "#FFFFFF",
|
|
2267
2155
|
borderRadius: isPipFullscreen ? "0" : "8px",
|
|
2268
2156
|
boxShadow: "0 8px 24px rgba(0, 0, 0, 0.3)",
|
|
2269
|
-
zIndex:
|
|
2157
|
+
zIndex: 100000,
|
|
2270
2158
|
overflow: "hidden",
|
|
2271
2159
|
display: "flex",
|
|
2272
2160
|
flexDirection: "column",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MyPackage={},e.React,e.ReactDOM)}(this,(function(e,t,n){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(t),i=o(n);const l="/appointment/V1/consultant/all-appointments",r="/notification/V1/consultation/online/initiate",d="https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/",p=async function(e,t,n,o){let a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},i=(e||"").toUpperCase();"INPROGRESS"===i&&(i="IN_PROGRESS");const r=a.apiBaseUrl,d=a.hospitalId,p=a.doctorId,s=a.token||"",c={hospitalId:d,doctorId:p,fromDate:t,toDate:n,statuses:i};o&&"ALL"!==String(o).toUpperCase()&&(c.appointmentType=String(o).toUpperCase());const u=`${r}${l}`,f=await async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const o=new URL(e);return o.search=new URLSearchParams(t).toString(),fetch(o,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`${n}`}}).then((async e=>{const t=await e.json().catch((()=>({})));return e.ok?t:{err:t?.resultInfo?.message||"Something went wrong!",status:e.status}})).catch((e=>(console.error("Fetch error:",e),{err:e?.message||String(e)||"Network error"})))}(u,c,"PIH-Appointment-Widget",s);return f},s=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};console.log("initiateConsultation -> config",t);const n=`${t.apiBaseUrl.replace(/\/$/,"")}${r}`,o=t.appToken||"";return async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=arguments.length>4?arguments[4]:void 0;const a=new URL(e);Object.keys(n).forEach((e=>{a.searchParams.append(e,n[e])}));const i={"Content-Type":"application/json"};o&&(i.Authorization=o);const l={method:"POST",headers:i,body:JSON.stringify(t)};return fetch(a.toString(),l).then((async e=>{const t=await e.json().catch((()=>({})));return e.ok?t:{err:t?.resultInfo?.message||"Something went wrong!",status:e.status}})).catch((e=>(console.error("Fetch error:",e),{err:e.message||"Network error"})))}(n,{patientId:String(e.patientId||""),primaryPatientId:String(e.primaryPatientId||e.patientId||""),hospitalId:t.hospitalId,doctorId:String(t.doctorId),patientName:e.patientName||e.name||"",doctorName:e.doctorName||t.doctorName,appointmentId:String(e.id||e.appointmentId||e._id||"")},"PIH-Appointment-Widget",{},o)};const c="pih_appointment_idToken",u="pih_appointment_email",f="pih_appointment_appToken",m="pih_appointment_doctorId",x="pih_appointment_userName",g="pih_appointment_apiBaseUrl",h="pih_appointment_hospitalId",y=720,E="pih-appointment-widget",F="data-pih-widget";class b extends t.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){"undefined"!=typeof console&&console.error&&console.error("Appointment widget error:",e,t)}render(){return this.state.hasError?a.default.createElement("div",{className:E,[F]:"teleconsult-appointments",style:{fontFamily:'"Nunito", serif',background:"#F5F5F7",boxSizing:"border-box",minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",padding:"24px",textAlign:"center"}},a.default.createElement("div",{style:{maxWidth:"400px"}},a.default.createElement("div",{style:{fontSize:"48px",marginBottom:"16px"}},"⚠️"),a.default.createElement("h2",{style:{fontSize:"20px",fontWeight:700,color:"#1a1a1a",margin:"0 0 8px 0"}},"Something went wrong"),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0,lineHeight:1.5}},"Please refresh the page or try again later."))):this.props.children}}const w=e=>{let{config:n={}}=e;const[o,i]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(g):null}catch{return null}})),[l,r]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(h):null}catch{return null}})),w=n.apiBaseUrl||o||"https://afiyaapiqa.powermindinc.com",S=n.hospitalId||l,[v,k]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(c):null}catch{return null}})),[C,I]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(u):null}catch{return null}})),D=n.idToken||n.token||v,z=n.email||C;t.useEffect((()=>{try{if("undefined"==typeof localStorage)return;const e=n.idToken||n.token;if(e&&String(e).trim()){localStorage.getItem(c)!==e&&(M(null),A(null),N(null),localStorage.removeItem(f),localStorage.removeItem(m),localStorage.removeItem(x)),localStorage.setItem(c,e),k(e)}n.email&&String(n.email).trim()&&(localStorage.setItem(u,n.email),I(n.email)),n.apiBaseUrl&&String(n.apiBaseUrl).trim()&&(localStorage.setItem(g,n.apiBaseUrl.trim()),i(n.apiBaseUrl.trim())),null!=n.hospitalId&&String(n.hospitalId).trim()&&(localStorage.setItem(h,String(n.hospitalId).trim()),r(String(n.hospitalId).trim()))}catch(e){}}),[n.idToken,n.token,n.email,n.apiBaseUrl,n.hospitalId]);const[W,M]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(f):null}catch{return null}})),[T,A]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(m):null}catch{return null}})),[R,N]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(x):null}catch{return null}})),[P,j]=t.useState((()=>{try{if("undefined"==typeof localStorage)return!1;const e=localStorage.getItem(f),t=localStorage.getItem(c),n=localStorage.getItem(u);return!e&&!(!t||!n)}catch{return!1}})),[B,L]=t.useState(null),[H,U]=t.useState(!1),[O,$]=t.useState(0);t.useEffect((()=>{W&&P&&j(!1)}),[W,P]),t.useEffect((()=>{W||(D&&z?(U(!1),L((e=>"Sign in required. Redirecting to home..."===e?null:e))):(L("Sign in required. Redirecting to home..."),U(!0)))}),[W,D,z]),t.useEffect((()=>{if(!H)return;const e=n.homeUrl||"https://wbaemrdevittisalwe01-fnapdpfme7bvduhh.westeurope-01.azurewebsites.net/";if(!e||"undefined"==typeof window)return;const t=setTimeout((()=>{window.location.href=e}),2500);return()=>clearTimeout(t)}),[H,n.homeUrl]),t.useEffect((()=>{if(!P)return;const e=setTimeout((()=>{L("Request timed out. Please try again."),j(!1)}),3e4);return()=>clearTimeout(e)}),[P]);const _=n.joinCallUrl||d;W&&String(_||"").replace(/\/?$/,"/");const Y=function(e){if(!e||"string"!=typeof e)return{};try{const t=e.split(".");if(3!==t.length)return{};const n=t[1].replace(/-/g,"+").replace(/_/g,"/"),o=n.padEnd(n.length+(4-n.length%4)%4,"=");return JSON.parse(atob(o))}catch{return{}}}(D),V=R||Y.name||Y.sub||"User",q=()=>(new Date).toISOString().split("T")[0],[X,G]=t.useState("upcoming"),[J,K]=t.useState([]),[Q,Z]=t.useState(null),[ee,te]=t.useState(!1),[ne,oe]=t.useState(null),[ae,ie]=t.useState(window.innerWidth<768),[le,re]=t.useState("today"),[de,pe]=t.useState("today"),[se,ce]=t.useState(!1),[ue,fe]=t.useState(!1),[me,xe]=t.useState("all"),[ge,he]=t.useState("asc"),[ye,Ee]=t.useState(""),[Fe,be]=t.useState(!1),[we,Se]=t.useState(!1),[ve,ke]=t.useState(!1),[Ce,Ie]=t.useState(null),[De,ze]=t.useState(null),[We,Me]=t.useState(!1),[Te,Ae]=t.useState(null),[Re,Ne]=t.useState((()=>({x:Math.max(20,"undefined"!=typeof window?window.innerWidth-y-20:300),y:80}))),[Pe,je]=t.useState({width:y,height:560}),[Be,Le]=t.useState(!1),[He,Ue]=t.useState({x:0,y:0}),[Oe,$e]=t.useState(!1),[_e,Ye]=t.useState(null),[Ve,qe]=t.useState({x:0,y:0,width:0,height:0});t.useState(!1);const[Xe,Ge]=t.useState(1),Je=J.filter((e=>{if(!ye.trim())return!0;const t=ye.toLowerCase(),n=(e.patientName||"").toLowerCase(),o=String(e.patientId||"").toLowerCase();return n.includes(t)||o.includes(t)})),Ke=20*(Xe-1),Qe=Ke+20,Ze=Je.slice(Ke,Qe),et=Math.ceil(Je.length/20),tt=Je.length,[nt,ot]=t.useState(q()),[at,it]=t.useState(q()),[lt,rt]=t.useState(),[dt,pt]=t.useState(),st=e=>e?.id||e?._id||e?.appointmentId||e?.patientId||JSON.stringify(e),ct=e=>e?.image?e.image:null,ut=e=>e?e.charAt(0).toUpperCase():"?",ft=e=>{if(!e)return"#4C4DDC";const t=["#4C4DDC","#1CC3CE","#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F"];return t[e.charCodeAt(0)%t.length]},mt=()=>{const e="asc"===ge?"desc":"asc";he(e);const t=[...J].sort(((t,n)=>{const o=new Date(t.appointmentDate||t.date||0),a=new Date(n.appointmentDate||n.date||0);return"asc"===e?o-a:a-o}));K(t),Ge(1),t.length>0&&Z(t[0])},xt=t.useCallback((async e=>{if(!W)return;console.log(T,"fetchAppointments -> doctorIdFromLogin");const t=T,n=void 0!==e?e:me;te(!0),oe(null);try{const e={apiBaseUrl:w,hospitalId:S,doctorId:t,token:W},o=await p(X,nt,at,n,e);if(401===o.status||403===o.status){try{"undefined"!=typeof localStorage&&(localStorage.removeItem(f),localStorage.removeItem(m),localStorage.removeItem(x))}catch(e){}return M(null),A(null),N(null),$((e=>e+1)),void oe("Session expired. Re-authenticating...")}if(o.err)return void oe(String(o.err||"Failed to fetch appointments"));const a=o.data||o.appointments||o||[];K(Array.isArray(a)?a:[]),Array.isArray(a)&&a.length>0?Z(a[0]):Z(null)}catch(e){console.error("Error fetching appointments:",e),oe(e.message||"Failed to fetch appointments")}finally{te(!1)}}),[X,nt,at,me,w,S,T,W]),gt=e=>{Z(e)},ht=async()=>{if(Q&&W){Me(!0),Ae(null);try{const e={apiBaseUrl:w,hospitalId:S,doctorId:T,doctorName:R||V,appToken:W};console.log(Q,"selectedAppointment"),console.log(e,"callConfig");const t=await s(Q,e);if(401===t.status||403===t.status)return Ae("Session expired. Please try again."),void Me(!1);if(t.err||!t.data?.token)return Ae(String(t.err||"Failed to initiate call")),void Me(!1);const o=n.joinCallUrl||d,a=t.data.token?String(o||"").replace(/\/?$/,"/")+t.data.token:"";console.log("joinCallUrl",a),Ie(t.data.token),ze(a||""),be(!0),Se(!1),ke(!1),je({width:y,height:560}),Ne({x:Math.max(20,window.innerWidth-y-20),y:80})}catch(e){Ae(e.message||"Failed to initiate call")}finally{Ae(null),Me(!1)}}},yt=()=>{be(!1),Se(!1),ke(!1),Ie(null),ze(null),Ae(null),xt()},Et=()=>{ve&&ke(!1),Se(!we)},Ft=()=>{we&&Se(!1),ke(!ve)},bt=e=>{if(0!==e.button)return;if(e.target.closest("button"))return;e.currentTarget.setPointerCapture&&e.currentTarget.setPointerCapture(e.pointerId),Le(!0);const t=e.currentTarget.getBoundingClientRect();Ue({x:e.clientX-t.left,y:e.clientY-t.top})},wt=t.useCallback((e=>{if(!ve)if(Be){const t=e.clientX-He.x,n=e.clientY-He.y,o=window.innerWidth-Pe.width,a=window.innerHeight-Pe.height;Ne({x:Math.max(0,Math.min(t,o)),y:Math.max(0,Math.min(n,a))})}else if(Oe){const t=e.clientX-Ve.x,n=e.clientY-Ve.y;let o=Ve.width,a=Ve.height,i=Ve.posX,l=Ve.posY;const r=300,d=250,p=window.innerWidth-40,s=window.innerHeight-100;if("bottom-right"===_e)o=Math.min(Math.max(Ve.width+t,r),p),a=Math.min(Math.max(Ve.height+n,d),s),i+o>window.innerWidth&&(o=window.innerWidth-i),l+a>window.innerHeight&&(a=window.innerHeight-l);else if("bottom-left"===_e){o=Math.min(Math.max(Ve.width-t,r),p),i=Math.max(0,Ve.posX+t),0===i&&(o=Ve.posX+Ve.width),a=Math.min(Math.max(Ve.height+n,d),s),l+a>window.innerHeight&&(a=window.innerHeight-l)}else if("top-right"===_e){o=Math.min(Math.max(Ve.width+t,r),p),i+o>window.innerWidth&&(o=window.innerWidth-i);a=Math.min(Math.max(Ve.height-n,d),s),l=Math.max(0,Ve.posY+n),0===l&&(a=Ve.posY+Ve.height)}else if("top-left"===_e){o=Math.min(Math.max(Ve.width-t,r),p),i=Math.max(0,Ve.posX+t),0===i&&(o=Ve.posX+Ve.width);a=Math.min(Math.max(Ve.height-n,d),s),l=Math.max(0,Ve.posY+n),0===l&&(a=Ve.posY+Ve.height)}je({width:o,height:a}),Ne({x:i,y:l})}}),[Be,Oe,He,_e,Ve,Re,Pe,ve]),St=()=>{Le(!1),$e(!1),Ye(null)},vt=(e,t)=>{t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture&&t.currentTarget.setPointerCapture(t.pointerId),$e(!0),Ye(e),qe({x:t.clientX,y:t.clientY,width:Pe.width,height:Pe.height,posX:Re.x,posY:Re.y})};t.useEffect((()=>{if(!Fe||ve)return;const e=()=>{if(!(window.innerWidth<768)){const e=we?350:Pe.width,t=we?60:Pe.height,n=window.innerWidth-40,o=window.innerHeight-100,a=Math.min(e,n),i=Math.min(t,o);a===Pe.width&&i===Pe.height||je({width:a,height:i});const l=window.innerWidth-a-20,r=window.innerHeight-i-20;Ne((e=>({x:Math.min(e.x,l),y:Math.min(e.y,r)})))}};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[Fe,we,ve,Pe]),t.useEffect((()=>{if(!(D&&z&&(!W||O>0)))return;let e=!1;return j(!0),L(null),(async(e,t,n,o)=>{const a=`${e.replace(/\/$/,"")}/um/user/V1/sso/login?hospitalId=${encodeURIComponent(t)}`,i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({idToken:n,email:o})};return console.log("[getTokenFromSso] request",{url:a,body:{idToken:n?n.slice(0,50)+"...":null,email:o}}),fetch(a,i).then((e=>(console.log("[getTokenFromSso] response status",e.status,e.statusText),e.ok?e.json().then((e=>(console.log("[getTokenFromSso] success",{hasData:!!e,dataKeys:e?Object.keys(e):[],hasAccessToken:!!e?.data?.access_token}),e))):e.json().then((t=>{const n=t?.resultInfo?.message||"SSO login failed";return console.log("[getTokenFromSso] error body",t),{err:n,status:e.status}})).catch((()=>({err:"Something went wrong!",status:e.status})))))).catch((e=>(console.error("[getTokenFromSso] catch",e),{err:e.message||"Network error"})))})(w,S,D,z).then((t=>{if(e)return;const n=function(e){return!e||e.err?null:e.data?.access_token??e.data?.token??e.token??e.accessToken??null}(t);if(400===t.status)return L(t.err||"Invalid request. Redirecting to home..."),j(!1),void U(!0);if(t.err||!n){L(String(t.err||"Failed to get token")),M(null),A(null),N(null);try{"undefined"!=typeof localStorage&&(localStorage.removeItem(f),localStorage.removeItem(m),localStorage.removeItem(x))}catch(e){}}else{const e=function(e){if(!e?.data)return null;const t=e.data.doctor_id??e.data.doctorId??null;return console.log(t,"extractDoctorIdFromLoginResponse -> id"),null!=t?String(t):null}(t);console.log(e,"extractDoctorIdFromLoginResponse -> doctorId");const o=function(e){if(!e?.data)return null;const t=e.data.name??e.data.doctor_name??e.data.userName??null;return null!=t?String(t):null}(t);M(n),A(e),N(o),L(null),U(!1);try{"undefined"!=typeof localStorage&&(localStorage.setItem(f,n),e&&localStorage.setItem(m,e),o&&localStorage.setItem(x,o))}catch(e){}}})).catch((()=>{})).finally((()=>{e||j(!1)})),()=>{e=!0}}),[w,S,D,z,O]),t.useEffect((()=>{Ge(1)}),[X,le,nt,at,ye,me]),t.useEffect((()=>{!P&&W&&xt()}),[xt,W,P]),t.useEffect((()=>{const e=document.createElement("link");e.href="https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap",e.rel="stylesheet",document.head.appendChild(e);const t=document.createElement("style");t.innerHTML="\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n \n @media (max-width: 768px) {\n .appointments-grid {\n grid-template-columns: 1.5fr 1fr 0.8fr !important;\n }\n .appointments-header-grid {\n grid-template-columns: 1.5fr 1fr 0.8fr !important;\n }\n .hide-on-mobile {\n display: none !important;\n }\n }\n @media (max-width: 480px) {\n .appointments-header-grid {\n font-size: 10px !important;\n }\n .appointments-grid {\n font-size: 11px !important;\n }\n }\n ",document.head.appendChild(t);const n=()=>{ie(window.innerWidth<768)};return window.addEventListener("resize",n),()=>{document.head.removeChild(e),document.head.removeChild(t),window.removeEventListener("resize",n)}}),[]),t.useEffect((()=>{const e=e=>{!se||e.target.closest("button")||e.target.closest('input[type="date"]')||ce(!1),ue&&!e.target.closest("[data-appointment-type-picker]")&&fe(!1)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}}),[se,ue]);let kt='"Nunito", serif';const Ct=B||!W&&(!D||!z),It=B||"Sign in required. Redirecting to home...";let Dt;return Dt=P&&D&&z?a.default.createElement("div",{className:E,[F]:"teleconsult-appointments",style:{fontFamily:kt,background:"#F5F5F7",boxSizing:"border-box",height:"100%",minHeight:"100vh",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"24px"}},a.default.createElement("style",null,"@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }"),a.default.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #4C4DDC",borderRadius:"50%",animation:"spin 1s linear infinite",marginBottom:"16px"}}),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0}},"Checking authorisation...")):a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{className:E,[F]:"teleconsult-appointments",style:{fontFamily:kt,background:"#F5F5F7",boxSizing:"border-box",height:"100%",minHeight:"100vh",width:"100%",display:"flex",flexDirection:"column",overflow:"hidden"}},a.default.createElement("div",{style:{background:"#FFFFFF",padding:ae?"10px 12px":"12px 24px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #E5E5E5",flexWrap:"nowrap",gap:ae?"8px":"0"}},a.default.createElement("div",{style:{position:"relative",width:ae?"calc(100% - 90px)":"480px",maxWidth:ae?"none":"480px"}},a.default.createElement("input",{type:"text",placeholder:"Search by patient name or ID",value:ye,onChange:e=>Ee(e.target.value),style:{width:"100%",padding:ae?"8px 32px 8px 10px":"8px 36px 8px 14px",border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:ae?"12px":"13px",fontFamily:kt,background:"#FFFFFF",outline:"none",boxSizing:"border-box"}}),ye&&a.default.createElement("button",{onClick:()=>Ee(""),style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:"#999",fontSize:"16px"},title:"Clear search"},"✕")),!1),a.default.createElement("div",{style:{padding:ae?"12px":"16px 24px",flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"}},a.default.createElement("div",{style:{marginBottom:ae?"10px":"14px"}},a.default.createElement("h1",{style:{fontSize:ae?"18px":"22px",fontWeight:700,color:"#1a1a1a",margin:"0 0 2px 0"}},"Tele Consultation"),a.default.createElement("p",{style:{fontSize:ae?"11px":"12px",color:"#999",margin:0}},"Displaying All Tele Consultation Appointments")),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:ae?"flex-start":"center",marginBottom:ae?"10px":"14px",flexDirection:ae?"column":"row",gap:ae?"12px":"0"}},a.default.createElement("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",width:ae?"100%":"auto"}},a.default.createElement("button",{onClick:()=>G("upcoming"),style:{background:"upcoming"===X?"#4C4DDC":"#FFFFFF",padding:ae?"8px 10px":"9px 16px",border:"upcoming"===X?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:ae?"10px":"13px",color:"upcoming"===X?"white":"#555555",fontWeight:600,fontFamily:kt,cursor:"pointer",flex:ae?"1 1 auto":"none",minWidth:ae?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Upcoming Appointments"),a.default.createElement("button",{onClick:()=>G("completed"),style:{background:"completed"===X?"#4C4DDC":"#FFFFFF",padding:ae?"8px 10px":"9px 16px",border:"completed"===X?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:ae?"10px":"13px",color:"completed"===X?"white":"#555555",fontWeight:600,fontFamily:kt,cursor:"pointer",flex:ae?"1 1 auto":"none",minWidth:ae?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Completed Appointments"),a.default.createElement("button",{onClick:()=>G("cancelled"),style:{background:"cancelled"===X?"#4C4DDC":"#FFFFFF",padding:ae?"8px 10px":"9px 16px",border:"cancelled"===X?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:ae?"10px":"13px",color:"cancelled"===X?"white":"#555555",fontWeight:600,fontFamily:kt,cursor:"pointer",flex:ae?"1 1 auto":"none",minWidth:ae?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Cancelled Appointments")),a.default.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center",width:"auto",position:"relative",justifyContent:ae?"flex-start":"flex-end",flexWrap:"wrap"}},a.default.createElement("div",{style:{position:"relative"},"data-appointment-type-picker":!0},a.default.createElement("button",{onClick:()=>fe(!ue),style:{padding:"8px 12px",fontFamily:kt,fontWeight:600,border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:ae?"11px":"13px",color:"#1a1a1a",background:"#FFFFFF",display:"flex",alignItems:"center",gap:ae?"4px":"6px",cursor:"pointer",flex:"none",minWidth:ae?"100px":"auto",justifyContent:"center"}},a.default.createElement("svg",{width:ae?"14":"16",height:ae?"14":"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},a.default.createElement("path",{d:"M4.8 2A2.8 2.8 0 0 0 2 4.8v14.4A2.8 2.8 0 0 0 4.8 22h14.4a2.8 2.8 0 0 0 2.8-2.8V4.8A2.8 2.8 0 0 0 19.2 2H4.8z"}),a.default.createElement("path",{d:"M8 12h8M8 16h5"})),a.default.createElement("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"#4C4DDC"}},"all"===me?"All Appointment":"ONLINE"===me?"Online":"Physical"),a.default.createElement("svg",{width:ae?"8":"10",height:ae?"8":"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},a.default.createElement("polyline",{points:"6 9 12 15 18 9"}))),ue&&a.default.createElement("div",{style:{position:"absolute",top:"100%",right:ae?"auto":0,left:ae?0:"auto",marginTop:"4px",background:"#FFFFFF",border:"1px solid #E5E5E5",borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.15)",padding:"8px",zIndex:1e3,minWidth:ae?"240px":"200px",width:ae?"calc(100vw - 24px)":"auto",maxWidth:ae?"calc(100vw - 24px)":"240px"}},[{value:"all",label:"All Appointment"},{value:"ONLINE",label:"Online"},{value:"PHYSICAL",label:"Physical"}].map((e=>{let{value:t,label:n}=e;return a.default.createElement("button",{key:t,onClick:()=>{xe(t),fe(!1),xt(t)},style:{width:"100%",padding:"10px 12px",background:me===t?"#E8EEF4":"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:kt,cursor:"pointer",textAlign:"left",fontWeight:me===t?600:400,color:me===t?"#4C4DDC":"#1a1a1a",marginBottom:"4px",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.2s ease"},onMouseEnter:e=>{me!==t&&(e.target.style.background="#F5F5F5")},onMouseLeave:e=>{me!==t&&(e.target.style.background="#FFFFFF")}},a.default.createElement("span",null,n),me===t&&a.default.createElement("span",{style:{color:"#4C4DDC",fontSize:"16px"}},"✓"))})))),a.default.createElement("button",{onClick:()=>{se||(rt(nt),pt(at),pe(le)),ce(!se)},style:{padding:"8px 12px",fontFamily:kt,fontWeight:600,border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:ae?"11px":"13px",color:"#1a1a1a",background:"#FFFFFF",display:"flex",alignItems:"center",gap:ae?"4px":"6px",cursor:"pointer",flex:"none",minWidth:ae?"100px":"auto",justifyContent:"center"}},a.default.createElement("svg",{width:ae?"12":"14",height:ae?"12":"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},a.default.createElement("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),a.default.createElement("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),a.default.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),a.default.createElement("line",{x1:"3",y1:"10",x2:"21",y2:"10"})),a.default.createElement("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},(()=>{switch(le){case"today":default:return"Today";case"tomorrow":return"Tomorrow";case"currentWeek":return"Current Week";case"thisMonth":return"This Month";case"currentYear":return"Current Year";case"custom":return ae?"Custom":`${nt} to ${at}`}})()),a.default.createElement("svg",{width:ae?"8":"10",height:ae?"8":"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},a.default.createElement("polyline",{points:"6 9 12 15 18 9"}))),se&&a.default.createElement("div",{style:{position:"absolute",top:"100%",right:ae?"auto":0,left:ae?0:"auto",marginTop:"4px",background:"#FFFFFF",border:"1px solid #E5E5E5",borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.15)",padding:"8px",zIndex:1e3,minWidth:ae?"280px":"240px",width:ae?"calc(100vw - 24px)":"auto",maxWidth:ae?"calc(100vw - 24px)":"280px"}},a.default.createElement("div",{style:{marginBottom:"custom"===de?"12px":"0"}},["thisMonth","today","tomorrow","currentWeek","currentYear","custom"].map((e=>a.default.createElement("button",{key:e,onClick:()=>{if(pe(e),"custom"!==e){const t=(e=>{const t=new Date;let n,o;switch(e){case"today":default:n=o=q();break;case"tomorrow":const e=new Date(t);e.setDate(e.getDate()+1),n=o=e.toISOString().split("T")[0];break;case"currentWeek":const a=new Date(t),i=new Date(t),l=t.getDay(),r=0===l?-6:1-l;a.setDate(t.getDate()+r),i.setDate(a.getDate()+6),n=a.toISOString().split("T")[0],o=i.toISOString().split("T")[0];break;case"thisMonth":const d=new Date(t.getFullYear(),t.getMonth(),1),p=new Date(t.getFullYear(),t.getMonth()+1,0);n=d.toISOString().split("T")[0],o=p.toISOString().split("T")[0];break;case"currentYear":n=`${t.getFullYear()}-01-01`,o=`${t.getFullYear()}-12-31`}return{from:n,to:o}})(e);re(e),ot(t.from),it(t.to),rt(t.from),pt(t.to),ce(!1)}else rt(""),pt("")},style:{width:"100%",padding:"10px 12px",background:de===e?"#E8EEF4":"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:kt,cursor:"pointer",textAlign:"left",fontWeight:de===e?600:400,color:de===e?"#4C4DDC":"#1a1a1a",marginBottom:"4px",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.2s ease"},onMouseEnter:t=>{de!==e&&(t.target.style.background="#F5F5F5")},onMouseLeave:t=>{de!==e&&(t.target.style.background="#FFFFFF")}},a.default.createElement("span",null,{thisMonth:"This Month",today:"Today",tomorrow:"Tomorrow",currentWeek:"Current Week",currentYear:"Current Year",custom:"Custom"}[e]),de===e&&a.default.createElement("span",{style:{color:"#4C4DDC",fontSize:"16px"}},"✓"))))),"custom"===de&&a.default.createElement("div",{style:{paddingTop:"8px",borderTop:"1px solid #E5E5E5"}},a.default.createElement("div",{style:{marginBottom:"8px"}},a.default.createElement("input",{type:"date",value:lt,onChange:e=>rt(e.target.value),placeholder:"Start Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:kt,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{marginBottom:"12px"}},a.default.createElement("input",{type:"date",value:dt,onChange:e=>pt(e.target.value),placeholder:"End Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:kt,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{display:"flex",gap:"8px"}},a.default.createElement("button",{onClick:()=>{pe(le),rt(nt),pt(at),ce(!1)},style:{flex:1,padding:"10px 12px",background:"#FFFFFF",color:"#4C4DDC",border:"1px solid #4C4DDC",borderRadius:"4px",fontSize:"13px",fontFamily:kt,fontWeight:600,cursor:"pointer"}},"Cancel"),a.default.createElement("button",{onClick:()=>{lt&&dt&&(re("custom"),ot(lt),it(dt),ce(!1))},style:{flex:1,padding:"10px 12px",background:"#4C4DDC",color:"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:kt,fontWeight:600,cursor:"pointer"}},"Submit")))))),a.default.createElement("div",{style:{display:"flex",flexDirection:ae?"column":"row",gap:ae?"12px":"14px",flex:1,minHeight:0,overflow:ae?"auto":"hidden"}},a.default.createElement("div",{style:{flex:ae?"none":"1 1 65%",width:ae?"100%":"auto",display:"flex",flexDirection:"column",minHeight:ae?"400px":0}},a.default.createElement("div",{style:{background:"#FFFFFF",borderRadius:"8px",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden",display:"flex",flexDirection:"column",flex:ae?"none":1,minHeight:ae?"auto":0}},a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:ae?"12px 14px":"14px 18px",borderBottom:"1px solid #F1F1F1"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:ae?"6px":"8px"}},a.default.createElement("span",{style:{fontSize:ae?"14px":"15px",fontWeight:700,color:"#1a1a1a"}},"Appointments"),a.default.createElement("span",{style:{background:"#4C4DDC",color:"#fff",fontSize:ae?"10px":"11px",fontWeight:600,padding:ae?"2px 7px":"3px 8px",borderRadius:"12px"}},tt))),a.default.createElement("div",{className:"appointments-header-grid",style:{display:"grid",gridTemplateColumns:ae?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:ae?"8px":"12px",padding:ae?"8px 12px":"10px 18px",background:"#F5F5F5",fontSize:ae?"10px":"12px",fontWeight:600,color:"#666"}},a.default.createElement("div",null,"Patients name"),!ae&&a.default.createElement("div",null,"Patient ID"),a.default.createElement("div",{onClick:mt,style:{display:"flex",alignItems:"center",gap:"3px",cursor:"pointer",userSelect:"none"}},"Date",a.default.createElement("span",{style:{opacity:.7,fontSize:"10px"}},"asc"===ge?"▲":"▼")),!ae&&a.default.createElement("div",null,"Slot"),!ae&&a.default.createElement("div",null,"Doctor")),a.default.createElement("div",{style:{overflow:"auto",flex:1}},P?a.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"40px",color:"#888"}},a.default.createElement("div",{style:{textAlign:"center"}},a.default.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #4C4DDC",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 10px"}}),"Getting token...")):ee?a.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"40px",color:"#888"}},a.default.createElement("div",{style:{textAlign:"center"}},a.default.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #4C4DDC",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 10px"}}),"Loading appointments...")):ne?a.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#FF0000"}},a.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"⚠️ Error"),a.default.createElement("div",{style:{fontSize:"13px"}},ne),a.default.createElement("button",{onClick:xt,style:{marginTop:"16px",padding:"8px 16px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontFamily:kt}},"Retry")):0===Ze.length?a.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#888"}},a.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),a.default.createElement("div",{style:{fontSize:"13px"}},ye?`No appointments found for "${ye}"`:"No appointments found"),ye&&a.default.createElement("button",{onClick:()=>Ee(""),style:{marginTop:"12px",padding:"6px 12px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px",fontFamily:kt}},"Clear Search")):Ze.map((e=>a.default.createElement("div",{key:st(e),role:"button",tabIndex:0,onClick:()=>gt(e),onKeyDown:t=>"Enter"===t.key&>(e),className:"appointments-grid",style:{display:"grid",gridTemplateColumns:ae?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:ae?"8px":"12px",padding:ae?"10px 12px":"12px 18px",background:st(Q)===st(e)?"#E8EEF4":"#FFFFFF",borderTop:"1px solid #F1F1F1",alignItems:"center",cursor:"pointer",fontSize:ae?"11px":"13px"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:ae?"8px":"10px"}},ct(e)?a.default.createElement("img",{src:e.image,alt:"",style:{width:ae?"32px":"36px",height:ae?"32px":"36px",borderRadius:"50%",objectFit:"cover"}}):a.default.createElement("div",{style:{width:ae?"32px":"36px",height:ae?"32px":"36px",borderRadius:"50%",background:ft(e.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:600,fontSize:ae?"14px":"16px"}},ut(e.patientName)),a.default.createElement("div",null,a.default.createElement("div",{style:{fontWeight:600,color:"#1a1a1a",fontSize:ae?"11px":"13px"}},e.patientName),a.default.createElement("div",{style:{fontSize:ae?"9px":"11px",color:"#888"}},e.email))),!ae&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.patientId),a.default.createElement("div",{style:{color:"#555",fontSize:ae?"10px":"12px"}},(()=>{const t=e.appointmentDate||"",n=t.match(/\s(\d{1,2}:\d{2}(?:\s*(?:AM|PM))?)$/i);return n?a.default.createElement(a.default.Fragment,null,a.default.createElement("div",null,t.slice(0,n.index).trim()),a.default.createElement("div",{style:{fontSize:ae?"9px":"11px",color:"#888"}},n[1].trim())):a.default.createElement("div",null,t)})()),!ae&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.appointmentTime||"-"),!ae&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.doctorName||e.doctor||"-"))))),!ee&&!ne&&Ze.length>0&&a.default.createElement("div",{style:{padding:ae?"12px 14px":"14px 18px",borderTop:"1px solid #F1F1F1",display:"flex",justifyContent:"space-between",alignItems:"center",background:"#FFFFFF",flexWrap:ae?"wrap":"nowrap",gap:ae?"10px":"0"}},a.default.createElement("div",{style:{fontSize:ae?"11px":"12px",color:"#666"}},"Showing page ",Xe," of ",et," (",tt," total)"),a.default.createElement("div",{style:{display:"flex",gap:"6px",alignItems:"center"}},a.default.createElement("button",{onClick:()=>Ge((e=>Math.max(1,e-1))),disabled:1===Xe,style:{padding:ae?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:1===Xe?"#F5F5F5":"#FFFFFF",color:1===Xe?"#999":"#1a1a1a",fontSize:ae?"11px":"12px",fontFamily:kt,fontWeight:600,cursor:1===Xe?"not-allowed":"pointer",opacity:1===Xe?.5:1}},"Previous"),a.default.createElement("div",{style:{display:"flex",gap:"4px"}},[...Array(Math.min(5,et))].map(((e,t)=>{let n;return n=et<=5||Xe<=3?t+1:Xe>=et-2?et-4+t:Xe-2+t,a.default.createElement("button",{key:n,onClick:()=>Ge(n),style:{padding:ae?"6px 10px":"6px 12px",border:Xe===n?"none":"1px solid #E5E5E5",borderRadius:"4px",background:Xe===n?"#4C4DDC":"#FFFFFF",color:Xe===n?"#FFFFFF":"#1a1a1a",fontSize:ae?"11px":"12px",fontFamily:kt,fontWeight:600,cursor:"pointer",minWidth:ae?"32px":"36px"}},n)}))),a.default.createElement("button",{onClick:()=>Ge((e=>Math.min(et,e+1))),disabled:Xe===et,style:{padding:ae?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:Xe===et?"#F5F5F5":"#FFFFFF",color:Xe===et?"#999":"#1a1a1a",fontSize:ae?"11px":"12px",fontFamily:kt,fontWeight:600,cursor:Xe===et?"not-allowed":"pointer",opacity:Xe===et?.5:1}},"Next"))))),a.default.createElement("div",{style:{flex:ae?"none":"1 1 35%",width:ae?"100%":"auto",display:Q||!ae?"flex":"none",flexDirection:"column",minHeight:ae?"auto":0}},a.default.createElement("div",{style:{border:"1px solid #E5E5E5",borderRadius:"8px",overflow:"hidden",background:"#FFFFFF",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",display:"flex",flexDirection:"column",flex:ae?"none":1,minHeight:ae?"auto":0}},Q?a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:ae?"12px 14px":"16px 18px",background:"#E8EEF4",borderBottom:"1px solid #E5E5E5"}},a.default.createElement("div",null,a.default.createElement("div",{style:{color:"#002668",fontSize:ae?"14px":"16px",fontWeight:"700"}},Q.patientName||"N/A"),a.default.createElement("div",{style:{color:"#002668",fontSize:ae?"11px":"13px"}},Q.patientId||Q.mrn||"N/A")),a.default.createElement("div",null,ct(Q)?a.default.createElement("img",{style:{width:ae?"36px":"44px",height:ae?"36px":"44px",borderRadius:"50%",objectFit:"cover"},src:Q.image,alt:Q.patientName}):a.default.createElement("div",{style:{width:ae?"36px":"44px",height:ae?"36px":"44px",borderRadius:"50%",background:ft(Q.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:700,fontSize:ae?"16px":"20px"}},ut(Q.patientName)))),a.default.createElement("div",{style:{padding:ae?"12px 14px":"14px 18px",gap:ae?"10px":"12px",display:"flex",flexDirection:"column",background:"white",overflow:"auto",flex:1,position:"relative"}},a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:ae?"10px":"11px",color:"#888",marginBottom:"3px"}},"Speciality"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ae?"12px":"13px"}},Q?.specialisation||Q?.speciality||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:ae?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Type"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ae?"12px":"13px"}},Q?.type||Q?.appointmentType||"Online"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:ae?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Date"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ae?"12px":"13px"}},Q?.date||Q?.appointmentDate||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:ae?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Time"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ae?"12px":"13px"}},Q?.time||Q?.appointmentTime||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:ae?"10px":"11px",color:"#888",marginBottom:"3px"}},"Doctor"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ae?"12px":"13px"}},Q?.doctor||Q?.doctorName||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:ae?"10px":"11px",color:"#888",marginBottom:"3px"}},"Hospital"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ae?"12px":"13px"}},Q?.hospital||Q?.hospitalName||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:ae?"10px":"11px",color:"#888",marginBottom:"3px"}},"Reason for Appointment"),a.default.createElement("div",{style:{fontWeight:"600",fontSize:ae?"11px":"12px",lineHeight:"1.4"}},Q?.reason||Q?.reasonForAppointment||"No reason provided"))),"upcoming"===X&&a.default.createElement("div",{style:{display:"flex",flexDirection:ae?"column":"row",gap:"6px",marginTop:"10px"}},a.default.createElement("button",{type:"button",onClick:ht,disabled:We,style:{flex:1,background:We?"#99e4e8":"#1CC3CE",color:"#FFFFFF",border:"1px solid #1CC3CE",borderRadius:"6px",padding:ae?"10px 8px":"8px 6px",fontFamily:kt,fontWeight:600,fontSize:ae?"11px":"12px",cursor:We?"not-allowed":"pointer"}},We?"Connecting...":"Join Call >")),"upcoming"===X&&Te&&a.default.createElement("div",{style:{fontSize:"11px",color:"#e53935",marginTop:"6px",textAlign:"center",width:"100%"}},"⚠️ ",Te))):a.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",padding:"40px",color:"#888",textAlign:"center"}},a.default.createElement("div",null,a.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),a.default.createElement("div",{style:{fontSize:"13px"}},"Select an appointment to view details"))))))),Fe&&a.default.createElement("div",{style:{position:"fixed",left:ve?"0":ae?"10px":`${Re.x}px`,top:ve?"0":ae?"70px":`${Re.y}px`,right:ve?"0":ae?"10px":"auto",bottom:ve?"0":"auto",width:ve?"100vw":ae?"calc(100vw - 20px)":we?"350px":`${Pe.width}px`,height:ve?"100vh":we?"auto":ae?"300px":`${Pe.height}px`,background:"#FFFFFF",borderRadius:ve?"0":"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",zIndex:1e4,overflow:"hidden",display:"flex",flexDirection:"column",transition:Be||Oe?"none":"all 0.3s ease"}},a.default.createElement("div",{onPointerDown:ae||ve?void 0:bt,onPointerMove:ae||ve?void 0:wt,onPointerUp:ae||ve?void 0:St,onPointerCancel:ae||ve?void 0:St,style:{background:"linear-gradient(135deg, #4C4DDC 0%, #3A3BBD 100%)",color:"#FFFFFF",padding:ae?"8px 10px":"10px 12px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:ae||ve?"default":"move",userSelect:"none"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:ae?"6px":"8px",flex:1,minWidth:0}},a.default.createElement("div",{style:{width:ae?"6px":"8px",height:ae?"6px":"8px",borderRadius:"50%",background:"#FF4444",animation:"pulse 2s infinite",flexShrink:0}}),a.default.createElement("span",{style:{fontSize:ae?"11px":"13px",fontWeight:600,fontFamily:kt,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},"Video Call - ",Q?.patientName||"Patient")),a.default.createElement("div",{style:{display:"flex",gap:ae?"4px":"6px",alignItems:"center",flexShrink:0}},!ve&&a.default.createElement("button",{onClick:Et,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:ae?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:ae?"28px":"32px",height:ae?"28px":"32px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:we?"Restore":"Minimize"},we?a.default.createElement("svg",{width:ae?"14":"16",height:ae?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("rect",{x:"3",y:"3",width:"10",height:"10",stroke:"white",strokeWidth:"1.8",fill:"none"})):a.default.createElement("svg",{width:ae?"14":"16",height:ae?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("line",{x1:"3",y1:"8",x2:"13",y2:"8",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round"}))),a.default.createElement("button",{onClick:Ft,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:ae?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:ae?"28px":"32px",height:ae?"28px":"32px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:ve?"Exit Fullscreen":"Fullscreen"},ve?a.default.createElement("svg",{width:ae?"14":"16",height:ae?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("path",{d:"M10 3H13V6M6 13H3V10M13 10V13H10M3 6V3H6",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})):a.default.createElement("svg",{width:ae?"14":"16",height:ae?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("path",{d:"M3 6V3H6M13 10V13H10M10 3H13V6M6 13H3V10",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}))),a.default.createElement("button",{onClick:yt,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:ae?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:ae?"28px":"32px",height:ae?"28px":"32px",fontWeight:"bold",fontSize:ae?"18px":"22px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:"Close"},"×"))),!we&&a.default.createElement("div",{style:{flex:1,background:"#000000",position:"relative"}},a.default.createElement("iframe",{src:(()=>{if(!Ce)return"";const e=String(_||"").replace(/\/?$/,"/");return console.log("${base}token=${callToken}",`${e}token=${Ce}`),`${e}token=${Ce}`})(),style:{width:"100%",height:"100%",border:"none"},allow:"camera; microphone; display-capture; autoplay",allowFullScreen:!0,title:"Video Call"})),!ae&&!ve&&!we&&a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{onPointerDown:e=>vt("top-left",e),onPointerMove:wt,onPointerUp:St,onPointerCancel:St,style:{position:"absolute",left:0,top:0,width:"16px",height:"16px",cursor:"nwse-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onPointerDown:e=>vt("top-right",e),onPointerMove:wt,onPointerUp:St,onPointerCancel:St,style:{position:"absolute",right:0,top:0,width:"16px",height:"16px",cursor:"nesw-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onPointerDown:e=>vt("bottom-left",e),onPointerMove:wt,onPointerUp:St,onPointerCancel:St,style:{position:"absolute",left:0,bottom:0,width:"16px",height:"16px",cursor:"nesw-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onPointerDown:e=>vt("bottom-right",e),onPointerMove:wt,onPointerUp:St,onPointerCancel:St,style:{position:"absolute",right:0,bottom:0,width:"16px",height:"16px",cursor:"nwse-resize",background:"transparent",zIndex:10001}})),a.default.createElement("style",null,"\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n "))),Ct&&a.default.createElement("div",{style:{position:"fixed",inset:0,zIndex:1e5,display:"flex",alignItems:"center",justifyContent:"center",padding:"24px",background:"rgba(0,0,0,0.4)",boxSizing:"border-box"}},a.default.createElement("div",{style:{fontFamily:kt,maxWidth:"400px",width:"100%",padding:"32px 24px",background:"#FFFFFF",borderRadius:"12px",boxShadow:"0 8px 32px rgba(0,0,0,0.2)",textAlign:"center"}},a.default.createElement("div",{style:{fontSize:"48px",marginBottom:"16px"}},"🔒"),a.default.createElement("h2",{style:{fontSize:"20px",fontWeight:700,color:"#1a1a1a",margin:"0 0 8px 0"}},B?"Not authorised":"Sign in required"),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0,lineHeight:1.5}},It),a.default.createElement("p",{style:{fontSize:"13px",color:"#999",marginTop:"16px",marginBottom:0}},"Redirecting to login...")))),a.default.createElement(b,null,Dt)};let S=null;const v={showWidget:(e,t)=>{S||(S=document.createElement("div"),document.body.appendChild(S));const n=()=>a.default.createElement(a.default.Fragment,null,a.default.createElement(w,{config:e}));i.default.render(a.default.createElement(n,null),S)},closePopup:()=>{S&&(i.default.unmountComponentAtNode(S),S=null)}};window.BookingSDK=v,e.AppointmentPage=w,e.PIH_APPOINTMENT_WIDGET_CLASS=E,e.default=v,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MyPackage={},e.React,e.ReactDOM)}(this,(function(e,t,n){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(t),i=o(n);const r="/appointment/V1/consultant/all-appointments",l="/notification/V1/consultation/online/initiate",d="https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/",s=async function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=(e||"").toUpperCase();"INPROGRESS"===a&&(a="IN_PROGRESS");const i=o.apiBaseUrl,l=o.hospitalId,d=o.doctorId,s=o.token||"",p={hospitalId:l,doctorId:d,fromDate:t,toDate:n,statuses:a,appointmentType:"ONLINE"},c=`${i}${r}`,u=await async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const o=new URL(e);return o.search=new URLSearchParams(t).toString(),fetch(o,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`${n}`}}).then((async e=>{const t=await e.json().catch((()=>({})));return e.ok?t:{err:t?.resultInfo?.message||"Something went wrong!",status:e.status}})).catch((e=>(console.error("Fetch error:",e),{err:e?.message||String(e)||"Network error"})))}(c,p,"PIH-Appointment-Widget",s);return u},p=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};console.log("initiateConsultation -> config",t);const n=`${t.apiBaseUrl.replace(/\/$/,"")}${l}`,o=t.appToken||"";return async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=arguments.length>4?arguments[4]:void 0;const a=new URL(e);Object.keys(n).forEach((e=>{a.searchParams.append(e,n[e])}));const i={"Content-Type":"application/json"};o&&(i.Authorization=o);const r={method:"POST",headers:i,body:JSON.stringify(t)};return fetch(a.toString(),r).then((async e=>{const t=await e.json().catch((()=>({})));return e.ok?t:{err:t?.resultInfo?.message||"Something went wrong!",status:e.status}})).catch((e=>(console.error("Fetch error:",e),{err:e.message||"Network error"})))}(n,{patientId:String(e.patientId||""),primaryPatientId:String(e.primaryPatientId||e.patientId||""),hospitalId:t.hospitalId,doctorId:String(t.doctorId),patientName:e.patientName||e.name||"",doctorName:e.doctorName||t.doctorName,appointmentId:String(e.id||e.appointmentId||e._id||"")},"PIH-Appointment-Widget",{},o)};const c="pih_appointment_idToken",u="pih_appointment_email",m="pih_appointment_appToken",f="pih_appointment_doctorId",x="pih_appointment_userName",g="pih_appointment_apiBaseUrl",h="pih_appointment_hospitalId",y=720,E="pih-appointment-widget",F="data-pih-widget";class w extends t.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){"undefined"!=typeof console&&console.error&&console.error("Appointment widget error:",e,t)}render(){return this.state.hasError?a.default.createElement("div",{className:E,[F]:"teleconsult-appointments",style:{fontFamily:'"Nunito", serif',background:"#F5F5F7",boxSizing:"border-box",minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",padding:"24px",textAlign:"center"}},a.default.createElement("div",{style:{maxWidth:"400px"}},a.default.createElement("div",{style:{fontSize:"48px",marginBottom:"16px"}},"⚠️"),a.default.createElement("h2",{style:{fontSize:"20px",fontWeight:700,color:"#1a1a1a",margin:"0 0 8px 0"}},"Something went wrong"),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0,lineHeight:1.5}},"Please refresh the page or try again later."))):this.props.children}}const b=e=>{let{config:n={}}=e;const[o,i]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(g):null}catch{return null}})),[r,l]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(h):null}catch{return null}})),b=n.apiBaseUrl||o||"https://afiyaapiqa.powermindinc.com",S=n.hospitalId||r,[v,k]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(c):null}catch{return null}})),[C,I]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(u):null}catch{return null}})),D=n.idToken||n.token||v,z=n.email||C;t.useEffect((()=>{try{if("undefined"==typeof localStorage)return;const e=n.idToken||n.token;if(e&&String(e).trim()){localStorage.getItem(c)!==e&&(T(null),A(null),N(null),localStorage.removeItem(m),localStorage.removeItem(f),localStorage.removeItem(x)),localStorage.setItem(c,e),k(e)}n.email&&String(n.email).trim()&&(localStorage.setItem(u,n.email),I(n.email)),n.apiBaseUrl&&String(n.apiBaseUrl).trim()&&(localStorage.setItem(g,n.apiBaseUrl.trim()),i(n.apiBaseUrl.trim())),null!=n.hospitalId&&String(n.hospitalId).trim()&&(localStorage.setItem(h,String(n.hospitalId).trim()),l(String(n.hospitalId).trim()))}catch(e){}}),[n.idToken,n.token,n.email,n.apiBaseUrl,n.hospitalId]);const[W,T]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(m):null}catch{return null}})),[M,A]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(f):null}catch{return null}})),[R,N]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(x):null}catch{return null}})),[P,j]=t.useState((()=>{try{if("undefined"==typeof localStorage)return!1;const e=localStorage.getItem(m),t=localStorage.getItem(c),n=localStorage.getItem(u);return!e&&!(!t||!n)}catch{return!1}})),[B,H]=t.useState(null),[L,U]=t.useState(!1),[$,_]=t.useState(0);t.useEffect((()=>{W&&P&&j(!1)}),[W,P]),t.useEffect((()=>{W||(D&&z?(U(!1),H((e=>"Sign in required. Redirecting to home..."===e?null:e))):(H("Sign in required. Redirecting to home..."),U(!0)))}),[W,D,z]),t.useEffect((()=>{if(!L)return;const e=n.homeUrl||"https://wbaemrdevittisalwe01-fnapdpfme7bvduhh.westeurope-01.azurewebsites.net/";if(!e||"undefined"==typeof window)return;const t=setTimeout((()=>{window.location.href=e}),2500);return()=>clearTimeout(t)}),[L,n.homeUrl]),t.useEffect((()=>{if(!P)return;const e=setTimeout((()=>{H("Request timed out. Please try again."),j(!1)}),3e4);return()=>clearTimeout(e)}),[P]);const O=n.joinCallUrl||d;W&&String(O||"").replace(/\/?$/,"/");const Y=function(e){if(!e||"string"!=typeof e)return{};try{const t=e.split(".");if(3!==t.length)return{};const n=t[1].replace(/-/g,"+").replace(/_/g,"/"),o=n.padEnd(n.length+(4-n.length%4)%4,"=");return JSON.parse(atob(o))}catch{return{}}}(D),V=R||Y.name||Y.sub||"User",q=()=>(new Date).toISOString().split("T")[0],[X,G]=t.useState("upcoming"),[J,K]=t.useState([]),[Q,Z]=t.useState(null),[ee,te]=t.useState(!1),[ne,oe]=t.useState(null),[ae,ie]=t.useState(window.innerWidth<768),[re,le]=t.useState("today"),[de,se]=t.useState("today"),[pe,ce]=t.useState(!1),[ue,me]=t.useState(!1),[fe,xe]=t.useState("all"),[ge,he]=t.useState("asc"),[ye,Ee]=t.useState(""),[Fe,we]=t.useState(!1),[be,Se]=t.useState(!1),[ve,ke]=t.useState(!1),[Ce,Ie]=t.useState(null),[De,ze]=t.useState(null),[We,Te]=t.useState(!1),[Me,Ae]=t.useState(null),[Re,Ne]=t.useState((()=>({x:Math.max(20,"undefined"!=typeof window?window.innerWidth-y-20:300),y:80}))),[Pe,je]=t.useState({width:y,height:560}),[Be,He]=t.useState(!1),[Le,Ue]=t.useState({x:0,y:0}),[$e,_e]=t.useState(!1),[Oe,Ye]=t.useState(null),[Ve,qe]=t.useState({x:0,y:0,width:0,height:0});t.useState(!1);const[Xe,Ge]=t.useState(1),Je=J.filter((e=>{if(!ye.trim())return!0;const t=ye.toLowerCase(),n=(e.patientName||"").toLowerCase(),o=String(e.patientId||"").toLowerCase();return n.includes(t)||o.includes(t)})),Ke=20*(Xe-1),Qe=Ke+20,Ze=Je.slice(Ke,Qe),et=Math.ceil(Je.length/20),tt=Je.length,[nt,ot]=t.useState(q()),[at,it]=t.useState(q()),[rt,lt]=t.useState(),[dt,st]=t.useState(),pt=e=>e?.id||e?._id||e?.appointmentId||e?.patientId||JSON.stringify(e),ct=e=>e?.image?e.image:null,ut=e=>e?e.charAt(0).toUpperCase():"?",mt=e=>{if(!e)return"#4C4DDC";const t=["#4C4DDC","#1CC3CE","#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F"];return t[e.charCodeAt(0)%t.length]},ft=()=>{const e="asc"===ge?"desc":"asc";he(e);const t=[...J].sort(((t,n)=>{const o=new Date(t.appointmentDate||t.date||0),a=new Date(n.appointmentDate||n.date||0);return"asc"===e?o-a:a-o}));K(t),Ge(1),t.length>0&&Z(t[0])},xt=t.useCallback((async()=>{if(!W)return;console.log(M,"fetchAppointments -> doctorIdFromLogin");const e=M;te(!0),oe(null);try{const t={apiBaseUrl:b,hospitalId:S,doctorId:e,token:W},n=await s(X,nt,at,t);if(401===n.status||403===n.status){try{"undefined"!=typeof localStorage&&(localStorage.removeItem(m),localStorage.removeItem(f),localStorage.removeItem(x))}catch(e){}return T(null),A(null),N(null),_((e=>e+1)),void oe("Session expired. Re-authenticating...")}if(n.err)return void oe(String(n.err||"Failed to fetch appointments"));const o=n.data||n.appointments||n||[];K(Array.isArray(o)?o:[]),Array.isArray(o)&&o.length>0?Z(o[0]):Z(null)}catch(e){console.error("Error fetching appointments:",e),oe(e.message||"Failed to fetch appointments")}finally{te(!1)}}),[X,nt,at,fe,b,S,M,W]),gt=e=>{Z(e),Ae(null)},ht=async()=>{if(Q&&W){Te(!0),Ae(null);try{const e={apiBaseUrl:b,hospitalId:S,doctorId:M,doctorName:R||V,appToken:W};console.log(Q,"selectedAppointment"),console.log(e,"callConfig");const t=await p(Q,e);if(console.log(t.status,"response"),401===t.status||403===t.status){try{"undefined"!=typeof localStorage&&(localStorage.removeItem(m),localStorage.removeItem(f),localStorage.removeItem(x))}catch(e){}return T(null),A(null),N(null),_((e=>e+1)),void Ae("Session expired. Re-authenticating...")}if(t.err||!t.data?.token)return void Ae(String(t.err||"Failed to initiate call"));const o=n.joinCallUrl||d,a=t.data.token?String(o||"").replace(/\/?$/,"/")+t.data.token:"";console.log("joinCallUrl",a),Ie(t.data.token),ze(a||""),we(!0),Se(!1),ke(!1),je({width:y,height:560}),Ne({x:Math.max(20,window.innerWidth-y-20),y:80})}catch(e){Ae(e.message||"Failed to initiate call")}finally{Te(!1)}}},yt=()=>{we(!1),Se(!1),ke(!1),Ie(null),ze(null),Ae(null),xt()},Et=()=>{ve&&ke(!1),Se(!be)},Ft=()=>{be&&Se(!1),ke(!ve)},wt=e=>{if(0!==e.button)return;if(e.target.closest("button"))return;e.currentTarget.setPointerCapture&&e.currentTarget.setPointerCapture(e.pointerId),He(!0);const t=e.currentTarget.getBoundingClientRect();Ue({x:e.clientX-t.left,y:e.clientY-t.top})},bt=t.useCallback((e=>{if(!ve)if(Be){const t=e.clientX-Le.x,n=e.clientY-Le.y,o=window.innerWidth-Pe.width,a=window.innerHeight-Pe.height;Ne({x:Math.max(0,Math.min(t,o)),y:Math.max(0,Math.min(n,a))})}else if($e){const t=e.clientX-Ve.x,n=e.clientY-Ve.y;let o=Ve.width,a=Ve.height,i=Ve.posX,r=Ve.posY;const l=300,d=250,s=window.innerWidth-40,p=window.innerHeight-100;if("bottom-right"===Oe)o=Math.min(Math.max(Ve.width+t,l),s),a=Math.min(Math.max(Ve.height+n,d),p),i+o>window.innerWidth&&(o=window.innerWidth-i),r+a>window.innerHeight&&(a=window.innerHeight-r);else if("bottom-left"===Oe){o=Math.min(Math.max(Ve.width-t,l),s),i=Math.max(0,Ve.posX+t),0===i&&(o=Ve.posX+Ve.width),a=Math.min(Math.max(Ve.height+n,d),p),r+a>window.innerHeight&&(a=window.innerHeight-r)}else if("top-right"===Oe){o=Math.min(Math.max(Ve.width+t,l),s),i+o>window.innerWidth&&(o=window.innerWidth-i);a=Math.min(Math.max(Ve.height-n,d),p),r=Math.max(0,Ve.posY+n),0===r&&(a=Ve.posY+Ve.height)}else if("top-left"===Oe){o=Math.min(Math.max(Ve.width-t,l),s),i=Math.max(0,Ve.posX+t),0===i&&(o=Ve.posX+Ve.width);a=Math.min(Math.max(Ve.height-n,d),p),r=Math.max(0,Ve.posY+n),0===r&&(a=Ve.posY+Ve.height)}je({width:o,height:a}),Ne({x:i,y:r})}}),[Be,$e,Le,Oe,Ve,Re,Pe,ve]),St=()=>{He(!1),_e(!1),Ye(null)},vt=(e,t)=>{t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture&&t.currentTarget.setPointerCapture(t.pointerId),_e(!0),Ye(e),qe({x:t.clientX,y:t.clientY,width:Pe.width,height:Pe.height,posX:Re.x,posY:Re.y})};t.useEffect((()=>{if(!Fe||ve)return;const e=()=>{if(!(window.innerWidth<768)){const e=be?350:Pe.width,t=be?60:Pe.height,n=window.innerWidth-40,o=window.innerHeight-100,a=Math.min(e,n),i=Math.min(t,o);a===Pe.width&&i===Pe.height||je({width:a,height:i});const r=window.innerWidth-a-20,l=window.innerHeight-i-20;Ne((e=>({x:Math.min(e.x,r),y:Math.min(e.y,l)})))}};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[Fe,be,ve,Pe]),t.useEffect((()=>{if(!(D&&z&&(!W||$>0)))return;let e=!1;return j(!0),H(null),(async(e,t,n,o)=>{const a=`${e.replace(/\/$/,"")}/um/user/V1/sso/login?hospitalId=${encodeURIComponent(t)}`,i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({idToken:n,email:o})};return console.log("[getTokenFromSso] request",{url:a,body:{idToken:n?n.slice(0,50)+"...":null,email:o}}),fetch(a,i).then((e=>(console.log("[getTokenFromSso] response status",e.status,e.statusText),e.ok?e.json().then((e=>(console.log("[getTokenFromSso] success",{hasData:!!e,dataKeys:e?Object.keys(e):[],hasAccessToken:!!e?.data?.access_token}),e))):e.json().then((t=>{const n=t?.resultInfo?.message||"SSO login failed";return console.log("[getTokenFromSso] error body",t),{err:n,status:e.status}})).catch((()=>({err:"Something went wrong!",status:e.status})))))).catch((e=>(console.error("[getTokenFromSso] catch",e),{err:e.message||"Network error"})))})(b,S,D,z).then((t=>{if(e)return;const n=function(e){return!e||e.err?null:e.data?.access_token??e.data?.token??e.token??e.accessToken??null}(t);if(400===t.status)return H(t.err||"Invalid request. Redirecting to home..."),j(!1),void U(!0);if(t.err||!n){H(String(t.err||"Failed to get token")),T(null),A(null),N(null);try{"undefined"!=typeof localStorage&&(localStorage.removeItem(m),localStorage.removeItem(f),localStorage.removeItem(x))}catch(e){}}else{const e=function(e){if(!e?.data)return null;const t=e.data.doctor_id??e.data.doctorId??null;return console.log(t,"extractDoctorIdFromLoginResponse -> id"),null!=t?String(t):null}(t);console.log(e,"extractDoctorIdFromLoginResponse -> doctorId");const o=function(e){if(!e?.data)return null;const t=e.data.name??e.data.doctor_name??e.data.userName??null;return null!=t?String(t):null}(t);T(n),A(e),N(o),H(null),U(!1);try{"undefined"!=typeof localStorage&&(localStorage.setItem(m,n),e&&localStorage.setItem(f,e),o&&localStorage.setItem(x,o))}catch(e){}}})).catch((()=>{})).finally((()=>{e||j(!1)})),()=>{e=!0}}),[b,S,D,z,$]),t.useEffect((()=>{Ge(1),Ae(null)}),[X,re,nt,at,ye,fe]),t.useEffect((()=>{!P&&W&&xt()}),[xt,W,P]),t.useEffect((()=>{const e=document.createElement("link");e.href="https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap",e.rel="stylesheet",document.head.appendChild(e);const t=document.createElement("style");t.innerHTML="\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n \n @media (max-width: 768px) {\n .appointments-grid {\n grid-template-columns: 1.5fr 1fr 0.8fr !important;\n }\n .appointments-header-grid {\n grid-template-columns: 1.5fr 1fr 0.8fr !important;\n }\n .hide-on-mobile {\n display: none !important;\n }\n }\n @media (max-width: 480px) {\n .appointments-header-grid {\n font-size: 10px !important;\n }\n .appointments-grid {\n font-size: 11px !important;\n }\n }\n ",document.head.appendChild(t);const n=()=>{ie(window.innerWidth<768)};return window.addEventListener("resize",n),()=>{document.head.removeChild(e),document.head.removeChild(t),window.removeEventListener("resize",n)}}),[]),t.useEffect((()=>{const e=e=>{!pe||e.target.closest("button")||e.target.closest('input[type="date"]')||ce(!1),ue&&!e.target.closest("[data-appointment-type-picker]")&&me(!1)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}}),[pe,ue]);let kt='"Nunito", serif';const Ct=B||!W&&(!D||!z),It=B||"Sign in required. Redirecting to home...";let Dt;return Dt=P&&D&&z?a.default.createElement("div",{className:E,[F]:"teleconsult-appointments",style:{fontFamily:kt,background:"#F5F5F7",boxSizing:"border-box",height:"100%",minHeight:"100vh",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"24px"}},a.default.createElement("style",null,"@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }"),a.default.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #4C4DDC",borderRadius:"50%",animation:"spin 1s linear infinite",marginBottom:"16px"}}),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0}},"Checking authorisation...")):a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{className:E,[F]:"teleconsult-appointments",style:{fontFamily:kt,background:"#F5F5F7",boxSizing:"border-box",height:"100%",minHeight:"100vh",width:"100%",display:"flex",flexDirection:"column",overflow:"hidden"}},a.default.createElement("div",{style:{background:"#FFFFFF",padding:ae?"10px 12px":"12px 24px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #E5E5E5",flexWrap:"nowrap",gap:ae?"8px":"0"}},a.default.createElement("div",{style:{position:"relative",width:ae?"calc(100% - 90px)":"480px",maxWidth:ae?"none":"480px"}},a.default.createElement("input",{type:"text",placeholder:"Search by patient name or ID",value:ye,onChange:e=>Ee(e.target.value),style:{width:"100%",padding:ae?"8px 32px 8px 10px":"8px 36px 8px 14px",border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:ae?"12px":"13px",fontFamily:kt,background:"#FFFFFF",outline:"none",boxSizing:"border-box"}}),ye&&a.default.createElement("button",{onClick:()=>Ee(""),style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:"#999",fontSize:"16px"},title:"Clear search"},"✕")),!1),a.default.createElement("div",{style:{padding:ae?"12px":"16px 24px",flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"}},a.default.createElement("div",{style:{marginBottom:ae?"10px":"14px"}},a.default.createElement("h1",{style:{fontSize:ae?"18px":"22px",fontWeight:700,color:"#1a1a1a",margin:"0 0 2px 0"}},"Tele Consultation"),a.default.createElement("p",{style:{fontSize:ae?"11px":"12px",color:"#999",margin:0}},"Displaying All Tele Consultation Appointments")),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:ae?"flex-start":"center",marginBottom:ae?"10px":"14px",flexDirection:ae?"column":"row",gap:ae?"12px":"0"}},a.default.createElement("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",width:ae?"100%":"auto"}},a.default.createElement("button",{onClick:()=>G("upcoming"),style:{background:"upcoming"===X?"#4C4DDC":"#FFFFFF",padding:ae?"8px 10px":"9px 16px",border:"upcoming"===X?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:ae?"10px":"13px",color:"upcoming"===X?"white":"#555555",fontWeight:600,fontFamily:kt,cursor:"pointer",flex:ae?"1 1 auto":"none",minWidth:ae?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Upcoming Appointments"),a.default.createElement("button",{onClick:()=>G("completed"),style:{background:"completed"===X?"#4C4DDC":"#FFFFFF",padding:ae?"8px 10px":"9px 16px",border:"completed"===X?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:ae?"10px":"13px",color:"completed"===X?"white":"#555555",fontWeight:600,fontFamily:kt,cursor:"pointer",flex:ae?"1 1 auto":"none",minWidth:ae?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Completed Appointments"),a.default.createElement("button",{onClick:()=>G("cancelled"),style:{background:"cancelled"===X?"#4C4DDC":"#FFFFFF",padding:ae?"8px 10px":"9px 16px",border:"cancelled"===X?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:ae?"10px":"13px",color:"cancelled"===X?"white":"#555555",fontWeight:600,fontFamily:kt,cursor:"pointer",flex:ae?"1 1 auto":"none",minWidth:ae?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Cancelled Appointments")),a.default.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center",width:"auto",position:"relative",justifyContent:ae?"flex-start":"flex-end",flexWrap:"wrap"}},a.default.createElement("button",{onClick:()=>{pe||(lt(nt),st(at),se(re)),ce(!pe)},style:{padding:"8px 12px",fontFamily:kt,fontWeight:600,border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:ae?"11px":"13px",color:"#1a1a1a",background:"#FFFFFF",display:"flex",alignItems:"center",gap:ae?"4px":"6px",cursor:"pointer",flex:"none",minWidth:ae?"100px":"auto",justifyContent:"center"}},a.default.createElement("svg",{width:ae?"12":"14",height:ae?"12":"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},a.default.createElement("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),a.default.createElement("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),a.default.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),a.default.createElement("line",{x1:"3",y1:"10",x2:"21",y2:"10"})),a.default.createElement("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},(()=>{switch(re){case"today":default:return"Today";case"tomorrow":return"Tomorrow";case"currentWeek":return"Current Week";case"thisMonth":return"This Month";case"currentYear":return"Current Year";case"custom":return ae?"Custom":`${nt} to ${at}`}})()),a.default.createElement("svg",{width:ae?"8":"10",height:ae?"8":"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},a.default.createElement("polyline",{points:"6 9 12 15 18 9"}))),pe&&a.default.createElement("div",{style:{position:"absolute",top:"100%",right:ae?"auto":0,left:ae?0:"auto",marginTop:"4px",background:"#FFFFFF",border:"1px solid #E5E5E5",borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.15)",padding:"8px",zIndex:1e3,minWidth:ae?"280px":"240px",width:ae?"calc(100vw - 24px)":"auto",maxWidth:ae?"calc(100vw - 24px)":"280px"}},a.default.createElement("div",{style:{marginBottom:"custom"===de?"12px":"0"}},["thisMonth","today","tomorrow","currentWeek","currentYear","custom"].map((e=>a.default.createElement("button",{key:e,onClick:()=>{if(se(e),"custom"!==e){const t=(e=>{const t=new Date;let n,o;switch(e){case"today":default:n=o=q();break;case"tomorrow":const e=new Date(t);e.setDate(e.getDate()+1),n=o=e.toISOString().split("T")[0];break;case"currentWeek":const a=new Date(t),i=new Date(t),r=t.getDay(),l=0===r?-6:1-r;a.setDate(t.getDate()+l),i.setDate(a.getDate()+6),n=a.toISOString().split("T")[0],o=i.toISOString().split("T")[0];break;case"thisMonth":const d=new Date(t.getFullYear(),t.getMonth(),1),s=new Date(t.getFullYear(),t.getMonth()+1,0);n=d.toISOString().split("T")[0],o=s.toISOString().split("T")[0];break;case"currentYear":n=`${t.getFullYear()}-01-01`,o=`${t.getFullYear()}-12-31`}return{from:n,to:o}})(e);le(e),ot(t.from),it(t.to),lt(t.from),st(t.to),ce(!1)}else lt(""),st("")},style:{width:"100%",padding:"10px 12px",background:de===e?"#E8EEF4":"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:kt,cursor:"pointer",textAlign:"left",fontWeight:de===e?600:400,color:de===e?"#4C4DDC":"#1a1a1a",marginBottom:"4px",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.2s ease"},onMouseEnter:t=>{de!==e&&(t.target.style.background="#F5F5F5")},onMouseLeave:t=>{de!==e&&(t.target.style.background="#FFFFFF")}},a.default.createElement("span",null,{thisMonth:"This Month",today:"Today",tomorrow:"Tomorrow",currentWeek:"Current Week",currentYear:"Current Year",custom:"Custom"}[e]),de===e&&a.default.createElement("span",{style:{color:"#4C4DDC",fontSize:"16px"}},"✓"))))),"custom"===de&&a.default.createElement("div",{style:{paddingTop:"8px",borderTop:"1px solid #E5E5E5"}},a.default.createElement("div",{style:{marginBottom:"8px"}},a.default.createElement("input",{type:"date",value:rt,onChange:e=>lt(e.target.value),placeholder:"Start Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:kt,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{marginBottom:"12px"}},a.default.createElement("input",{type:"date",value:dt,onChange:e=>st(e.target.value),placeholder:"End Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:kt,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{display:"flex",gap:"8px"}},a.default.createElement("button",{onClick:()=>{se(re),lt(nt),st(at),ce(!1)},style:{flex:1,padding:"10px 12px",background:"#FFFFFF",color:"#4C4DDC",border:"1px solid #4C4DDC",borderRadius:"4px",fontSize:"13px",fontFamily:kt,fontWeight:600,cursor:"pointer"}},"Cancel"),a.default.createElement("button",{onClick:()=>{rt&&dt&&(le("custom"),ot(rt),it(dt),ce(!1))},style:{flex:1,padding:"10px 12px",background:"#4C4DDC",color:"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:kt,fontWeight:600,cursor:"pointer"}},"Submit")))))),a.default.createElement("div",{style:{display:"flex",flexDirection:ae?"column":"row",gap:ae?"12px":"14px",flex:1,minHeight:0,overflow:ae?"auto":"hidden"}},a.default.createElement("div",{style:{flex:ae?"none":"1 1 65%",width:ae?"100%":"auto",display:"flex",flexDirection:"column",minHeight:ae?"400px":0}},a.default.createElement("div",{style:{background:"#FFFFFF",borderRadius:"8px",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden",display:"flex",flexDirection:"column",flex:ae?"none":1,minHeight:ae?"auto":0}},a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:ae?"12px 14px":"14px 18px",borderBottom:"1px solid #F1F1F1"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:ae?"6px":"8px"}},a.default.createElement("span",{style:{fontSize:ae?"14px":"15px",fontWeight:700,color:"#1a1a1a"}},"Appointments"),a.default.createElement("span",{style:{background:"#4C4DDC",color:"#fff",fontSize:ae?"10px":"11px",fontWeight:600,padding:ae?"2px 7px":"3px 8px",borderRadius:"12px"}},tt))),a.default.createElement("div",{className:"appointments-header-grid",style:{display:"grid",gridTemplateColumns:ae?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:ae?"8px":"12px",padding:ae?"8px 12px":"10px 18px",background:"#F5F5F5",fontSize:ae?"10px":"12px",fontWeight:600,color:"#666"}},a.default.createElement("div",null,"Patients name"),!ae&&a.default.createElement("div",null,"Patient ID"),a.default.createElement("div",{onClick:ft,style:{display:"flex",alignItems:"center",gap:"3px",cursor:"pointer",userSelect:"none"}},"Date",a.default.createElement("span",{style:{opacity:.7,fontSize:"10px"}},"asc"===ge?"▲":"▼")),!ae&&a.default.createElement("div",null,"Slot"),!ae&&a.default.createElement("div",null,"Doctor")),a.default.createElement("div",{style:{overflow:"auto",flex:1}},P?a.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"40px",color:"#888"}},a.default.createElement("div",{style:{textAlign:"center"}},a.default.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #4C4DDC",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 10px"}}),"Getting token...")):ee?a.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"40px",color:"#888"}},a.default.createElement("div",{style:{textAlign:"center"}},a.default.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #4C4DDC",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 10px"}}),"Loading appointments...")):ne?a.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#FF0000"}},a.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"⚠️ Error"),a.default.createElement("div",{style:{fontSize:"13px"}},ne),a.default.createElement("button",{onClick:xt,style:{marginTop:"16px",padding:"8px 16px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontFamily:kt}},"Retry")):0===Ze.length?a.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#888"}},a.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),a.default.createElement("div",{style:{fontSize:"13px"}},ye?`No appointments found for "${ye}"`:"No appointments found"),ye&&a.default.createElement("button",{onClick:()=>Ee(""),style:{marginTop:"12px",padding:"6px 12px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px",fontFamily:kt}},"Clear Search")):Ze.map((e=>a.default.createElement("div",{key:pt(e),role:"button",tabIndex:0,onClick:()=>gt(e),onKeyDown:t=>"Enter"===t.key&>(e),className:"appointments-grid",style:{display:"grid",gridTemplateColumns:ae?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:ae?"8px":"12px",padding:ae?"10px 12px":"12px 18px",background:pt(Q)===pt(e)?"#E8EEF4":"#FFFFFF",borderTop:"1px solid #F1F1F1",alignItems:"center",cursor:"pointer",fontSize:ae?"11px":"13px"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:ae?"8px":"10px"}},ct(e)?a.default.createElement("img",{src:e.image,alt:"",style:{width:ae?"32px":"36px",height:ae?"32px":"36px",borderRadius:"50%",objectFit:"cover"}}):a.default.createElement("div",{style:{width:ae?"32px":"36px",height:ae?"32px":"36px",borderRadius:"50%",background:mt(e.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:600,fontSize:ae?"14px":"16px"}},ut(e.patientName)),a.default.createElement("div",null,a.default.createElement("div",{style:{fontWeight:600,color:"#1a1a1a",fontSize:ae?"11px":"13px"}},e.patientName),a.default.createElement("div",{style:{fontSize:ae?"9px":"11px",color:"#888"}},e.email))),!ae&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.patientId),a.default.createElement("div",{style:{color:"#555",fontSize:ae?"10px":"12px"}},(()=>{const t=e.appointmentDate||"",n=t.match(/\s(\d{1,2}:\d{2}(?:\s*(?:AM|PM))?)$/i);return n?a.default.createElement(a.default.Fragment,null,a.default.createElement("div",null,t.slice(0,n.index).trim()),a.default.createElement("div",{style:{fontSize:ae?"9px":"11px",color:"#888"}},n[1].trim())):a.default.createElement("div",null,t)})()),!ae&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.appointmentTime||"-"),!ae&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.doctorName||e.doctor||"-"))))),!ee&&!ne&&Ze.length>0&&a.default.createElement("div",{style:{padding:ae?"12px 14px":"14px 18px",borderTop:"1px solid #F1F1F1",display:"flex",justifyContent:"space-between",alignItems:"center",background:"#FFFFFF",flexWrap:ae?"wrap":"nowrap",gap:ae?"10px":"0"}},a.default.createElement("div",{style:{fontSize:ae?"11px":"12px",color:"#666"}},"Showing page ",Xe," of ",et," (",tt," total)"),a.default.createElement("div",{style:{display:"flex",gap:"6px",alignItems:"center"}},a.default.createElement("button",{onClick:()=>Ge((e=>Math.max(1,e-1))),disabled:1===Xe,style:{padding:ae?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:1===Xe?"#F5F5F5":"#FFFFFF",color:1===Xe?"#999":"#1a1a1a",fontSize:ae?"11px":"12px",fontFamily:kt,fontWeight:600,cursor:1===Xe?"not-allowed":"pointer",opacity:1===Xe?.5:1}},"Previous"),a.default.createElement("div",{style:{display:"flex",gap:"4px"}},[...Array(Math.min(5,et))].map(((e,t)=>{let n;return n=et<=5||Xe<=3?t+1:Xe>=et-2?et-4+t:Xe-2+t,a.default.createElement("button",{key:n,onClick:()=>Ge(n),style:{padding:ae?"6px 10px":"6px 12px",border:Xe===n?"none":"1px solid #E5E5E5",borderRadius:"4px",background:Xe===n?"#4C4DDC":"#FFFFFF",color:Xe===n?"#FFFFFF":"#1a1a1a",fontSize:ae?"11px":"12px",fontFamily:kt,fontWeight:600,cursor:"pointer",minWidth:ae?"32px":"36px"}},n)}))),a.default.createElement("button",{onClick:()=>Ge((e=>Math.min(et,e+1))),disabled:Xe===et,style:{padding:ae?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:Xe===et?"#F5F5F5":"#FFFFFF",color:Xe===et?"#999":"#1a1a1a",fontSize:ae?"11px":"12px",fontFamily:kt,fontWeight:600,cursor:Xe===et?"not-allowed":"pointer",opacity:Xe===et?.5:1}},"Next"))))),a.default.createElement("div",{style:{flex:ae?"none":"1 1 35%",width:ae?"100%":"auto",display:Q||!ae?"flex":"none",flexDirection:"column",minHeight:ae?"auto":0}},a.default.createElement("div",{style:{border:"1px solid #E5E5E5",borderRadius:"8px",overflow:"hidden",background:"#FFFFFF",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",display:"flex",flexDirection:"column",flex:ae?"none":1,minHeight:ae?"auto":0}},Q?a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:ae?"12px 14px":"16px 18px",background:"#E8EEF4",borderBottom:"1px solid #E5E5E5"}},a.default.createElement("div",null,a.default.createElement("div",{style:{color:"#002668",fontSize:ae?"14px":"16px",fontWeight:"700"}},Q.patientName||"N/A"),a.default.createElement("div",{style:{color:"#002668",fontSize:ae?"11px":"13px"}},Q.patientId||Q.mrn||"N/A")),a.default.createElement("div",null,ct(Q)?a.default.createElement("img",{style:{width:ae?"36px":"44px",height:ae?"36px":"44px",borderRadius:"50%",objectFit:"cover"},src:Q.image,alt:Q.patientName}):a.default.createElement("div",{style:{width:ae?"36px":"44px",height:ae?"36px":"44px",borderRadius:"50%",background:mt(Q.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:700,fontSize:ae?"16px":"20px"}},ut(Q.patientName)))),a.default.createElement("div",{style:{padding:ae?"12px 14px":"14px 18px",gap:ae?"10px":"12px",display:"flex",flexDirection:"column",background:"white",overflow:"auto",flex:1,position:"relative"}},a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:ae?"10px":"11px",color:"#888",marginBottom:"3px"}},"Speciality"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ae?"12px":"13px"}},Q?.specialisation||Q?.speciality||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:ae?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Type"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ae?"12px":"13px"}},Q?.type||Q?.appointmentType||"Online"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:ae?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Date"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ae?"12px":"13px"}},Q?.date||Q?.appointmentDate||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:ae?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Time"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ae?"12px":"13px"}},Q?.time||Q?.appointmentTime||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:ae?"10px":"11px",color:"#888",marginBottom:"3px"}},"Doctor"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ae?"12px":"13px"}},Q?.doctor||Q?.doctorName||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:ae?"10px":"11px",color:"#888",marginBottom:"3px"}},"Hospital"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ae?"12px":"13px"}},Q?.hospital||Q?.hospitalName||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:ae?"10px":"11px",color:"#888",marginBottom:"3px"}},"Reason for Appointment"),a.default.createElement("div",{style:{fontWeight:"600",fontSize:ae?"11px":"12px",lineHeight:"1.4"}},Q?.reason||Q?.reasonForAppointment||"No reason provided"))),"upcoming"===X&&a.default.createElement("div",{style:{display:"flex",flexDirection:ae?"column":"row",gap:"6px",marginTop:"10px"}},a.default.createElement("button",{type:"button",onClick:ht,disabled:We,style:{flex:1,background:We?"#99e4e8":"#1CC3CE",color:"#FFFFFF",border:"1px solid #1CC3CE",borderRadius:"6px",padding:ae?"10px 8px":"8px 6px",fontFamily:kt,fontWeight:600,fontSize:ae?"11px":"12px",cursor:We?"not-allowed":"pointer"}},We?"Connecting...":"Join Call >")),"upcoming"===X&&Me&&a.default.createElement("div",{style:{fontSize:"11px",color:"#e53935",marginTop:"6px",textAlign:"center",width:"100%"}},"⚠️ ",Me))):a.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",padding:"40px",color:"#888",textAlign:"center"}},a.default.createElement("div",null,a.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),a.default.createElement("div",{style:{fontSize:"13px"}},"Select an appointment to view details"))))))),Fe&&a.default.createElement("div",{style:{position:"fixed",left:ve?"0":ae?"10px":`${Re.x}px`,top:ve?"0":ae?"70px":`${Re.y}px`,right:ve?"0":ae?"10px":"auto",bottom:ve?"0":"auto",width:ve?"100vw":ae?"calc(100vw - 20px)":be?"350px":`${Pe.width}px`,height:ve?"100vh":be?"auto":ae?"300px":`${Pe.height}px`,background:"#FFFFFF",borderRadius:ve?"0":"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",zIndex:1e5,overflow:"hidden",display:"flex",flexDirection:"column",transition:Be||$e?"none":"all 0.3s ease"}},a.default.createElement("div",{onPointerDown:ae||ve?void 0:wt,onPointerMove:ae||ve?void 0:bt,onPointerUp:ae||ve?void 0:St,onPointerCancel:ae||ve?void 0:St,style:{background:"linear-gradient(135deg, #4C4DDC 0%, #3A3BBD 100%)",color:"#FFFFFF",padding:ae?"8px 10px":"10px 12px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:ae||ve?"default":"move",userSelect:"none"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:ae?"6px":"8px",flex:1,minWidth:0}},a.default.createElement("div",{style:{width:ae?"6px":"8px",height:ae?"6px":"8px",borderRadius:"50%",background:"#FF4444",animation:"pulse 2s infinite",flexShrink:0}}),a.default.createElement("span",{style:{fontSize:ae?"11px":"13px",fontWeight:600,fontFamily:kt,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},"Video Call - ",Q?.patientName||"Patient")),a.default.createElement("div",{style:{display:"flex",gap:ae?"4px":"6px",alignItems:"center",flexShrink:0}},!ve&&a.default.createElement("button",{onClick:Et,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:ae?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:ae?"28px":"32px",height:ae?"28px":"32px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:be?"Restore":"Minimize"},be?a.default.createElement("svg",{width:ae?"14":"16",height:ae?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("rect",{x:"3",y:"3",width:"10",height:"10",stroke:"white",strokeWidth:"1.8",fill:"none"})):a.default.createElement("svg",{width:ae?"14":"16",height:ae?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("line",{x1:"3",y1:"8",x2:"13",y2:"8",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round"}))),a.default.createElement("button",{onClick:Ft,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:ae?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:ae?"28px":"32px",height:ae?"28px":"32px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:ve?"Exit Fullscreen":"Fullscreen"},ve?a.default.createElement("svg",{width:ae?"14":"16",height:ae?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("path",{d:"M10 3H13V6M6 13H3V10M13 10V13H10M3 6V3H6",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})):a.default.createElement("svg",{width:ae?"14":"16",height:ae?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("path",{d:"M3 6V3H6M13 10V13H10M10 3H13V6M6 13H3V10",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}))),a.default.createElement("button",{onClick:yt,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:ae?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:ae?"28px":"32px",height:ae?"28px":"32px",fontWeight:"bold",fontSize:ae?"18px":"22px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:"Close"},"×"))),!be&&a.default.createElement("div",{style:{flex:1,background:"#000000",position:"relative"}},a.default.createElement("iframe",{src:(()=>{if(!Ce)return"";const e=String(O||"").replace(/\/?$/,"/");return console.log("${base}token=${callToken}",`${e}token=${Ce}`),`${e}token=${Ce}`})(),style:{width:"100%",height:"100%",border:"none"},allow:"camera; microphone; display-capture; autoplay",allowFullScreen:!0,title:"Video Call"})),!ae&&!ve&&!be&&a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{onPointerDown:e=>vt("top-left",e),onPointerMove:bt,onPointerUp:St,onPointerCancel:St,style:{position:"absolute",left:0,top:0,width:"16px",height:"16px",cursor:"nwse-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onPointerDown:e=>vt("top-right",e),onPointerMove:bt,onPointerUp:St,onPointerCancel:St,style:{position:"absolute",right:0,top:0,width:"16px",height:"16px",cursor:"nesw-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onPointerDown:e=>vt("bottom-left",e),onPointerMove:bt,onPointerUp:St,onPointerCancel:St,style:{position:"absolute",left:0,bottom:0,width:"16px",height:"16px",cursor:"nesw-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onPointerDown:e=>vt("bottom-right",e),onPointerMove:bt,onPointerUp:St,onPointerCancel:St,style:{position:"absolute",right:0,bottom:0,width:"16px",height:"16px",cursor:"nwse-resize",background:"transparent",zIndex:10001}})),a.default.createElement("style",null,"\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n "))),Ct&&a.default.createElement("div",{style:{position:"fixed",inset:0,zIndex:1e5,display:"flex",alignItems:"center",justifyContent:"center",padding:"24px",background:"rgba(0,0,0,0.4)",boxSizing:"border-box"}},a.default.createElement("div",{style:{fontFamily:kt,maxWidth:"400px",width:"100%",padding:"32px 24px",background:"#FFFFFF",borderRadius:"12px",boxShadow:"0 8px 32px rgba(0,0,0,0.2)",textAlign:"center"}},a.default.createElement("div",{style:{fontSize:"48px",marginBottom:"16px"}},"🔒"),a.default.createElement("h2",{style:{fontSize:"20px",fontWeight:700,color:"#1a1a1a",margin:"0 0 8px 0"}},B?"Not authorised":"Sign in required"),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0,lineHeight:1.5}},It),a.default.createElement("p",{style:{fontSize:"13px",color:"#999",marginTop:"16px",marginBottom:0}},"Redirecting to login...")))),a.default.createElement(w,null,Dt)};let S=null;const v={showWidget:(e,t)=>{S||(S=document.createElement("div"),document.body.appendChild(S));const n=()=>a.default.createElement(a.default.Fragment,null,a.default.createElement(b,{config:e}));i.default.render(a.default.createElement(n,null),S)},closePopup:()=>{S&&(i.default.unmountComponentAtNode(S),S=null)}};window.BookingSDK=v,e.AppointmentPage=b,e.PIH_APPOINTMENT_WIDGET_CLASS=E,e.default=v,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
@@ -14,8 +14,8 @@ var _apiConfig = require("../constants/apiConfig");
|
|
|
14
14
|
* @param {object} config - Optional configuration { apiBaseUrl, hospitalId, doctorId }
|
|
15
15
|
* @returns {Promise} Appointments data
|
|
16
16
|
*/
|
|
17
|
-
const getAppointmentsByStatus = async function (status, fromDate, toDate
|
|
18
|
-
let config = arguments.length >
|
|
17
|
+
const getAppointmentsByStatus = async function (status, fromDate, toDate) {
|
|
18
|
+
let config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
19
19
|
// Map status to API format
|
|
20
20
|
let apiStatus = (status || "").toUpperCase();
|
|
21
21
|
if (apiStatus === "INPROGRESS") {
|
|
@@ -32,9 +32,10 @@ const getAppointmentsByStatus = async function (status, fromDate, toDate, type)
|
|
|
32
32
|
toDate,
|
|
33
33
|
statuses: apiStatus
|
|
34
34
|
};
|
|
35
|
-
if (type && String(type).toUpperCase() !== "ALL") {
|
|
36
|
-
|
|
37
|
-
}
|
|
35
|
+
// if (type && String(type).toUpperCase() !== "ALL") {
|
|
36
|
+
// params.appointmentType = String(type).toUpperCase();
|
|
37
|
+
// }
|
|
38
|
+
params.appointmentType = 'ONLINE';
|
|
38
39
|
const url = `${baseURL}${_apiConfig.API_PATHS.APPOINTMENTS}`;
|
|
39
40
|
|
|
40
41
|
// Return raw response (including status) so caller can detect 401 and re-login
|
package/package.json
CHANGED
|
@@ -425,11 +425,10 @@ const AppointmentPage = ({ config = {} }) => {
|
|
|
425
425
|
}
|
|
426
426
|
};
|
|
427
427
|
|
|
428
|
-
const fetchAppointments = useCallback(async (
|
|
428
|
+
const fetchAppointments = useCallback(async () => {
|
|
429
429
|
if (!appToken) return;
|
|
430
430
|
console.log(doctorIdFromLogin, 'fetchAppointments -> doctorIdFromLogin')
|
|
431
431
|
const doctorId = doctorIdFromLogin;
|
|
432
|
-
const typeToUse = overrideType !== undefined ? overrideType : appointmentTypeFilter;
|
|
433
432
|
setLoading(true);
|
|
434
433
|
setError(null);
|
|
435
434
|
try {
|
|
@@ -439,7 +438,7 @@ const AppointmentPage = ({ config = {} }) => {
|
|
|
439
438
|
doctorId,
|
|
440
439
|
token: appToken,
|
|
441
440
|
};
|
|
442
|
-
const response = await getAppointmentsByStatus(activeTab, fromDate, toDate,
|
|
441
|
+
const response = await getAppointmentsByStatus(activeTab, fromDate, toDate, serviceConfig);
|
|
443
442
|
if (response.status === 401 || response.status === 403) {
|
|
444
443
|
// Token expired — clear stored token and trigger re-login (SSO effect will fire)
|
|
445
444
|
try {
|
|
@@ -478,6 +477,7 @@ const AppointmentPage = ({ config = {} }) => {
|
|
|
478
477
|
// Handle appointment selection - no API call, just show data from list
|
|
479
478
|
const handleAppointmentSelect = (appointment) => {
|
|
480
479
|
setSelectedAppointment(appointment);
|
|
480
|
+
setCallError(null);
|
|
481
481
|
};
|
|
482
482
|
|
|
483
483
|
// Logout: clear storage and redirect to login page
|
|
@@ -516,21 +516,31 @@ const AppointmentPage = ({ config = {} }) => {
|
|
|
516
516
|
console.log(selectedAppointment, 'selectedAppointment')
|
|
517
517
|
console.log(callConfig, 'callConfig')
|
|
518
518
|
const response = await initiateConsultation(selectedAppointment, callConfig);
|
|
519
|
+
console.log(response.status, 'response')
|
|
519
520
|
if (response.status === 401 || response.status === 403) {
|
|
520
|
-
|
|
521
|
-
|
|
521
|
+
// Token expired — clear stored token and trigger re-login (same as fetchAppointments)
|
|
522
|
+
try {
|
|
523
|
+
if (typeof localStorage !== "undefined") {
|
|
524
|
+
localStorage.removeItem(STORAGE_KEY_APP_TOKEN);
|
|
525
|
+
localStorage.removeItem(STORAGE_KEY_DOCTOR_ID);
|
|
526
|
+
localStorage.removeItem(STORAGE_KEY_USER_NAME);
|
|
527
|
+
}
|
|
528
|
+
} catch (e) {}
|
|
529
|
+
setAppToken(null);
|
|
530
|
+
setDoctorIdFromLogin(null);
|
|
531
|
+
setUserName(null);
|
|
532
|
+
setRefreshLoginTrigger((t) => t + 1);
|
|
533
|
+
setCallError("Session expired. Re-authenticating...");
|
|
522
534
|
return;
|
|
523
535
|
}
|
|
524
536
|
if (response.err || !response.data?.token) {
|
|
525
537
|
setCallError(String(response.err || "Failed to initiate call"));
|
|
526
|
-
setCallLoading(false);
|
|
527
538
|
return;
|
|
528
539
|
}
|
|
529
540
|
const joinCallUrlBase = config.joinCallUrl || JOIN_CALL_URL;
|
|
530
541
|
const joinCallUrl = response.data.token ? String(joinCallUrlBase || "").replace(/\/?$/, "/") + response.data.token : "";
|
|
531
542
|
console.log("joinCallUrl", joinCallUrl)
|
|
532
543
|
setCallToken(response.data.token);
|
|
533
|
-
// setCallUrl(response.data.url || "");
|
|
534
544
|
setCallUrl(joinCallUrl || '');
|
|
535
545
|
setShowPipVideo(true);
|
|
536
546
|
setIsPipMinimized(false);
|
|
@@ -544,7 +554,6 @@ const AppointmentPage = ({ config = {} }) => {
|
|
|
544
554
|
} catch (err) {
|
|
545
555
|
setCallError(err.message || "Failed to initiate call");
|
|
546
556
|
} finally {
|
|
547
|
-
setCallError(null);
|
|
548
557
|
setCallLoading(false);
|
|
549
558
|
}
|
|
550
559
|
};
|
|
@@ -774,9 +783,10 @@ const AppointmentPage = ({ config = {} }) => {
|
|
|
774
783
|
return () => { cancelled = true; };
|
|
775
784
|
}, [apiBaseUrl, hospitalId, idToken, email, refreshLoginTrigger]);
|
|
776
785
|
|
|
777
|
-
// Reset page to 1 when filters change
|
|
786
|
+
// Reset page to 1 and clear call error when filters/tab change
|
|
778
787
|
useEffect(() => {
|
|
779
788
|
setCurrentPage(1);
|
|
789
|
+
setCallError(null);
|
|
780
790
|
}, [activeTab, selectedDate, fromDate, toDate, searchQuery, appointmentTypeFilter]);
|
|
781
791
|
|
|
782
792
|
// Fetch appointments when we have appToken (tab/date change triggers refetch via fetchAppointments deps)
|
|
@@ -1197,7 +1207,7 @@ const AppointmentPage = ({ config = {} }) => {
|
|
|
1197
1207
|
|
|
1198
1208
|
{/* Date Filter + Type of Appointment Filter */}
|
|
1199
1209
|
<div style={{ display: "flex", gap: "8px", alignItems: "center", width: isMobile ? "auto" : "auto", position: "relative", justifyContent: isMobile ? "flex-start" : "flex-end", flexWrap: "wrap" }}>
|
|
1200
|
-
{/* Type of Appointment Filter
|
|
1210
|
+
{/* Type of Appointment Filter
|
|
1201
1211
|
<div style={{ position: "relative" }} data-appointment-type-picker>
|
|
1202
1212
|
<button
|
|
1203
1213
|
onClick={() => setShowAppointmentTypePicker(!showAppointmentTypePicker)}
|
|
@@ -1293,6 +1303,7 @@ const AppointmentPage = ({ config = {} }) => {
|
|
|
1293
1303
|
</div>
|
|
1294
1304
|
)}
|
|
1295
1305
|
</div>
|
|
1306
|
+
*/}
|
|
1296
1307
|
{/* Date Filter */}
|
|
1297
1308
|
<button
|
|
1298
1309
|
onClick={() => {
|
|
@@ -2117,7 +2128,7 @@ const AppointmentPage = ({ config = {} }) => {
|
|
|
2117
2128
|
background: "#FFFFFF",
|
|
2118
2129
|
borderRadius: isPipFullscreen ? "0" : "8px",
|
|
2119
2130
|
boxShadow: "0 8px 24px rgba(0, 0, 0, 0.3)",
|
|
2120
|
-
zIndex:
|
|
2131
|
+
zIndex: 100000,
|
|
2121
2132
|
overflow: "hidden",
|
|
2122
2133
|
display: "flex",
|
|
2123
2134
|
flexDirection: "column",
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
* @param {object} config - Optional configuration { apiBaseUrl, hospitalId, doctorId }
|
|
14
14
|
* @returns {Promise} Appointments data
|
|
15
15
|
*/
|
|
16
|
-
export const getAppointmentsByStatus = async (status, fromDate, toDate,
|
|
16
|
+
export const getAppointmentsByStatus = async (status, fromDate, toDate, config = {}) => {
|
|
17
17
|
// Map status to API format
|
|
18
18
|
let apiStatus = (status || "").toUpperCase();
|
|
19
19
|
|
|
@@ -27,9 +27,10 @@ export const getAppointmentsByStatus = async (status, fromDate, toDate, type, co
|
|
|
27
27
|
const token = config.token || '';
|
|
28
28
|
|
|
29
29
|
const params = { hospitalId, doctorId, fromDate, toDate, statuses: apiStatus };
|
|
30
|
-
if (type && String(type).toUpperCase() !== "ALL") {
|
|
31
|
-
|
|
32
|
-
}
|
|
30
|
+
// if (type && String(type).toUpperCase() !== "ALL") {
|
|
31
|
+
// params.appointmentType = String(type).toUpperCase();
|
|
32
|
+
// }
|
|
33
|
+
params.appointmentType = 'ONLINE';
|
|
33
34
|
const url = `${baseURL}${API_PATHS.APPOINTMENTS}`;
|
|
34
35
|
|
|
35
36
|
// Return raw response (including status) so caller can detect 401 and re-login
|