pih-appointment-widget 0.0.21 → 0.0.22
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 +137 -7
- package/dist/pih-appointment-widget.umd.js +142 -11
- package/dist/pih-appointment-widget.umd.min.js +1 -1
- package/dist/services/appointmentService.js +5 -4
- package/package.json +1 -1
- package/src/components/AppointmentPage.js +110 -8
- package/src/services/appointmentService.js +5 -2
|
@@ -331,6 +331,8 @@ const AppointmentPage = _ref => {
|
|
|
331
331
|
const [selectedDate, setSelectedDate] = (0, _react.useState)("today"); // today, tomorrow, week, month, year, custom
|
|
332
332
|
const [dateOption, setDateOption] = (0, _react.useState)("today"); // Currently selected option in dropdown
|
|
333
333
|
const [showDatePicker, setShowDatePicker] = (0, _react.useState)(false);
|
|
334
|
+
const [showAppointmentTypePicker, setShowAppointmentTypePicker] = (0, _react.useState)(false);
|
|
335
|
+
const [appointmentTypeFilter, setAppointmentTypeFilter] = (0, _react.useState)("all"); // 'all' | 'ONLINE' | 'PHYSICAL'
|
|
334
336
|
const [sortOrder, setSortOrder] = (0, _react.useState)("asc"); // asc or desc for date sorting
|
|
335
337
|
const [searchQuery, setSearchQuery] = (0, _react.useState)(""); // Search query for filtering
|
|
336
338
|
|
|
@@ -441,10 +443,11 @@ const AppointmentPage = _ref => {
|
|
|
441
443
|
setSelectedAppointment(sortedAppointments[0]);
|
|
442
444
|
}
|
|
443
445
|
};
|
|
444
|
-
const fetchAppointments = (0, _react.useCallback)(async
|
|
446
|
+
const fetchAppointments = (0, _react.useCallback)(async overrideType => {
|
|
445
447
|
if (!appToken) return;
|
|
446
448
|
console.log(doctorIdFromLogin, 'fetchAppointments -> doctorIdFromLogin');
|
|
447
449
|
const doctorId = doctorIdFromLogin;
|
|
450
|
+
const typeToUse = overrideType !== undefined ? overrideType : appointmentTypeFilter;
|
|
448
451
|
setLoading(true);
|
|
449
452
|
setError(null);
|
|
450
453
|
try {
|
|
@@ -454,7 +457,7 @@ const AppointmentPage = _ref => {
|
|
|
454
457
|
doctorId,
|
|
455
458
|
token: appToken
|
|
456
459
|
};
|
|
457
|
-
const response = await (0, _appointmentService.getAppointmentsByStatus)(activeTab, fromDate, toDate,
|
|
460
|
+
const response = await (0, _appointmentService.getAppointmentsByStatus)(activeTab, fromDate, toDate, typeToUse, serviceConfig);
|
|
458
461
|
if (response.status === 401 || response.status === 403) {
|
|
459
462
|
// Token expired — clear stored token and trigger re-login (SSO effect will fire)
|
|
460
463
|
try {
|
|
@@ -488,7 +491,7 @@ const AppointmentPage = _ref => {
|
|
|
488
491
|
} finally {
|
|
489
492
|
setLoading(false);
|
|
490
493
|
}
|
|
491
|
-
}, [activeTab, fromDate, toDate, apiBaseUrl, hospitalId, doctorIdFromLogin, appToken]);
|
|
494
|
+
}, [activeTab, fromDate, toDate, appointmentTypeFilter, apiBaseUrl, hospitalId, doctorIdFromLogin, appToken]);
|
|
492
495
|
|
|
493
496
|
// Handle appointment selection - no API call, just show data from list
|
|
494
497
|
const handleAppointmentSelect = appointment => {
|
|
@@ -794,7 +797,7 @@ const AppointmentPage = _ref => {
|
|
|
794
797
|
// Reset page to 1 when filters change
|
|
795
798
|
(0, _react.useEffect)(() => {
|
|
796
799
|
setCurrentPage(1);
|
|
797
|
-
}, [activeTab, selectedDate, fromDate, toDate, searchQuery]);
|
|
800
|
+
}, [activeTab, selectedDate, fromDate, toDate, searchQuery, appointmentTypeFilter]);
|
|
798
801
|
|
|
799
802
|
// Fetch appointments when we have appToken (tab/date change triggers refetch via fetchAppointments deps)
|
|
800
803
|
(0, _react.useEffect)(() => {
|
|
@@ -851,18 +854,21 @@ const AppointmentPage = _ref => {
|
|
|
851
854
|
};
|
|
852
855
|
}, []);
|
|
853
856
|
|
|
854
|
-
// Close date picker when clicking outside
|
|
857
|
+
// Close date picker and appointment type picker when clicking outside
|
|
855
858
|
(0, _react.useEffect)(() => {
|
|
856
859
|
const handleClickOutside = event => {
|
|
857
860
|
if (showDatePicker && !event.target.closest('button') && !event.target.closest('input[type="date"]')) {
|
|
858
861
|
setShowDatePicker(false);
|
|
859
862
|
}
|
|
863
|
+
if (showAppointmentTypePicker && !event.target.closest('[data-appointment-type-picker]')) {
|
|
864
|
+
setShowAppointmentTypePicker(false);
|
|
865
|
+
}
|
|
860
866
|
};
|
|
861
867
|
document.addEventListener("click", handleClickOutside);
|
|
862
868
|
return () => {
|
|
863
869
|
document.removeEventListener("click", handleClickOutside);
|
|
864
870
|
};
|
|
865
|
-
}, [showDatePicker]);
|
|
871
|
+
}, [showDatePicker, showAppointmentTypePicker]);
|
|
866
872
|
let fontFamily = '"Nunito", serif';
|
|
867
873
|
|
|
868
874
|
// Error as popup overlay (main page stays in background); auto-redirect to home
|
|
@@ -1215,9 +1221,133 @@ const AppointmentPage = _ref => {
|
|
|
1215
1221
|
alignItems: "center",
|
|
1216
1222
|
width: isMobile ? "auto" : "auto",
|
|
1217
1223
|
position: "relative",
|
|
1218
|
-
justifyContent: isMobile ? "flex-start" : "flex-end"
|
|
1224
|
+
justifyContent: isMobile ? "flex-start" : "flex-end",
|
|
1225
|
+
flexWrap: "wrap"
|
|
1219
1226
|
}
|
|
1227
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
1228
|
+
style: {
|
|
1229
|
+
position: "relative"
|
|
1230
|
+
},
|
|
1231
|
+
"data-appointment-type-picker": true
|
|
1220
1232
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
1233
|
+
onClick: () => setShowAppointmentTypePicker(!showAppointmentTypePicker),
|
|
1234
|
+
style: {
|
|
1235
|
+
padding: isMobile ? "8px 12px" : "8px 12px",
|
|
1236
|
+
fontFamily,
|
|
1237
|
+
fontWeight: 600,
|
|
1238
|
+
border: "1px solid #E5E5E5",
|
|
1239
|
+
borderRadius: "6px",
|
|
1240
|
+
fontSize: isMobile ? "11px" : "13px",
|
|
1241
|
+
color: "#1a1a1a",
|
|
1242
|
+
background: "#FFFFFF",
|
|
1243
|
+
display: "flex",
|
|
1244
|
+
alignItems: "center",
|
|
1245
|
+
gap: isMobile ? "4px" : "6px",
|
|
1246
|
+
cursor: "pointer",
|
|
1247
|
+
flex: "none",
|
|
1248
|
+
minWidth: isMobile ? "100px" : "auto",
|
|
1249
|
+
justifyContent: "center"
|
|
1250
|
+
}
|
|
1251
|
+
}, /*#__PURE__*/_react.default.createElement("svg", {
|
|
1252
|
+
width: isMobile ? "14" : "16",
|
|
1253
|
+
height: isMobile ? "14" : "16",
|
|
1254
|
+
viewBox: "0 0 24 24",
|
|
1255
|
+
fill: "none",
|
|
1256
|
+
stroke: "currentColor",
|
|
1257
|
+
strokeWidth: "2",
|
|
1258
|
+
strokeLinecap: "round",
|
|
1259
|
+
strokeLinejoin: "round"
|
|
1260
|
+
}, /*#__PURE__*/_react.default.createElement("path", {
|
|
1261
|
+
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"
|
|
1262
|
+
}), /*#__PURE__*/_react.default.createElement("path", {
|
|
1263
|
+
d: "M8 12h8M8 16h5"
|
|
1264
|
+
})), /*#__PURE__*/_react.default.createElement("span", {
|
|
1265
|
+
style: {
|
|
1266
|
+
overflow: "hidden",
|
|
1267
|
+
textOverflow: "ellipsis",
|
|
1268
|
+
whiteSpace: "nowrap",
|
|
1269
|
+
color: "#4C4DDC"
|
|
1270
|
+
}
|
|
1271
|
+
}, appointmentTypeFilter === "all" ? "All Appointment" : appointmentTypeFilter === "ONLINE" ? "Online" : "Physical"), /*#__PURE__*/_react.default.createElement("svg", {
|
|
1272
|
+
width: isMobile ? "8" : "10",
|
|
1273
|
+
height: isMobile ? "8" : "10",
|
|
1274
|
+
viewBox: "0 0 24 24",
|
|
1275
|
+
fill: "none",
|
|
1276
|
+
stroke: "currentColor",
|
|
1277
|
+
strokeWidth: "2",
|
|
1278
|
+
strokeLinecap: "round",
|
|
1279
|
+
strokeLinejoin: "round"
|
|
1280
|
+
}, /*#__PURE__*/_react.default.createElement("polyline", {
|
|
1281
|
+
points: "6 9 12 15 18 9"
|
|
1282
|
+
}))), showAppointmentTypePicker && /*#__PURE__*/_react.default.createElement("div", {
|
|
1283
|
+
style: {
|
|
1284
|
+
position: "absolute",
|
|
1285
|
+
top: "100%",
|
|
1286
|
+
right: isMobile ? "auto" : 0,
|
|
1287
|
+
left: isMobile ? 0 : "auto",
|
|
1288
|
+
marginTop: "4px",
|
|
1289
|
+
background: "#FFFFFF",
|
|
1290
|
+
border: "1px solid #E5E5E5",
|
|
1291
|
+
borderRadius: "8px",
|
|
1292
|
+
boxShadow: "0 4px 16px rgba(0,0,0,0.15)",
|
|
1293
|
+
padding: "8px",
|
|
1294
|
+
zIndex: 1000,
|
|
1295
|
+
minWidth: isMobile ? "240px" : "200px",
|
|
1296
|
+
width: isMobile ? "calc(100vw - 24px)" : "auto",
|
|
1297
|
+
maxWidth: isMobile ? "calc(100vw - 24px)" : "240px"
|
|
1298
|
+
}
|
|
1299
|
+
}, [{
|
|
1300
|
+
value: "all",
|
|
1301
|
+
label: "All Appointment"
|
|
1302
|
+
}, {
|
|
1303
|
+
value: "ONLINE",
|
|
1304
|
+
label: "Online"
|
|
1305
|
+
}, {
|
|
1306
|
+
value: "PHYSICAL",
|
|
1307
|
+
label: "Physical"
|
|
1308
|
+
}].map(_ref2 => {
|
|
1309
|
+
let {
|
|
1310
|
+
value,
|
|
1311
|
+
label
|
|
1312
|
+
} = _ref2;
|
|
1313
|
+
return /*#__PURE__*/_react.default.createElement("button", {
|
|
1314
|
+
key: value,
|
|
1315
|
+
onClick: () => {
|
|
1316
|
+
setAppointmentTypeFilter(value);
|
|
1317
|
+
setShowAppointmentTypePicker(false);
|
|
1318
|
+
fetchAppointments(value);
|
|
1319
|
+
},
|
|
1320
|
+
style: {
|
|
1321
|
+
width: "100%",
|
|
1322
|
+
padding: "10px 12px",
|
|
1323
|
+
background: appointmentTypeFilter === value ? "#E8EEF4" : "#FFFFFF",
|
|
1324
|
+
border: "none",
|
|
1325
|
+
borderRadius: "4px",
|
|
1326
|
+
fontSize: "13px",
|
|
1327
|
+
fontFamily,
|
|
1328
|
+
cursor: "pointer",
|
|
1329
|
+
textAlign: "left",
|
|
1330
|
+
fontWeight: appointmentTypeFilter === value ? 600 : 400,
|
|
1331
|
+
color: appointmentTypeFilter === value ? "#4C4DDC" : "#1a1a1a",
|
|
1332
|
+
marginBottom: "4px",
|
|
1333
|
+
display: "flex",
|
|
1334
|
+
justifyContent: "space-between",
|
|
1335
|
+
alignItems: "center",
|
|
1336
|
+
transition: "all 0.2s ease"
|
|
1337
|
+
},
|
|
1338
|
+
onMouseEnter: e => {
|
|
1339
|
+
if (appointmentTypeFilter !== value) e.target.style.background = "#F5F5F5";
|
|
1340
|
+
},
|
|
1341
|
+
onMouseLeave: e => {
|
|
1342
|
+
if (appointmentTypeFilter !== value) e.target.style.background = "#FFFFFF";
|
|
1343
|
+
}
|
|
1344
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, label), appointmentTypeFilter === value && /*#__PURE__*/_react.default.createElement("span", {
|
|
1345
|
+
style: {
|
|
1346
|
+
color: "#4C4DDC",
|
|
1347
|
+
fontSize: "16px"
|
|
1348
|
+
}
|
|
1349
|
+
}, "\u2713"));
|
|
1350
|
+
}))), /*#__PURE__*/_react.default.createElement("button", {
|
|
1221
1351
|
onClick: () => {
|
|
1222
1352
|
// Initialize temp dates and option with current values when opening picker
|
|
1223
1353
|
if (!showDatePicker) {
|
|
@@ -164,8 +164,7 @@
|
|
|
164
164
|
* @param {object} config - Optional configuration { apiBaseUrl, hospitalId, doctorId }
|
|
165
165
|
* @returns {Promise} Appointments data
|
|
166
166
|
*/
|
|
167
|
-
const getAppointmentsByStatus = async function (status, fromDate, toDate) {
|
|
168
|
-
let type = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'ONLINE';
|
|
167
|
+
const getAppointmentsByStatus = async function (status, fromDate, toDate, type) {
|
|
169
168
|
let config = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
170
169
|
// Map status to API format
|
|
171
170
|
let apiStatus = (status || "").toUpperCase();
|
|
@@ -181,9 +180,11 @@
|
|
|
181
180
|
doctorId,
|
|
182
181
|
fromDate,
|
|
183
182
|
toDate,
|
|
184
|
-
statuses: apiStatus
|
|
185
|
-
type
|
|
183
|
+
statuses: apiStatus
|
|
186
184
|
};
|
|
185
|
+
if (type && String(type).toUpperCase() !== "ALL") {
|
|
186
|
+
params.appointmentType = String(type).toUpperCase();
|
|
187
|
+
}
|
|
187
188
|
const url = `${baseURL}${API_PATHS.APPOINTMENTS}`;
|
|
188
189
|
|
|
189
190
|
// Return raw response (including status) so caller can detect 401 and re-login
|
|
@@ -536,6 +537,8 @@
|
|
|
536
537
|
const [selectedDate, setSelectedDate] = React.useState("today"); // today, tomorrow, week, month, year, custom
|
|
537
538
|
const [dateOption, setDateOption] = React.useState("today"); // Currently selected option in dropdown
|
|
538
539
|
const [showDatePicker, setShowDatePicker] = React.useState(false);
|
|
540
|
+
const [showAppointmentTypePicker, setShowAppointmentTypePicker] = React.useState(false);
|
|
541
|
+
const [appointmentTypeFilter, setAppointmentTypeFilter] = React.useState("all"); // 'all' | 'ONLINE' | 'PHYSICAL'
|
|
539
542
|
const [sortOrder, setSortOrder] = React.useState("asc"); // asc or desc for date sorting
|
|
540
543
|
const [searchQuery, setSearchQuery] = React.useState(""); // Search query for filtering
|
|
541
544
|
|
|
@@ -646,10 +649,11 @@
|
|
|
646
649
|
setSelectedAppointment(sortedAppointments[0]);
|
|
647
650
|
}
|
|
648
651
|
};
|
|
649
|
-
const fetchAppointments = React.useCallback(async
|
|
652
|
+
const fetchAppointments = React.useCallback(async overrideType => {
|
|
650
653
|
if (!appToken) return;
|
|
651
654
|
console.log(doctorIdFromLogin, 'fetchAppointments -> doctorIdFromLogin');
|
|
652
655
|
const doctorId = doctorIdFromLogin;
|
|
656
|
+
const typeToUse = overrideType !== undefined ? overrideType : appointmentTypeFilter;
|
|
653
657
|
setLoading(true);
|
|
654
658
|
setError(null);
|
|
655
659
|
try {
|
|
@@ -659,7 +663,7 @@
|
|
|
659
663
|
doctorId,
|
|
660
664
|
token: appToken
|
|
661
665
|
};
|
|
662
|
-
const response = await getAppointmentsByStatus(activeTab, fromDate, toDate,
|
|
666
|
+
const response = await getAppointmentsByStatus(activeTab, fromDate, toDate, typeToUse, serviceConfig);
|
|
663
667
|
if (response.status === 401 || response.status === 403) {
|
|
664
668
|
// Token expired — clear stored token and trigger re-login (SSO effect will fire)
|
|
665
669
|
try {
|
|
@@ -693,7 +697,7 @@
|
|
|
693
697
|
} finally {
|
|
694
698
|
setLoading(false);
|
|
695
699
|
}
|
|
696
|
-
}, [activeTab, fromDate, toDate, apiBaseUrl, hospitalId, doctorIdFromLogin, appToken]);
|
|
700
|
+
}, [activeTab, fromDate, toDate, appointmentTypeFilter, apiBaseUrl, hospitalId, doctorIdFromLogin, appToken]);
|
|
697
701
|
|
|
698
702
|
// Handle appointment selection - no API call, just show data from list
|
|
699
703
|
const handleAppointmentSelect = appointment => {
|
|
@@ -980,7 +984,7 @@
|
|
|
980
984
|
// Reset page to 1 when filters change
|
|
981
985
|
React.useEffect(() => {
|
|
982
986
|
setCurrentPage(1);
|
|
983
|
-
}, [activeTab, selectedDate, fromDate, toDate, searchQuery]);
|
|
987
|
+
}, [activeTab, selectedDate, fromDate, toDate, searchQuery, appointmentTypeFilter]);
|
|
984
988
|
|
|
985
989
|
// Fetch appointments when we have appToken (tab/date change triggers refetch via fetchAppointments deps)
|
|
986
990
|
React.useEffect(() => {
|
|
@@ -1037,18 +1041,21 @@
|
|
|
1037
1041
|
};
|
|
1038
1042
|
}, []);
|
|
1039
1043
|
|
|
1040
|
-
// Close date picker when clicking outside
|
|
1044
|
+
// Close date picker and appointment type picker when clicking outside
|
|
1041
1045
|
React.useEffect(() => {
|
|
1042
1046
|
const handleClickOutside = event => {
|
|
1043
1047
|
if (showDatePicker && !event.target.closest('button') && !event.target.closest('input[type="date"]')) {
|
|
1044
1048
|
setShowDatePicker(false);
|
|
1045
1049
|
}
|
|
1050
|
+
if (showAppointmentTypePicker && !event.target.closest('[data-appointment-type-picker]')) {
|
|
1051
|
+
setShowAppointmentTypePicker(false);
|
|
1052
|
+
}
|
|
1046
1053
|
};
|
|
1047
1054
|
document.addEventListener("click", handleClickOutside);
|
|
1048
1055
|
return () => {
|
|
1049
1056
|
document.removeEventListener("click", handleClickOutside);
|
|
1050
1057
|
};
|
|
1051
|
-
}, [showDatePicker]);
|
|
1058
|
+
}, [showDatePicker, showAppointmentTypePicker]);
|
|
1052
1059
|
let fontFamily = '"Nunito", serif';
|
|
1053
1060
|
|
|
1054
1061
|
// Error as popup overlay (main page stays in background); auto-redirect to home
|
|
@@ -1255,9 +1262,133 @@
|
|
|
1255
1262
|
alignItems: "center",
|
|
1256
1263
|
width: isMobile ? "auto" : "auto",
|
|
1257
1264
|
position: "relative",
|
|
1258
|
-
justifyContent: isMobile ? "flex-start" : "flex-end"
|
|
1265
|
+
justifyContent: isMobile ? "flex-start" : "flex-end",
|
|
1266
|
+
flexWrap: "wrap"
|
|
1259
1267
|
}
|
|
1268
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1269
|
+
style: {
|
|
1270
|
+
position: "relative"
|
|
1271
|
+
},
|
|
1272
|
+
"data-appointment-type-picker": true
|
|
1260
1273
|
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
1274
|
+
onClick: () => setShowAppointmentTypePicker(!showAppointmentTypePicker),
|
|
1275
|
+
style: {
|
|
1276
|
+
padding: isMobile ? "8px 12px" : "8px 12px",
|
|
1277
|
+
fontFamily,
|
|
1278
|
+
fontWeight: 600,
|
|
1279
|
+
border: "1px solid #E5E5E5",
|
|
1280
|
+
borderRadius: "6px",
|
|
1281
|
+
fontSize: isMobile ? "11px" : "13px",
|
|
1282
|
+
color: "#1a1a1a",
|
|
1283
|
+
background: "#FFFFFF",
|
|
1284
|
+
display: "flex",
|
|
1285
|
+
alignItems: "center",
|
|
1286
|
+
gap: isMobile ? "4px" : "6px",
|
|
1287
|
+
cursor: "pointer",
|
|
1288
|
+
flex: "none",
|
|
1289
|
+
minWidth: isMobile ? "100px" : "auto",
|
|
1290
|
+
justifyContent: "center"
|
|
1291
|
+
}
|
|
1292
|
+
}, /*#__PURE__*/React__default["default"].createElement("svg", {
|
|
1293
|
+
width: isMobile ? "14" : "16",
|
|
1294
|
+
height: isMobile ? "14" : "16",
|
|
1295
|
+
viewBox: "0 0 24 24",
|
|
1296
|
+
fill: "none",
|
|
1297
|
+
stroke: "currentColor",
|
|
1298
|
+
strokeWidth: "2",
|
|
1299
|
+
strokeLinecap: "round",
|
|
1300
|
+
strokeLinejoin: "round"
|
|
1301
|
+
}, /*#__PURE__*/React__default["default"].createElement("path", {
|
|
1302
|
+
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"
|
|
1303
|
+
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
1304
|
+
d: "M8 12h8M8 16h5"
|
|
1305
|
+
})), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
1306
|
+
style: {
|
|
1307
|
+
overflow: "hidden",
|
|
1308
|
+
textOverflow: "ellipsis",
|
|
1309
|
+
whiteSpace: "nowrap",
|
|
1310
|
+
color: "#4C4DDC"
|
|
1311
|
+
}
|
|
1312
|
+
}, appointmentTypeFilter === "all" ? "All Appointment" : appointmentTypeFilter === "ONLINE" ? "Online" : "Physical"), /*#__PURE__*/React__default["default"].createElement("svg", {
|
|
1313
|
+
width: isMobile ? "8" : "10",
|
|
1314
|
+
height: isMobile ? "8" : "10",
|
|
1315
|
+
viewBox: "0 0 24 24",
|
|
1316
|
+
fill: "none",
|
|
1317
|
+
stroke: "currentColor",
|
|
1318
|
+
strokeWidth: "2",
|
|
1319
|
+
strokeLinecap: "round",
|
|
1320
|
+
strokeLinejoin: "round"
|
|
1321
|
+
}, /*#__PURE__*/React__default["default"].createElement("polyline", {
|
|
1322
|
+
points: "6 9 12 15 18 9"
|
|
1323
|
+
}))), showAppointmentTypePicker && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1324
|
+
style: {
|
|
1325
|
+
position: "absolute",
|
|
1326
|
+
top: "100%",
|
|
1327
|
+
right: isMobile ? "auto" : 0,
|
|
1328
|
+
left: isMobile ? 0 : "auto",
|
|
1329
|
+
marginTop: "4px",
|
|
1330
|
+
background: "#FFFFFF",
|
|
1331
|
+
border: "1px solid #E5E5E5",
|
|
1332
|
+
borderRadius: "8px",
|
|
1333
|
+
boxShadow: "0 4px 16px rgba(0,0,0,0.15)",
|
|
1334
|
+
padding: "8px",
|
|
1335
|
+
zIndex: 1000,
|
|
1336
|
+
minWidth: isMobile ? "240px" : "200px",
|
|
1337
|
+
width: isMobile ? "calc(100vw - 24px)" : "auto",
|
|
1338
|
+
maxWidth: isMobile ? "calc(100vw - 24px)" : "240px"
|
|
1339
|
+
}
|
|
1340
|
+
}, [{
|
|
1341
|
+
value: "all",
|
|
1342
|
+
label: "All Appointment"
|
|
1343
|
+
}, {
|
|
1344
|
+
value: "ONLINE",
|
|
1345
|
+
label: "Online"
|
|
1346
|
+
}, {
|
|
1347
|
+
value: "PHYSICAL",
|
|
1348
|
+
label: "Physical"
|
|
1349
|
+
}].map(_ref2 => {
|
|
1350
|
+
let {
|
|
1351
|
+
value,
|
|
1352
|
+
label
|
|
1353
|
+
} = _ref2;
|
|
1354
|
+
return /*#__PURE__*/React__default["default"].createElement("button", {
|
|
1355
|
+
key: value,
|
|
1356
|
+
onClick: () => {
|
|
1357
|
+
setAppointmentTypeFilter(value);
|
|
1358
|
+
setShowAppointmentTypePicker(false);
|
|
1359
|
+
fetchAppointments(value);
|
|
1360
|
+
},
|
|
1361
|
+
style: {
|
|
1362
|
+
width: "100%",
|
|
1363
|
+
padding: "10px 12px",
|
|
1364
|
+
background: appointmentTypeFilter === value ? "#E8EEF4" : "#FFFFFF",
|
|
1365
|
+
border: "none",
|
|
1366
|
+
borderRadius: "4px",
|
|
1367
|
+
fontSize: "13px",
|
|
1368
|
+
fontFamily,
|
|
1369
|
+
cursor: "pointer",
|
|
1370
|
+
textAlign: "left",
|
|
1371
|
+
fontWeight: appointmentTypeFilter === value ? 600 : 400,
|
|
1372
|
+
color: appointmentTypeFilter === value ? "#4C4DDC" : "#1a1a1a",
|
|
1373
|
+
marginBottom: "4px",
|
|
1374
|
+
display: "flex",
|
|
1375
|
+
justifyContent: "space-between",
|
|
1376
|
+
alignItems: "center",
|
|
1377
|
+
transition: "all 0.2s ease"
|
|
1378
|
+
},
|
|
1379
|
+
onMouseEnter: e => {
|
|
1380
|
+
if (appointmentTypeFilter !== value) e.target.style.background = "#F5F5F5";
|
|
1381
|
+
},
|
|
1382
|
+
onMouseLeave: e => {
|
|
1383
|
+
if (appointmentTypeFilter !== value) e.target.style.background = "#FFFFFF";
|
|
1384
|
+
}
|
|
1385
|
+
}, /*#__PURE__*/React__default["default"].createElement("span", null, label), appointmentTypeFilter === value && /*#__PURE__*/React__default["default"].createElement("span", {
|
|
1386
|
+
style: {
|
|
1387
|
+
color: "#4C4DDC",
|
|
1388
|
+
fontSize: "16px"
|
|
1389
|
+
}
|
|
1390
|
+
}, "\u2713"));
|
|
1391
|
+
}))), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
1261
1392
|
onClick: () => {
|
|
1262
1393
|
// Initialize temp dates and option with current values when opening picker
|
|
1263
1394
|
if (!showDatePicker) {
|
|
@@ -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 r="/appointment/V1/consultant/all-appointments",l="/notification/V1/consultation/online/initiate",d="dMtEGhak",s="https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/",p=async function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"ONLINE",a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},i=(e||"").toUpperCase();"INPROGRESS"===i&&(i="IN_PROGRESS");const l=a.apiBaseUrl,s=a.hospitalId||d,p=a.doctorId,c=a.token||"",u={hospitalId:s,doctorId:p,fromDate:t,toDate:n,statuses:i,type:o},f=`${l}${r}`,m=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"})))}(f,u,"PIH-Appointment-Widget",c);return m},c=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||d,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 u="pih_appointment_idToken",f="pih_appointment_email",m="pih_appointment_appToken",x="pih_appointment_doctorId",g="pih_appointment_userName",h="pih_appointment_apiBaseUrl",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(h):null}catch{return null}})),r=n.apiBaseUrl||o||"https://afiyaapiqa.powermindinc.com",l=n.hospitalId||d,[w,S]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(u):null}catch{return null}})),[v,k]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(f):null}catch{return null}})),C=n.idToken||n.token||w,I=n.email||v;t.useEffect((()=>{try{if("undefined"==typeof localStorage)return;const e=n.idToken||n.token;if(e&&String(e).trim()){localStorage.getItem(u)!==e&&(z(null),T(null),A(null),localStorage.removeItem(m),localStorage.removeItem(x),localStorage.removeItem(g)),localStorage.setItem(u,e),S(e)}n.email&&String(n.email).trim()&&(localStorage.setItem(f,n.email),k(n.email)),n.apiBaseUrl&&String(n.apiBaseUrl).trim()&&(localStorage.setItem(h,n.apiBaseUrl.trim()),i(n.apiBaseUrl.trim()))}catch(e){}}),[n.idToken,n.token,n.email,n.apiBaseUrl]);const[D,z]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(m):null}catch{return null}})),[W,T]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(x):null}catch{return null}})),[M,A]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(g):null}catch{return null}})),[R,N]=t.useState((()=>{try{if("undefined"==typeof localStorage)return!1;const e=localStorage.getItem(m),t=localStorage.getItem(u),n=localStorage.getItem(f);return!e&&!(!t||!n)}catch{return!1}})),[P,j]=t.useState(null),[B,H]=t.useState(!1),[L,U]=t.useState(0);t.useEffect((()=>{D&&R&&N(!1)}),[D,R]),t.useEffect((()=>{D||(C&&I?(H(!1),j((e=>"Sign in required. Redirecting to home..."===e?null:e))):(j("Sign in required. Redirecting to home..."),H(!0)))}),[D,C,I]),t.useEffect((()=>{if(!B)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)}),[B,n.homeUrl]),t.useEffect((()=>{if(!R)return;const e=setTimeout((()=>{j("Request timed out. Please try again."),N(!1)}),3e4);return()=>clearTimeout(e)}),[R]);const $=n.joinCallUrl||s;D&&String($||"").replace(/\/?$/,"/");const _=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{}}}(C),O=M||_.name||_.sub||"User",Y=()=>(new Date).toISOString().split("T")[0],[V,q]=t.useState("upcoming"),[X,G]=t.useState([]),[J,K]=t.useState(null),[Q,Z]=t.useState(!1),[ee,te]=t.useState(null),[ne,oe]=t.useState(window.innerWidth<768),[ae,ie]=t.useState("today"),[re,le]=t.useState("today"),[de,se]=t.useState(!1),[pe,ce]=t.useState("asc"),[ue,fe]=t.useState(""),[me,xe]=t.useState(!1),[ge,he]=t.useState(!1),[ye,Ee]=t.useState(!1),[Fe,be]=t.useState(null),[we,Se]=t.useState(null),[ve,ke]=t.useState(!1),[Ce,Ie]=t.useState(null),[De,ze]=t.useState((()=>({x:Math.max(20,"undefined"!=typeof window?window.innerWidth-y-20:300),y:80}))),[We,Te]=t.useState({width:y,height:560}),[Me,Ae]=t.useState(!1),[Re,Ne]=t.useState({x:0,y:0}),[Pe,je]=t.useState(!1),[Be,He]=t.useState(null),[Le,Ue]=t.useState({x:0,y:0,width:0,height:0});t.useState(!1);const[$e,_e]=t.useState(1),Oe=X.filter((e=>{if(!ue.trim())return!0;const t=ue.toLowerCase(),n=(e.patientName||"").toLowerCase(),o=String(e.patientId||"").toLowerCase();return n.includes(t)||o.includes(t)})),Ye=20*($e-1),Ve=Ye+20,qe=Oe.slice(Ye,Ve),Xe=Math.ceil(Oe.length/20),Ge=Oe.length,[Je,Ke]=t.useState(Y()),[Qe,Ze]=t.useState(Y()),[et,tt]=t.useState(),[nt,ot]=t.useState(),at=e=>e?.id||e?._id||e?.appointmentId||e?.patientId||JSON.stringify(e),it=e=>e?.image?e.image:null,rt=e=>e?e.charAt(0).toUpperCase():"?",lt=e=>{if(!e)return"#4C4DDC";const t=["#4C4DDC","#1CC3CE","#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F"];return t[e.charCodeAt(0)%t.length]},dt=()=>{const e="asc"===pe?"desc":"asc";ce(e);const t=[...X].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}));G(t),_e(1),t.length>0&&K(t[0])},st=t.useCallback((async()=>{if(!D)return;console.log(W,"fetchAppointments -> doctorIdFromLogin");const e=W;Z(!0),te(null);try{const t={apiBaseUrl:r,hospitalId:l,doctorId:e,token:D},n=await p(V,Je,Qe,"PHYSICAL",t);if(401===n.status||403===n.status){try{"undefined"!=typeof localStorage&&(localStorage.removeItem(m),localStorage.removeItem(x),localStorage.removeItem(g))}catch(e){}return z(null),T(null),A(null),U((e=>e+1)),void te("Session expired. Re-authenticating...")}if(n.err)return void te(String(n.err||"Failed to fetch appointments"));const o=n.data||n.appointments||n||[];G(Array.isArray(o)?o:[]),Array.isArray(o)&&o.length>0?K(o[0]):K(null)}catch(e){console.error("Error fetching appointments:",e),te(e.message||"Failed to fetch appointments")}finally{Z(!1)}}),[V,Je,Qe,r,l,W,D]),pt=e=>{K(e)},ct=async()=>{if(J&&D){ke(!0),Ie(null);try{const e={apiBaseUrl:r,hospitalId:l,doctorId:W,doctorName:M||O,appToken:D};console.log(J,"selectedAppointment"),console.log(e,"callConfig");const t=await c(J,e);if(401===t.status||403===t.status)return Ie("Session expired. Please try again."),void ke(!1);if(t.err||!t.data?.token)return Ie(String(t.err||"Failed to initiate call")),void ke(!1);const o=n.joinCallUrl||s,a=t.data.token?String(o||"").replace(/\/?$/,"/")+t.data.token:"";console.log("joinCallUrl",a),be(t.data.token),Se(a||""),xe(!0),he(!1),Ee(!1),Te({width:y,height:560}),ze({x:Math.max(20,window.innerWidth-y-20),y:80})}catch(e){Ie(e.message||"Failed to initiate call")}finally{Ie(null),ke(!1)}}},ut=()=>{xe(!1),he(!1),Ee(!1),be(null),Se(null),Ie(null),st()},ft=()=>{ye&&Ee(!1),he(!ge)},mt=()=>{ge&&he(!1),Ee(!ye)},xt=e=>{if(0!==e.button)return;if(e.target.closest("button"))return;e.currentTarget.setPointerCapture&&e.currentTarget.setPointerCapture(e.pointerId),Ae(!0);const t=e.currentTarget.getBoundingClientRect();Ne({x:e.clientX-t.left,y:e.clientY-t.top})},gt=t.useCallback((e=>{if(!ye)if(Me){const t=e.clientX-Re.x,n=e.clientY-Re.y,o=window.innerWidth-We.width,a=window.innerHeight-We.height;ze({x:Math.max(0,Math.min(t,o)),y:Math.max(0,Math.min(n,a))})}else if(Pe){const t=e.clientX-Le.x,n=e.clientY-Le.y;let o=Le.width,a=Le.height,i=Le.posX,r=Le.posY;const l=300,d=250,s=window.innerWidth-40,p=window.innerHeight-100;if("bottom-right"===Be)o=Math.min(Math.max(Le.width+t,l),s),a=Math.min(Math.max(Le.height+n,d),p),i+o>window.innerWidth&&(o=window.innerWidth-i),r+a>window.innerHeight&&(a=window.innerHeight-r);else if("bottom-left"===Be){o=Math.min(Math.max(Le.width-t,l),s),i=Math.max(0,Le.posX+t),0===i&&(o=Le.posX+Le.width),a=Math.min(Math.max(Le.height+n,d),p),r+a>window.innerHeight&&(a=window.innerHeight-r)}else if("top-right"===Be){o=Math.min(Math.max(Le.width+t,l),s),i+o>window.innerWidth&&(o=window.innerWidth-i);a=Math.min(Math.max(Le.height-n,d),p),r=Math.max(0,Le.posY+n),0===r&&(a=Le.posY+Le.height)}else if("top-left"===Be){o=Math.min(Math.max(Le.width-t,l),s),i=Math.max(0,Le.posX+t),0===i&&(o=Le.posX+Le.width);a=Math.min(Math.max(Le.height-n,d),p),r=Math.max(0,Le.posY+n),0===r&&(a=Le.posY+Le.height)}Te({width:o,height:a}),ze({x:i,y:r})}}),[Me,Pe,Re,Be,Le,De,We,ye]),ht=()=>{Ae(!1),je(!1),He(null)},yt=(e,t)=>{t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture&&t.currentTarget.setPointerCapture(t.pointerId),je(!0),He(e),Ue({x:t.clientX,y:t.clientY,width:We.width,height:We.height,posX:De.x,posY:De.y})};t.useEffect((()=>{if(!me||ye)return;const e=()=>{if(!(window.innerWidth<768)){const e=ge?350:We.width,t=ge?60:We.height,n=window.innerWidth-40,o=window.innerHeight-100,a=Math.min(e,n),i=Math.min(t,o);a===We.width&&i===We.height||Te({width:a,height:i});const r=window.innerWidth-a-20,l=window.innerHeight-i-20;ze((e=>({x:Math.min(e.x,r),y:Math.min(e.y,l)})))}};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[me,ge,ye,We]),t.useEffect((()=>{if(!(C&&I&&(!D||L>0)))return;let e=!1;return N(!0),j(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"})))})(r,l,C,I).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 j(t.err||"Invalid request. Redirecting to home..."),N(!1),void H(!0);if(t.err||!n){j(String(t.err||"Failed to get token")),z(null),T(null),A(null);try{"undefined"!=typeof localStorage&&(localStorage.removeItem(m),localStorage.removeItem(x),localStorage.removeItem(g))}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);z(n),T(e),A(o),j(null),H(!1);try{"undefined"!=typeof localStorage&&(localStorage.setItem(m,n),e&&localStorage.setItem(x,e),o&&localStorage.setItem(g,o))}catch(e){}}})).catch((()=>{})).finally((()=>{e||N(!1)})),()=>{e=!0}}),[r,l,C,I,L]),t.useEffect((()=>{_e(1)}),[V,ae,Je,Qe,ue]),t.useEffect((()=>{!R&&D&&st()}),[st,D,R]),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=()=>{oe(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=>{!de||e.target.closest("button")||e.target.closest('input[type="date"]')||se(!1)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}}),[de]);let Et='"Nunito", serif';const Ft=P||!D&&(!C||!I),bt=P||"Sign in required. Redirecting to home...";let wt;return wt=R&&C&&I?a.default.createElement("div",{className:E,[F]:"teleconsult-appointments",style:{fontFamily:Et,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:Et,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:ne?"10px 12px":"12px 24px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #E5E5E5",flexWrap:"nowrap",gap:ne?"8px":"0"}},a.default.createElement("div",{style:{position:"relative",width:ne?"calc(100% - 90px)":"480px",maxWidth:ne?"none":"480px"}},a.default.createElement("input",{type:"text",placeholder:"Search by patient name or ID",value:ue,onChange:e=>fe(e.target.value),style:{width:"100%",padding:ne?"8px 32px 8px 10px":"8px 36px 8px 14px",border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:ne?"12px":"13px",fontFamily:Et,background:"#FFFFFF",outline:"none",boxSizing:"border-box"}}),ue&&a.default.createElement("button",{onClick:()=>fe(""),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:ne?"12px":"16px 24px",flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"}},a.default.createElement("div",{style:{marginBottom:ne?"10px":"14px"}},a.default.createElement("h1",{style:{fontSize:ne?"18px":"22px",fontWeight:700,color:"#1a1a1a",margin:"0 0 2px 0"}},"Tele Consultation"),a.default.createElement("p",{style:{fontSize:ne?"11px":"12px",color:"#999",margin:0}},"Displaying All Tele Consultation Appointments")),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:ne?"flex-start":"center",marginBottom:ne?"10px":"14px",flexDirection:ne?"column":"row",gap:ne?"12px":"0"}},a.default.createElement("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",width:ne?"100%":"auto"}},a.default.createElement("button",{onClick:()=>q("upcoming"),style:{background:"upcoming"===V?"#4C4DDC":"#FFFFFF",padding:ne?"8px 10px":"9px 16px",border:"upcoming"===V?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:ne?"10px":"13px",color:"upcoming"===V?"white":"#555555",fontWeight:600,fontFamily:Et,cursor:"pointer",flex:ne?"1 1 auto":"none",minWidth:ne?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Upcoming Appointments"),a.default.createElement("button",{onClick:()=>q("completed"),style:{background:"completed"===V?"#4C4DDC":"#FFFFFF",padding:ne?"8px 10px":"9px 16px",border:"completed"===V?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:ne?"10px":"13px",color:"completed"===V?"white":"#555555",fontWeight:600,fontFamily:Et,cursor:"pointer",flex:ne?"1 1 auto":"none",minWidth:ne?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Completed Appointments"),a.default.createElement("button",{onClick:()=>q("cancelled"),style:{background:"cancelled"===V?"#4C4DDC":"#FFFFFF",padding:ne?"8px 10px":"9px 16px",border:"cancelled"===V?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:ne?"10px":"13px",color:"cancelled"===V?"white":"#555555",fontWeight:600,fontFamily:Et,cursor:"pointer",flex:ne?"1 1 auto":"none",minWidth:ne?"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:ne?"flex-start":"flex-end"}},a.default.createElement("button",{onClick:()=>{de||(tt(Je),ot(Qe),le(ae)),se(!de)},style:{padding:"8px 12px",fontFamily:Et,fontWeight:600,border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:ne?"11px":"13px",color:"#1a1a1a",background:"#FFFFFF",display:"flex",alignItems:"center",gap:ne?"4px":"6px",cursor:"pointer",flex:"none",minWidth:ne?"100px":"auto",justifyContent:"center"}},a.default.createElement("svg",{width:ne?"12":"14",height:ne?"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(ae){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 ne?"Custom":`${Je} to ${Qe}`}})()),a.default.createElement("svg",{width:ne?"8":"10",height:ne?"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"}))),de&&a.default.createElement("div",{style:{position:"absolute",top:"100%",right:ne?"auto":0,left:ne?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:ne?"280px":"240px",width:ne?"calc(100vw - 24px)":"auto",maxWidth:ne?"calc(100vw - 24px)":"280px"}},a.default.createElement("div",{style:{marginBottom:"custom"===re?"12px":"0"}},["thisMonth","today","tomorrow","currentWeek","currentYear","custom"].map((e=>a.default.createElement("button",{key:e,onClick:()=>{if(le(e),"custom"!==e){const t=(e=>{const t=new Date;let n,o;switch(e){case"today":default:n=o=Y();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);ie(e),Ke(t.from),Ze(t.to),tt(t.from),ot(t.to),se(!1)}else tt(""),ot("")},style:{width:"100%",padding:"10px 12px",background:re===e?"#E8EEF4":"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:Et,cursor:"pointer",textAlign:"left",fontWeight:re===e?600:400,color:re===e?"#4C4DDC":"#1a1a1a",marginBottom:"4px",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.2s ease"},onMouseEnter:t=>{re!==e&&(t.target.style.background="#F5F5F5")},onMouseLeave:t=>{re!==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]),re===e&&a.default.createElement("span",{style:{color:"#4C4DDC",fontSize:"16px"}},"✓"))))),"custom"===re&&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:et,onChange:e=>tt(e.target.value),placeholder:"Start Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:Et,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{marginBottom:"12px"}},a.default.createElement("input",{type:"date",value:nt,onChange:e=>ot(e.target.value),placeholder:"End Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:Et,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{display:"flex",gap:"8px"}},a.default.createElement("button",{onClick:()=>{le(ae),tt(Je),ot(Qe),se(!1)},style:{flex:1,padding:"10px 12px",background:"#FFFFFF",color:"#4C4DDC",border:"1px solid #4C4DDC",borderRadius:"4px",fontSize:"13px",fontFamily:Et,fontWeight:600,cursor:"pointer"}},"Cancel"),a.default.createElement("button",{onClick:()=>{et&&nt&&(ie("custom"),Ke(et),Ze(nt),se(!1))},style:{flex:1,padding:"10px 12px",background:"#4C4DDC",color:"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:Et,fontWeight:600,cursor:"pointer"}},"Submit")))))),a.default.createElement("div",{style:{display:"flex",flexDirection:ne?"column":"row",gap:ne?"12px":"14px",flex:1,minHeight:0,overflow:ne?"auto":"hidden"}},a.default.createElement("div",{style:{flex:ne?"none":"1 1 65%",width:ne?"100%":"auto",display:"flex",flexDirection:"column",minHeight:ne?"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:ne?"none":1,minHeight:ne?"auto":0}},a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:ne?"12px 14px":"14px 18px",borderBottom:"1px solid #F1F1F1"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:ne?"6px":"8px"}},a.default.createElement("span",{style:{fontSize:ne?"14px":"15px",fontWeight:700,color:"#1a1a1a"}},"Appointments"),a.default.createElement("span",{style:{background:"#4C4DDC",color:"#fff",fontSize:ne?"10px":"11px",fontWeight:600,padding:ne?"2px 7px":"3px 8px",borderRadius:"12px"}},Ge))),a.default.createElement("div",{className:"appointments-header-grid",style:{display:"grid",gridTemplateColumns:ne?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:ne?"8px":"12px",padding:ne?"8px 12px":"10px 18px",background:"#F5F5F5",fontSize:ne?"10px":"12px",fontWeight:600,color:"#666"}},a.default.createElement("div",null,"Patients name"),!ne&&a.default.createElement("div",null,"Patient ID"),a.default.createElement("div",{onClick:dt,style:{display:"flex",alignItems:"center",gap:"3px",cursor:"pointer",userSelect:"none"}},"Date",a.default.createElement("span",{style:{opacity:.7,fontSize:"10px"}},"asc"===pe?"▲":"▼")),!ne&&a.default.createElement("div",null,"Slot"),!ne&&a.default.createElement("div",null,"Doctor")),a.default.createElement("div",{style:{overflow:"auto",flex:1}},R?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...")):Q?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...")):ee?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"}},ee),a.default.createElement("button",{onClick:st,style:{marginTop:"16px",padding:"8px 16px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontFamily:Et}},"Retry")):0===qe.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"}},ue?`No appointments found for "${ue}"`:"No appointments found"),ue&&a.default.createElement("button",{onClick:()=>fe(""),style:{marginTop:"12px",padding:"6px 12px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px",fontFamily:Et}},"Clear Search")):qe.map((e=>a.default.createElement("div",{key:at(e),role:"button",tabIndex:0,onClick:()=>pt(e),onKeyDown:t=>"Enter"===t.key&&pt(e),className:"appointments-grid",style:{display:"grid",gridTemplateColumns:ne?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:ne?"8px":"12px",padding:ne?"10px 12px":"12px 18px",background:at(J)===at(e)?"#E8EEF4":"#FFFFFF",borderTop:"1px solid #F1F1F1",alignItems:"center",cursor:"pointer",fontSize:ne?"11px":"13px"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:ne?"8px":"10px"}},it(e)?a.default.createElement("img",{src:e.image,alt:"",style:{width:ne?"32px":"36px",height:ne?"32px":"36px",borderRadius:"50%",objectFit:"cover"}}):a.default.createElement("div",{style:{width:ne?"32px":"36px",height:ne?"32px":"36px",borderRadius:"50%",background:lt(e.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:600,fontSize:ne?"14px":"16px"}},rt(e.patientName)),a.default.createElement("div",null,a.default.createElement("div",{style:{fontWeight:600,color:"#1a1a1a",fontSize:ne?"11px":"13px"}},e.patientName),a.default.createElement("div",{style:{fontSize:ne?"9px":"11px",color:"#888"}},e.email))),!ne&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.patientId),a.default.createElement("div",{style:{color:"#555",fontSize:ne?"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:ne?"9px":"11px",color:"#888"}},n[1].trim())):a.default.createElement("div",null,t)})()),!ne&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.appointmentTime||"-"),!ne&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.doctorName||e.doctor||"-"))))),!Q&&!ee&&qe.length>0&&a.default.createElement("div",{style:{padding:ne?"12px 14px":"14px 18px",borderTop:"1px solid #F1F1F1",display:"flex",justifyContent:"space-between",alignItems:"center",background:"#FFFFFF",flexWrap:ne?"wrap":"nowrap",gap:ne?"10px":"0"}},a.default.createElement("div",{style:{fontSize:ne?"11px":"12px",color:"#666"}},"Showing page ",$e," of ",Xe," (",Ge," total)"),a.default.createElement("div",{style:{display:"flex",gap:"6px",alignItems:"center"}},a.default.createElement("button",{onClick:()=>_e((e=>Math.max(1,e-1))),disabled:1===$e,style:{padding:ne?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:1===$e?"#F5F5F5":"#FFFFFF",color:1===$e?"#999":"#1a1a1a",fontSize:ne?"11px":"12px",fontFamily:Et,fontWeight:600,cursor:1===$e?"not-allowed":"pointer",opacity:1===$e?.5:1}},"Previous"),a.default.createElement("div",{style:{display:"flex",gap:"4px"}},[...Array(Math.min(5,Xe))].map(((e,t)=>{let n;return n=Xe<=5||$e<=3?t+1:$e>=Xe-2?Xe-4+t:$e-2+t,a.default.createElement("button",{key:n,onClick:()=>_e(n),style:{padding:ne?"6px 10px":"6px 12px",border:$e===n?"none":"1px solid #E5E5E5",borderRadius:"4px",background:$e===n?"#4C4DDC":"#FFFFFF",color:$e===n?"#FFFFFF":"#1a1a1a",fontSize:ne?"11px":"12px",fontFamily:Et,fontWeight:600,cursor:"pointer",minWidth:ne?"32px":"36px"}},n)}))),a.default.createElement("button",{onClick:()=>_e((e=>Math.min(Xe,e+1))),disabled:$e===Xe,style:{padding:ne?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:$e===Xe?"#F5F5F5":"#FFFFFF",color:$e===Xe?"#999":"#1a1a1a",fontSize:ne?"11px":"12px",fontFamily:Et,fontWeight:600,cursor:$e===Xe?"not-allowed":"pointer",opacity:$e===Xe?.5:1}},"Next"))))),a.default.createElement("div",{style:{flex:ne?"none":"1 1 35%",width:ne?"100%":"auto",display:J||!ne?"flex":"none",flexDirection:"column",minHeight:ne?"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:ne?"none":1,minHeight:ne?"auto":0}},J?a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:ne?"12px 14px":"16px 18px",background:"#E8EEF4",borderBottom:"1px solid #E5E5E5"}},a.default.createElement("div",null,a.default.createElement("div",{style:{color:"#002668",fontSize:ne?"14px":"16px",fontWeight:"700"}},J.patientName||"N/A"),a.default.createElement("div",{style:{color:"#002668",fontSize:ne?"11px":"13px"}},J.patientId||J.mrn||"N/A")),a.default.createElement("div",null,it(J)?a.default.createElement("img",{style:{width:ne?"36px":"44px",height:ne?"36px":"44px",borderRadius:"50%",objectFit:"cover"},src:J.image,alt:J.patientName}):a.default.createElement("div",{style:{width:ne?"36px":"44px",height:ne?"36px":"44px",borderRadius:"50%",background:lt(J.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:700,fontSize:ne?"16px":"20px"}},rt(J.patientName)))),a.default.createElement("div",{style:{padding:ne?"12px 14px":"14px 18px",gap:ne?"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:ne?"10px":"11px",color:"#888",marginBottom:"3px"}},"Speciality"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ne?"12px":"13px"}},J?.specialisation||J?.speciality||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:ne?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Type"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ne?"12px":"13px"}},J?.type||J?.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:ne?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Date"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ne?"12px":"13px"}},J?.date||J?.appointmentDate||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:ne?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Time"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ne?"12px":"13px"}},J?.time||J?.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:ne?"10px":"11px",color:"#888",marginBottom:"3px"}},"Doctor"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ne?"12px":"13px"}},J?.doctor||J?.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:ne?"10px":"11px",color:"#888",marginBottom:"3px"}},"Hospital"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ne?"12px":"13px"}},J?.hospital||J?.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:ne?"10px":"11px",color:"#888",marginBottom:"3px"}},"Reason for Appointment"),a.default.createElement("div",{style:{fontWeight:"600",fontSize:ne?"11px":"12px",lineHeight:"1.4"}},J?.reason||J?.reasonForAppointment||"No reason provided"))),"upcoming"===V&&a.default.createElement("div",{style:{display:"flex",flexDirection:ne?"column":"row",gap:"6px",marginTop:"10px"}},a.default.createElement("button",{type:"button",onClick:ct,disabled:ve,style:{flex:1,background:ve?"#99e4e8":"#1CC3CE",color:"#FFFFFF",border:"1px solid #1CC3CE",borderRadius:"6px",padding:ne?"10px 8px":"8px 6px",fontFamily:Et,fontWeight:600,fontSize:ne?"11px":"12px",cursor:ve?"not-allowed":"pointer"}},ve?"Connecting...":"Join Call >")),"upcoming"===V&&Ce&&a.default.createElement("div",{style:{fontSize:"11px",color:"#e53935",marginTop:"6px",textAlign:"center",width:"100%"}},"⚠️ ",Ce))):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"))))))),me&&a.default.createElement("div",{style:{position:"fixed",left:ye?"0":ne?"10px":`${De.x}px`,top:ye?"0":ne?"70px":`${De.y}px`,right:ye?"0":ne?"10px":"auto",bottom:ye?"0":"auto",width:ye?"100vw":ne?"calc(100vw - 20px)":ge?"350px":`${We.width}px`,height:ye?"100vh":ge?"auto":ne?"300px":`${We.height}px`,background:"#FFFFFF",borderRadius:ye?"0":"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",zIndex:1e4,overflow:"hidden",display:"flex",flexDirection:"column",transition:Me||Pe?"none":"all 0.3s ease"}},a.default.createElement("div",{onPointerDown:ne||ye?void 0:xt,onPointerMove:ne||ye?void 0:gt,onPointerUp:ne||ye?void 0:ht,onPointerCancel:ne||ye?void 0:ht,style:{background:"linear-gradient(135deg, #4C4DDC 0%, #3A3BBD 100%)",color:"#FFFFFF",padding:ne?"8px 10px":"10px 12px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:ne||ye?"default":"move",userSelect:"none"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:ne?"6px":"8px",flex:1,minWidth:0}},a.default.createElement("div",{style:{width:ne?"6px":"8px",height:ne?"6px":"8px",borderRadius:"50%",background:"#FF4444",animation:"pulse 2s infinite",flexShrink:0}}),a.default.createElement("span",{style:{fontSize:ne?"11px":"13px",fontWeight:600,fontFamily:Et,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},"Video Call - ",J?.patientName||"Patient")),a.default.createElement("div",{style:{display:"flex",gap:ne?"4px":"6px",alignItems:"center",flexShrink:0}},!ye&&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:ne?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:ne?"28px":"32px",height:ne?"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:ge?"Restore":"Minimize"},ge?a.default.createElement("svg",{width:ne?"14":"16",height:ne?"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:ne?"14":"16",height:ne?"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:mt,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:ne?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:ne?"28px":"32px",height:ne?"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:ye?"Exit Fullscreen":"Fullscreen"},ye?a.default.createElement("svg",{width:ne?"14":"16",height:ne?"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:ne?"14":"16",height:ne?"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:ut,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:ne?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:ne?"28px":"32px",height:ne?"28px":"32px",fontWeight:"bold",fontSize:ne?"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"},"×"))),!ge&&a.default.createElement("div",{style:{flex:1,background:"#000000",position:"relative"}},a.default.createElement("iframe",{src:(()=>{if(!Fe)return"";const e=String($||"").replace(/\/?$/,"/");return console.log("${base}token=${callToken}",`${e}token=${Fe}`),`${e}token=${Fe}`})(),style:{width:"100%",height:"100%",border:"none"},allow:"camera; microphone; display-capture; autoplay",allowFullScreen:!0,title:"Video Call"})),!ne&&!ye&&!ge&&a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{onPointerDown:e=>yt("top-left",e),onPointerMove:gt,onPointerUp:ht,onPointerCancel:ht,style:{position:"absolute",left:0,top:0,width:"16px",height:"16px",cursor:"nwse-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onPointerDown:e=>yt("top-right",e),onPointerMove:gt,onPointerUp:ht,onPointerCancel:ht,style:{position:"absolute",right:0,top:0,width:"16px",height:"16px",cursor:"nesw-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onPointerDown:e=>yt("bottom-left",e),onPointerMove:gt,onPointerUp:ht,onPointerCancel:ht,style:{position:"absolute",left:0,bottom:0,width:"16px",height:"16px",cursor:"nesw-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onPointerDown:e=>yt("bottom-right",e),onPointerMove:gt,onPointerUp:ht,onPointerCancel:ht,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 "))),Ft&&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:Et,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"}},P?"Not authorised":"Sign in required"),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0,lineHeight:1.5}},bt),a.default.createElement("p",{style:{fontSize:"13px",color:"#999",marginTop:"16px",marginBottom:0}},"Redirecting to login...")))),a.default.createElement(b,null,wt)};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 l="/appointment/V1/consultant/all-appointments",r="/notification/V1/consultation/online/initiate",d="dMtEGhak",p="https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/",s=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,p=a.hospitalId||d,s=a.doctorId,c=a.token||"",u={hospitalId:p,doctorId:s,fromDate:t,toDate:n,statuses:i};o&&"ALL"!==String(o).toUpperCase()&&(u.appointmentType=String(o).toUpperCase());const f=`${r}${l}`,m=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"})))}(f,u,"PIH-Appointment-Widget",c);return m},c=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||d,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 u="pih_appointment_idToken",f="pih_appointment_email",m="pih_appointment_appToken",x="pih_appointment_doctorId",g="pih_appointment_userName",h="pih_appointment_apiBaseUrl",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(h):null}catch{return null}})),l=n.apiBaseUrl||o||"https://afiyaapiqa.powermindinc.com",r=n.hospitalId||d,[w,S]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(u):null}catch{return null}})),[v,k]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(f):null}catch{return null}})),C=n.idToken||n.token||w,I=n.email||v;t.useEffect((()=>{try{if("undefined"==typeof localStorage)return;const e=n.idToken||n.token;if(e&&String(e).trim()){localStorage.getItem(u)!==e&&(z(null),M(null),A(null),localStorage.removeItem(m),localStorage.removeItem(x),localStorage.removeItem(g)),localStorage.setItem(u,e),S(e)}n.email&&String(n.email).trim()&&(localStorage.setItem(f,n.email),k(n.email)),n.apiBaseUrl&&String(n.apiBaseUrl).trim()&&(localStorage.setItem(h,n.apiBaseUrl.trim()),i(n.apiBaseUrl.trim()))}catch(e){}}),[n.idToken,n.token,n.email,n.apiBaseUrl]);const[D,z]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(m):null}catch{return null}})),[W,M]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(x):null}catch{return null}})),[T,A]=t.useState((()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(g):null}catch{return null}})),[R,N]=t.useState((()=>{try{if("undefined"==typeof localStorage)return!1;const e=localStorage.getItem(m),t=localStorage.getItem(u),n=localStorage.getItem(f);return!e&&!(!t||!n)}catch{return!1}})),[P,j]=t.useState(null),[B,L]=t.useState(!1),[H,U]=t.useState(0);t.useEffect((()=>{D&&R&&N(!1)}),[D,R]),t.useEffect((()=>{D||(C&&I?(L(!1),j((e=>"Sign in required. Redirecting to home..."===e?null:e))):(j("Sign in required. Redirecting to home..."),L(!0)))}),[D,C,I]),t.useEffect((()=>{if(!B)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)}),[B,n.homeUrl]),t.useEffect((()=>{if(!R)return;const e=setTimeout((()=>{j("Request timed out. Please try again."),N(!1)}),3e4);return()=>clearTimeout(e)}),[R]);const O=n.joinCallUrl||p;D&&String(O||"").replace(/\/?$/,"/");const $=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{}}}(C),_=T||$.name||$.sub||"User",Y=()=>(new Date).toISOString().split("T")[0],[V,q]=t.useState("upcoming"),[X,G]=t.useState([]),[J,K]=t.useState(null),[Q,Z]=t.useState(!1),[ee,te]=t.useState(null),[ne,oe]=t.useState(window.innerWidth<768),[ae,ie]=t.useState("today"),[le,re]=t.useState("today"),[de,pe]=t.useState(!1),[se,ce]=t.useState(!1),[ue,fe]=t.useState("all"),[me,xe]=t.useState("asc"),[ge,he]=t.useState(""),[ye,Ee]=t.useState(!1),[Fe,be]=t.useState(!1),[we,Se]=t.useState(!1),[ve,ke]=t.useState(null),[Ce,Ie]=t.useState(null),[De,ze]=t.useState(!1),[We,Me]=t.useState(null),[Te,Ae]=t.useState((()=>({x:Math.max(20,"undefined"!=typeof window?window.innerWidth-y-20:300),y:80}))),[Re,Ne]=t.useState({width:y,height:560}),[Pe,je]=t.useState(!1),[Be,Le]=t.useState({x:0,y:0}),[He,Ue]=t.useState(!1),[Oe,$e]=t.useState(null),[_e,Ye]=t.useState({x:0,y:0,width:0,height:0});t.useState(!1);const[Ve,qe]=t.useState(1),Xe=X.filter((e=>{if(!ge.trim())return!0;const t=ge.toLowerCase(),n=(e.patientName||"").toLowerCase(),o=String(e.patientId||"").toLowerCase();return n.includes(t)||o.includes(t)})),Ge=20*(Ve-1),Je=Ge+20,Ke=Xe.slice(Ge,Je),Qe=Math.ceil(Xe.length/20),Ze=Xe.length,[et,tt]=t.useState(Y()),[nt,ot]=t.useState(Y()),[at,it]=t.useState(),[lt,rt]=t.useState(),dt=e=>e?.id||e?._id||e?.appointmentId||e?.patientId||JSON.stringify(e),pt=e=>e?.image?e.image:null,st=e=>e?e.charAt(0).toUpperCase():"?",ct=e=>{if(!e)return"#4C4DDC";const t=["#4C4DDC","#1CC3CE","#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F"];return t[e.charCodeAt(0)%t.length]},ut=()=>{const e="asc"===me?"desc":"asc";xe(e);const t=[...X].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}));G(t),qe(1),t.length>0&&K(t[0])},ft=t.useCallback((async e=>{if(!D)return;console.log(W,"fetchAppointments -> doctorIdFromLogin");const t=W,n=void 0!==e?e:ue;Z(!0),te(null);try{const e={apiBaseUrl:l,hospitalId:r,doctorId:t,token:D},o=await s(V,et,nt,n,e);if(401===o.status||403===o.status){try{"undefined"!=typeof localStorage&&(localStorage.removeItem(m),localStorage.removeItem(x),localStorage.removeItem(g))}catch(e){}return z(null),M(null),A(null),U((e=>e+1)),void te("Session expired. Re-authenticating...")}if(o.err)return void te(String(o.err||"Failed to fetch appointments"));const a=o.data||o.appointments||o||[];G(Array.isArray(a)?a:[]),Array.isArray(a)&&a.length>0?K(a[0]):K(null)}catch(e){console.error("Error fetching appointments:",e),te(e.message||"Failed to fetch appointments")}finally{Z(!1)}}),[V,et,nt,ue,l,r,W,D]),mt=e=>{K(e)},xt=async()=>{if(J&&D){ze(!0),Me(null);try{const e={apiBaseUrl:l,hospitalId:r,doctorId:W,doctorName:T||_,appToken:D};console.log(J,"selectedAppointment"),console.log(e,"callConfig");const t=await c(J,e);if(401===t.status||403===t.status)return Me("Session expired. Please try again."),void ze(!1);if(t.err||!t.data?.token)return Me(String(t.err||"Failed to initiate call")),void ze(!1);const o=n.joinCallUrl||p,a=t.data.token?String(o||"").replace(/\/?$/,"/")+t.data.token:"";console.log("joinCallUrl",a),ke(t.data.token),Ie(a||""),Ee(!0),be(!1),Se(!1),Ne({width:y,height:560}),Ae({x:Math.max(20,window.innerWidth-y-20),y:80})}catch(e){Me(e.message||"Failed to initiate call")}finally{Me(null),ze(!1)}}},gt=()=>{Ee(!1),be(!1),Se(!1),ke(null),Ie(null),Me(null),ft()},ht=()=>{we&&Se(!1),be(!Fe)},yt=()=>{Fe&&be(!1),Se(!we)},Et=e=>{if(0!==e.button)return;if(e.target.closest("button"))return;e.currentTarget.setPointerCapture&&e.currentTarget.setPointerCapture(e.pointerId),je(!0);const t=e.currentTarget.getBoundingClientRect();Le({x:e.clientX-t.left,y:e.clientY-t.top})},Ft=t.useCallback((e=>{if(!we)if(Pe){const t=e.clientX-Be.x,n=e.clientY-Be.y,o=window.innerWidth-Re.width,a=window.innerHeight-Re.height;Ae({x:Math.max(0,Math.min(t,o)),y:Math.max(0,Math.min(n,a))})}else if(He){const t=e.clientX-_e.x,n=e.clientY-_e.y;let o=_e.width,a=_e.height,i=_e.posX,l=_e.posY;const r=300,d=250,p=window.innerWidth-40,s=window.innerHeight-100;if("bottom-right"===Oe)o=Math.min(Math.max(_e.width+t,r),p),a=Math.min(Math.max(_e.height+n,d),s),i+o>window.innerWidth&&(o=window.innerWidth-i),l+a>window.innerHeight&&(a=window.innerHeight-l);else if("bottom-left"===Oe){o=Math.min(Math.max(_e.width-t,r),p),i=Math.max(0,_e.posX+t),0===i&&(o=_e.posX+_e.width),a=Math.min(Math.max(_e.height+n,d),s),l+a>window.innerHeight&&(a=window.innerHeight-l)}else if("top-right"===Oe){o=Math.min(Math.max(_e.width+t,r),p),i+o>window.innerWidth&&(o=window.innerWidth-i);a=Math.min(Math.max(_e.height-n,d),s),l=Math.max(0,_e.posY+n),0===l&&(a=_e.posY+_e.height)}else if("top-left"===Oe){o=Math.min(Math.max(_e.width-t,r),p),i=Math.max(0,_e.posX+t),0===i&&(o=_e.posX+_e.width);a=Math.min(Math.max(_e.height-n,d),s),l=Math.max(0,_e.posY+n),0===l&&(a=_e.posY+_e.height)}Ne({width:o,height:a}),Ae({x:i,y:l})}}),[Pe,He,Be,Oe,_e,Te,Re,we]),bt=()=>{je(!1),Ue(!1),$e(null)},wt=(e,t)=>{t.preventDefault(),t.stopPropagation(),t.currentTarget.setPointerCapture&&t.currentTarget.setPointerCapture(t.pointerId),Ue(!0),$e(e),Ye({x:t.clientX,y:t.clientY,width:Re.width,height:Re.height,posX:Te.x,posY:Te.y})};t.useEffect((()=>{if(!ye||we)return;const e=()=>{if(!(window.innerWidth<768)){const e=Fe?350:Re.width,t=Fe?60:Re.height,n=window.innerWidth-40,o=window.innerHeight-100,a=Math.min(e,n),i=Math.min(t,o);a===Re.width&&i===Re.height||Ne({width:a,height:i});const l=window.innerWidth-a-20,r=window.innerHeight-i-20;Ae((e=>({x:Math.min(e.x,l),y:Math.min(e.y,r)})))}};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[ye,Fe,we,Re]),t.useEffect((()=>{if(!(C&&I&&(!D||H>0)))return;let e=!1;return N(!0),j(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"})))})(l,r,C,I).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 j(t.err||"Invalid request. Redirecting to home..."),N(!1),void L(!0);if(t.err||!n){j(String(t.err||"Failed to get token")),z(null),M(null),A(null);try{"undefined"!=typeof localStorage&&(localStorage.removeItem(m),localStorage.removeItem(x),localStorage.removeItem(g))}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);z(n),M(e),A(o),j(null),L(!1);try{"undefined"!=typeof localStorage&&(localStorage.setItem(m,n),e&&localStorage.setItem(x,e),o&&localStorage.setItem(g,o))}catch(e){}}})).catch((()=>{})).finally((()=>{e||N(!1)})),()=>{e=!0}}),[l,r,C,I,H]),t.useEffect((()=>{qe(1)}),[V,ae,et,nt,ge,ue]),t.useEffect((()=>{!R&&D&&ft()}),[ft,D,R]),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=()=>{oe(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=>{!de||e.target.closest("button")||e.target.closest('input[type="date"]')||pe(!1),se&&!e.target.closest("[data-appointment-type-picker]")&&ce(!1)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}}),[de,se]);let St='"Nunito", serif';const vt=P||!D&&(!C||!I),kt=P||"Sign in required. Redirecting to home...";let Ct;return Ct=R&&C&&I?a.default.createElement("div",{className:E,[F]:"teleconsult-appointments",style:{fontFamily:St,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:St,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:ne?"10px 12px":"12px 24px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #E5E5E5",flexWrap:"nowrap",gap:ne?"8px":"0"}},a.default.createElement("div",{style:{position:"relative",width:ne?"calc(100% - 90px)":"480px",maxWidth:ne?"none":"480px"}},a.default.createElement("input",{type:"text",placeholder:"Search by patient name or ID",value:ge,onChange:e=>he(e.target.value),style:{width:"100%",padding:ne?"8px 32px 8px 10px":"8px 36px 8px 14px",border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:ne?"12px":"13px",fontFamily:St,background:"#FFFFFF",outline:"none",boxSizing:"border-box"}}),ge&&a.default.createElement("button",{onClick:()=>he(""),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:ne?"12px":"16px 24px",flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"}},a.default.createElement("div",{style:{marginBottom:ne?"10px":"14px"}},a.default.createElement("h1",{style:{fontSize:ne?"18px":"22px",fontWeight:700,color:"#1a1a1a",margin:"0 0 2px 0"}},"Tele Consultation"),a.default.createElement("p",{style:{fontSize:ne?"11px":"12px",color:"#999",margin:0}},"Displaying All Tele Consultation Appointments")),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:ne?"flex-start":"center",marginBottom:ne?"10px":"14px",flexDirection:ne?"column":"row",gap:ne?"12px":"0"}},a.default.createElement("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",width:ne?"100%":"auto"}},a.default.createElement("button",{onClick:()=>q("upcoming"),style:{background:"upcoming"===V?"#4C4DDC":"#FFFFFF",padding:ne?"8px 10px":"9px 16px",border:"upcoming"===V?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:ne?"10px":"13px",color:"upcoming"===V?"white":"#555555",fontWeight:600,fontFamily:St,cursor:"pointer",flex:ne?"1 1 auto":"none",minWidth:ne?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Upcoming Appointments"),a.default.createElement("button",{onClick:()=>q("completed"),style:{background:"completed"===V?"#4C4DDC":"#FFFFFF",padding:ne?"8px 10px":"9px 16px",border:"completed"===V?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:ne?"10px":"13px",color:"completed"===V?"white":"#555555",fontWeight:600,fontFamily:St,cursor:"pointer",flex:ne?"1 1 auto":"none",minWidth:ne?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Completed Appointments"),a.default.createElement("button",{onClick:()=>q("cancelled"),style:{background:"cancelled"===V?"#4C4DDC":"#FFFFFF",padding:ne?"8px 10px":"9px 16px",border:"cancelled"===V?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:ne?"10px":"13px",color:"cancelled"===V?"white":"#555555",fontWeight:600,fontFamily:St,cursor:"pointer",flex:ne?"1 1 auto":"none",minWidth:ne?"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:ne?"flex-start":"flex-end",flexWrap:"wrap"}},a.default.createElement("div",{style:{position:"relative"},"data-appointment-type-picker":!0},a.default.createElement("button",{onClick:()=>ce(!se),style:{padding:"8px 12px",fontFamily:St,fontWeight:600,border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:ne?"11px":"13px",color:"#1a1a1a",background:"#FFFFFF",display:"flex",alignItems:"center",gap:ne?"4px":"6px",cursor:"pointer",flex:"none",minWidth:ne?"100px":"auto",justifyContent:"center"}},a.default.createElement("svg",{width:ne?"14":"16",height:ne?"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"===ue?"All Appointment":"ONLINE"===ue?"Online":"Physical"),a.default.createElement("svg",{width:ne?"8":"10",height:ne?"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:ne?"auto":0,left:ne?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:ne?"240px":"200px",width:ne?"calc(100vw - 24px)":"auto",maxWidth:ne?"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:()=>{fe(t),ce(!1),ft(t)},style:{width:"100%",padding:"10px 12px",background:ue===t?"#E8EEF4":"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:St,cursor:"pointer",textAlign:"left",fontWeight:ue===t?600:400,color:ue===t?"#4C4DDC":"#1a1a1a",marginBottom:"4px",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.2s ease"},onMouseEnter:e=>{ue!==t&&(e.target.style.background="#F5F5F5")},onMouseLeave:e=>{ue!==t&&(e.target.style.background="#FFFFFF")}},a.default.createElement("span",null,n),ue===t&&a.default.createElement("span",{style:{color:"#4C4DDC",fontSize:"16px"}},"✓"))})))),a.default.createElement("button",{onClick:()=>{de||(it(et),rt(nt),re(ae)),pe(!de)},style:{padding:"8px 12px",fontFamily:St,fontWeight:600,border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:ne?"11px":"13px",color:"#1a1a1a",background:"#FFFFFF",display:"flex",alignItems:"center",gap:ne?"4px":"6px",cursor:"pointer",flex:"none",minWidth:ne?"100px":"auto",justifyContent:"center"}},a.default.createElement("svg",{width:ne?"12":"14",height:ne?"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(ae){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 ne?"Custom":`${et} to ${nt}`}})()),a.default.createElement("svg",{width:ne?"8":"10",height:ne?"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"}))),de&&a.default.createElement("div",{style:{position:"absolute",top:"100%",right:ne?"auto":0,left:ne?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:ne?"280px":"240px",width:ne?"calc(100vw - 24px)":"auto",maxWidth:ne?"calc(100vw - 24px)":"280px"}},a.default.createElement("div",{style:{marginBottom:"custom"===le?"12px":"0"}},["thisMonth","today","tomorrow","currentWeek","currentYear","custom"].map((e=>a.default.createElement("button",{key:e,onClick:()=>{if(re(e),"custom"!==e){const t=(e=>{const t=new Date;let n,o;switch(e){case"today":default:n=o=Y();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);ie(e),tt(t.from),ot(t.to),it(t.from),rt(t.to),pe(!1)}else it(""),rt("")},style:{width:"100%",padding:"10px 12px",background:le===e?"#E8EEF4":"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:St,cursor:"pointer",textAlign:"left",fontWeight:le===e?600:400,color:le===e?"#4C4DDC":"#1a1a1a",marginBottom:"4px",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.2s ease"},onMouseEnter:t=>{le!==e&&(t.target.style.background="#F5F5F5")},onMouseLeave:t=>{le!==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]),le===e&&a.default.createElement("span",{style:{color:"#4C4DDC",fontSize:"16px"}},"✓"))))),"custom"===le&&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:at,onChange:e=>it(e.target.value),placeholder:"Start Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:St,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{marginBottom:"12px"}},a.default.createElement("input",{type:"date",value:lt,onChange:e=>rt(e.target.value),placeholder:"End Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:St,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{display:"flex",gap:"8px"}},a.default.createElement("button",{onClick:()=>{re(ae),it(et),rt(nt),pe(!1)},style:{flex:1,padding:"10px 12px",background:"#FFFFFF",color:"#4C4DDC",border:"1px solid #4C4DDC",borderRadius:"4px",fontSize:"13px",fontFamily:St,fontWeight:600,cursor:"pointer"}},"Cancel"),a.default.createElement("button",{onClick:()=>{at&<&&(ie("custom"),tt(at),ot(lt),pe(!1))},style:{flex:1,padding:"10px 12px",background:"#4C4DDC",color:"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:St,fontWeight:600,cursor:"pointer"}},"Submit")))))),a.default.createElement("div",{style:{display:"flex",flexDirection:ne?"column":"row",gap:ne?"12px":"14px",flex:1,minHeight:0,overflow:ne?"auto":"hidden"}},a.default.createElement("div",{style:{flex:ne?"none":"1 1 65%",width:ne?"100%":"auto",display:"flex",flexDirection:"column",minHeight:ne?"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:ne?"none":1,minHeight:ne?"auto":0}},a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:ne?"12px 14px":"14px 18px",borderBottom:"1px solid #F1F1F1"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:ne?"6px":"8px"}},a.default.createElement("span",{style:{fontSize:ne?"14px":"15px",fontWeight:700,color:"#1a1a1a"}},"Appointments"),a.default.createElement("span",{style:{background:"#4C4DDC",color:"#fff",fontSize:ne?"10px":"11px",fontWeight:600,padding:ne?"2px 7px":"3px 8px",borderRadius:"12px"}},Ze))),a.default.createElement("div",{className:"appointments-header-grid",style:{display:"grid",gridTemplateColumns:ne?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:ne?"8px":"12px",padding:ne?"8px 12px":"10px 18px",background:"#F5F5F5",fontSize:ne?"10px":"12px",fontWeight:600,color:"#666"}},a.default.createElement("div",null,"Patients name"),!ne&&a.default.createElement("div",null,"Patient ID"),a.default.createElement("div",{onClick:ut,style:{display:"flex",alignItems:"center",gap:"3px",cursor:"pointer",userSelect:"none"}},"Date",a.default.createElement("span",{style:{opacity:.7,fontSize:"10px"}},"asc"===me?"▲":"▼")),!ne&&a.default.createElement("div",null,"Slot"),!ne&&a.default.createElement("div",null,"Doctor")),a.default.createElement("div",{style:{overflow:"auto",flex:1}},R?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...")):Q?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...")):ee?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"}},ee),a.default.createElement("button",{onClick:ft,style:{marginTop:"16px",padding:"8px 16px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontFamily:St}},"Retry")):0===Ke.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"}},ge?`No appointments found for "${ge}"`:"No appointments found"),ge&&a.default.createElement("button",{onClick:()=>he(""),style:{marginTop:"12px",padding:"6px 12px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px",fontFamily:St}},"Clear Search")):Ke.map((e=>a.default.createElement("div",{key:dt(e),role:"button",tabIndex:0,onClick:()=>mt(e),onKeyDown:t=>"Enter"===t.key&&mt(e),className:"appointments-grid",style:{display:"grid",gridTemplateColumns:ne?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:ne?"8px":"12px",padding:ne?"10px 12px":"12px 18px",background:dt(J)===dt(e)?"#E8EEF4":"#FFFFFF",borderTop:"1px solid #F1F1F1",alignItems:"center",cursor:"pointer",fontSize:ne?"11px":"13px"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:ne?"8px":"10px"}},pt(e)?a.default.createElement("img",{src:e.image,alt:"",style:{width:ne?"32px":"36px",height:ne?"32px":"36px",borderRadius:"50%",objectFit:"cover"}}):a.default.createElement("div",{style:{width:ne?"32px":"36px",height:ne?"32px":"36px",borderRadius:"50%",background:ct(e.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:600,fontSize:ne?"14px":"16px"}},st(e.patientName)),a.default.createElement("div",null,a.default.createElement("div",{style:{fontWeight:600,color:"#1a1a1a",fontSize:ne?"11px":"13px"}},e.patientName),a.default.createElement("div",{style:{fontSize:ne?"9px":"11px",color:"#888"}},e.email))),!ne&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.patientId),a.default.createElement("div",{style:{color:"#555",fontSize:ne?"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:ne?"9px":"11px",color:"#888"}},n[1].trim())):a.default.createElement("div",null,t)})()),!ne&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.appointmentTime||"-"),!ne&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.doctorName||e.doctor||"-"))))),!Q&&!ee&&Ke.length>0&&a.default.createElement("div",{style:{padding:ne?"12px 14px":"14px 18px",borderTop:"1px solid #F1F1F1",display:"flex",justifyContent:"space-between",alignItems:"center",background:"#FFFFFF",flexWrap:ne?"wrap":"nowrap",gap:ne?"10px":"0"}},a.default.createElement("div",{style:{fontSize:ne?"11px":"12px",color:"#666"}},"Showing page ",Ve," of ",Qe," (",Ze," total)"),a.default.createElement("div",{style:{display:"flex",gap:"6px",alignItems:"center"}},a.default.createElement("button",{onClick:()=>qe((e=>Math.max(1,e-1))),disabled:1===Ve,style:{padding:ne?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:1===Ve?"#F5F5F5":"#FFFFFF",color:1===Ve?"#999":"#1a1a1a",fontSize:ne?"11px":"12px",fontFamily:St,fontWeight:600,cursor:1===Ve?"not-allowed":"pointer",opacity:1===Ve?.5:1}},"Previous"),a.default.createElement("div",{style:{display:"flex",gap:"4px"}},[...Array(Math.min(5,Qe))].map(((e,t)=>{let n;return n=Qe<=5||Ve<=3?t+1:Ve>=Qe-2?Qe-4+t:Ve-2+t,a.default.createElement("button",{key:n,onClick:()=>qe(n),style:{padding:ne?"6px 10px":"6px 12px",border:Ve===n?"none":"1px solid #E5E5E5",borderRadius:"4px",background:Ve===n?"#4C4DDC":"#FFFFFF",color:Ve===n?"#FFFFFF":"#1a1a1a",fontSize:ne?"11px":"12px",fontFamily:St,fontWeight:600,cursor:"pointer",minWidth:ne?"32px":"36px"}},n)}))),a.default.createElement("button",{onClick:()=>qe((e=>Math.min(Qe,e+1))),disabled:Ve===Qe,style:{padding:ne?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:Ve===Qe?"#F5F5F5":"#FFFFFF",color:Ve===Qe?"#999":"#1a1a1a",fontSize:ne?"11px":"12px",fontFamily:St,fontWeight:600,cursor:Ve===Qe?"not-allowed":"pointer",opacity:Ve===Qe?.5:1}},"Next"))))),a.default.createElement("div",{style:{flex:ne?"none":"1 1 35%",width:ne?"100%":"auto",display:J||!ne?"flex":"none",flexDirection:"column",minHeight:ne?"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:ne?"none":1,minHeight:ne?"auto":0}},J?a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:ne?"12px 14px":"16px 18px",background:"#E8EEF4",borderBottom:"1px solid #E5E5E5"}},a.default.createElement("div",null,a.default.createElement("div",{style:{color:"#002668",fontSize:ne?"14px":"16px",fontWeight:"700"}},J.patientName||"N/A"),a.default.createElement("div",{style:{color:"#002668",fontSize:ne?"11px":"13px"}},J.patientId||J.mrn||"N/A")),a.default.createElement("div",null,pt(J)?a.default.createElement("img",{style:{width:ne?"36px":"44px",height:ne?"36px":"44px",borderRadius:"50%",objectFit:"cover"},src:J.image,alt:J.patientName}):a.default.createElement("div",{style:{width:ne?"36px":"44px",height:ne?"36px":"44px",borderRadius:"50%",background:ct(J.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:700,fontSize:ne?"16px":"20px"}},st(J.patientName)))),a.default.createElement("div",{style:{padding:ne?"12px 14px":"14px 18px",gap:ne?"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:ne?"10px":"11px",color:"#888",marginBottom:"3px"}},"Speciality"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ne?"12px":"13px"}},J?.specialisation||J?.speciality||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:ne?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Type"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ne?"12px":"13px"}},J?.type||J?.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:ne?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Date"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ne?"12px":"13px"}},J?.date||J?.appointmentDate||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:ne?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Time"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ne?"12px":"13px"}},J?.time||J?.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:ne?"10px":"11px",color:"#888",marginBottom:"3px"}},"Doctor"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ne?"12px":"13px"}},J?.doctor||J?.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:ne?"10px":"11px",color:"#888",marginBottom:"3px"}},"Hospital"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:ne?"12px":"13px"}},J?.hospital||J?.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:ne?"10px":"11px",color:"#888",marginBottom:"3px"}},"Reason for Appointment"),a.default.createElement("div",{style:{fontWeight:"600",fontSize:ne?"11px":"12px",lineHeight:"1.4"}},J?.reason||J?.reasonForAppointment||"No reason provided"))),"upcoming"===V&&a.default.createElement("div",{style:{display:"flex",flexDirection:ne?"column":"row",gap:"6px",marginTop:"10px"}},a.default.createElement("button",{type:"button",onClick:xt,disabled:De,style:{flex:1,background:De?"#99e4e8":"#1CC3CE",color:"#FFFFFF",border:"1px solid #1CC3CE",borderRadius:"6px",padding:ne?"10px 8px":"8px 6px",fontFamily:St,fontWeight:600,fontSize:ne?"11px":"12px",cursor:De?"not-allowed":"pointer"}},De?"Connecting...":"Join Call >")),"upcoming"===V&&We&&a.default.createElement("div",{style:{fontSize:"11px",color:"#e53935",marginTop:"6px",textAlign:"center",width:"100%"}},"⚠️ ",We))):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"))))))),ye&&a.default.createElement("div",{style:{position:"fixed",left:we?"0":ne?"10px":`${Te.x}px`,top:we?"0":ne?"70px":`${Te.y}px`,right:we?"0":ne?"10px":"auto",bottom:we?"0":"auto",width:we?"100vw":ne?"calc(100vw - 20px)":Fe?"350px":`${Re.width}px`,height:we?"100vh":Fe?"auto":ne?"300px":`${Re.height}px`,background:"#FFFFFF",borderRadius:we?"0":"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",zIndex:1e4,overflow:"hidden",display:"flex",flexDirection:"column",transition:Pe||He?"none":"all 0.3s ease"}},a.default.createElement("div",{onPointerDown:ne||we?void 0:Et,onPointerMove:ne||we?void 0:Ft,onPointerUp:ne||we?void 0:bt,onPointerCancel:ne||we?void 0:bt,style:{background:"linear-gradient(135deg, #4C4DDC 0%, #3A3BBD 100%)",color:"#FFFFFF",padding:ne?"8px 10px":"10px 12px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:ne||we?"default":"move",userSelect:"none"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:ne?"6px":"8px",flex:1,minWidth:0}},a.default.createElement("div",{style:{width:ne?"6px":"8px",height:ne?"6px":"8px",borderRadius:"50%",background:"#FF4444",animation:"pulse 2s infinite",flexShrink:0}}),a.default.createElement("span",{style:{fontSize:ne?"11px":"13px",fontWeight:600,fontFamily:St,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},"Video Call - ",J?.patientName||"Patient")),a.default.createElement("div",{style:{display:"flex",gap:ne?"4px":"6px",alignItems:"center",flexShrink:0}},!we&&a.default.createElement("button",{onClick:ht,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:ne?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:ne?"28px":"32px",height:ne?"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:Fe?"Restore":"Minimize"},Fe?a.default.createElement("svg",{width:ne?"14":"16",height:ne?"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:ne?"14":"16",height:ne?"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: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:ne?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:ne?"28px":"32px",height:ne?"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?"Exit Fullscreen":"Fullscreen"},we?a.default.createElement("svg",{width:ne?"14":"16",height:ne?"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:ne?"14":"16",height:ne?"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:gt,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:ne?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:ne?"28px":"32px",height:ne?"28px":"32px",fontWeight:"bold",fontSize:ne?"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"},"×"))),!Fe&&a.default.createElement("div",{style:{flex:1,background:"#000000",position:"relative"}},a.default.createElement("iframe",{src:(()=>{if(!ve)return"";const e=String(O||"").replace(/\/?$/,"/");return console.log("${base}token=${callToken}",`${e}token=${ve}`),`${e}token=${ve}`})(),style:{width:"100%",height:"100%",border:"none"},allow:"camera; microphone; display-capture; autoplay",allowFullScreen:!0,title:"Video Call"})),!ne&&!we&&!Fe&&a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{onPointerDown:e=>wt("top-left",e),onPointerMove:Ft,onPointerUp:bt,onPointerCancel:bt,style:{position:"absolute",left:0,top:0,width:"16px",height:"16px",cursor:"nwse-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onPointerDown:e=>wt("top-right",e),onPointerMove:Ft,onPointerUp:bt,onPointerCancel:bt,style:{position:"absolute",right:0,top:0,width:"16px",height:"16px",cursor:"nesw-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onPointerDown:e=>wt("bottom-left",e),onPointerMove:Ft,onPointerUp:bt,onPointerCancel:bt,style:{position:"absolute",left:0,bottom:0,width:"16px",height:"16px",cursor:"nesw-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onPointerDown:e=>wt("bottom-right",e),onPointerMove:Ft,onPointerUp:bt,onPointerCancel:bt,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 "))),vt&&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:St,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"}},P?"Not authorised":"Sign in required"),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0,lineHeight:1.5}},kt),a.default.createElement("p",{style:{fontSize:"13px",color:"#999",marginTop:"16px",marginBottom:0}},"Redirecting to login...")))),a.default.createElement(b,null,Ct)};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})}));
|
|
@@ -14,8 +14,7 @@ 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 type = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'ONLINE';
|
|
17
|
+
const getAppointmentsByStatus = async function (status, fromDate, toDate, type) {
|
|
19
18
|
let config = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
20
19
|
// Map status to API format
|
|
21
20
|
let apiStatus = (status || "").toUpperCase();
|
|
@@ -31,9 +30,11 @@ const getAppointmentsByStatus = async function (status, fromDate, toDate) {
|
|
|
31
30
|
doctorId,
|
|
32
31
|
fromDate,
|
|
33
32
|
toDate,
|
|
34
|
-
statuses: apiStatus
|
|
35
|
-
type
|
|
33
|
+
statuses: apiStatus
|
|
36
34
|
};
|
|
35
|
+
if (type && String(type).toUpperCase() !== "ALL") {
|
|
36
|
+
params.appointmentType = String(type).toUpperCase();
|
|
37
|
+
}
|
|
37
38
|
const url = `${baseURL}${_apiConfig.API_PATHS.APPOINTMENTS}`;
|
|
38
39
|
|
|
39
40
|
// Return raw response (including status) so caller can detect 401 and re-login
|
package/package.json
CHANGED
|
@@ -305,6 +305,8 @@ const AppointmentPage = ({ config = {} }) => {
|
|
|
305
305
|
const [selectedDate, setSelectedDate] = useState("today"); // today, tomorrow, week, month, year, custom
|
|
306
306
|
const [dateOption, setDateOption] = useState("today"); // Currently selected option in dropdown
|
|
307
307
|
const [showDatePicker, setShowDatePicker] = useState(false);
|
|
308
|
+
const [showAppointmentTypePicker, setShowAppointmentTypePicker] = useState(false);
|
|
309
|
+
const [appointmentTypeFilter, setAppointmentTypeFilter] = useState("all"); // 'all' | 'ONLINE' | 'PHYSICAL'
|
|
308
310
|
const [sortOrder, setSortOrder] = useState("asc"); // asc or desc for date sorting
|
|
309
311
|
const [searchQuery, setSearchQuery] = useState(""); // Search query for filtering
|
|
310
312
|
|
|
@@ -411,10 +413,11 @@ const AppointmentPage = ({ config = {} }) => {
|
|
|
411
413
|
}
|
|
412
414
|
};
|
|
413
415
|
|
|
414
|
-
const fetchAppointments = useCallback(async () => {
|
|
416
|
+
const fetchAppointments = useCallback(async (overrideType) => {
|
|
415
417
|
if (!appToken) return;
|
|
416
418
|
console.log(doctorIdFromLogin, 'fetchAppointments -> doctorIdFromLogin')
|
|
417
419
|
const doctorId = doctorIdFromLogin;
|
|
420
|
+
const typeToUse = overrideType !== undefined ? overrideType : appointmentTypeFilter;
|
|
418
421
|
setLoading(true);
|
|
419
422
|
setError(null);
|
|
420
423
|
try {
|
|
@@ -424,7 +427,7 @@ const AppointmentPage = ({ config = {} }) => {
|
|
|
424
427
|
doctorId,
|
|
425
428
|
token: appToken,
|
|
426
429
|
};
|
|
427
|
-
const response = await getAppointmentsByStatus(activeTab, fromDate, toDate,
|
|
430
|
+
const response = await getAppointmentsByStatus(activeTab, fromDate, toDate, typeToUse, serviceConfig);
|
|
428
431
|
if (response.status === 401 || response.status === 403) {
|
|
429
432
|
// Token expired — clear stored token and trigger re-login (SSO effect will fire)
|
|
430
433
|
try {
|
|
@@ -458,7 +461,7 @@ const AppointmentPage = ({ config = {} }) => {
|
|
|
458
461
|
} finally {
|
|
459
462
|
setLoading(false);
|
|
460
463
|
}
|
|
461
|
-
}, [activeTab, fromDate, toDate, apiBaseUrl, hospitalId, doctorIdFromLogin, appToken]);
|
|
464
|
+
}, [activeTab, fromDate, toDate, appointmentTypeFilter, apiBaseUrl, hospitalId, doctorIdFromLogin, appToken]);
|
|
462
465
|
|
|
463
466
|
// Handle appointment selection - no API call, just show data from list
|
|
464
467
|
const handleAppointmentSelect = (appointment) => {
|
|
@@ -761,7 +764,7 @@ const AppointmentPage = ({ config = {} }) => {
|
|
|
761
764
|
// Reset page to 1 when filters change
|
|
762
765
|
useEffect(() => {
|
|
763
766
|
setCurrentPage(1);
|
|
764
|
-
}, [activeTab, selectedDate, fromDate, toDate, searchQuery]);
|
|
767
|
+
}, [activeTab, selectedDate, fromDate, toDate, searchQuery, appointmentTypeFilter]);
|
|
765
768
|
|
|
766
769
|
// Fetch appointments when we have appToken (tab/date change triggers refetch via fetchAppointments deps)
|
|
767
770
|
useEffect(() => {
|
|
@@ -821,19 +824,22 @@ const AppointmentPage = ({ config = {} }) => {
|
|
|
821
824
|
};
|
|
822
825
|
}, []);
|
|
823
826
|
|
|
824
|
-
// Close date picker when clicking outside
|
|
827
|
+
// Close date picker and appointment type picker when clicking outside
|
|
825
828
|
useEffect(() => {
|
|
826
829
|
const handleClickOutside = (event) => {
|
|
827
830
|
if (showDatePicker && !event.target.closest('button') && !event.target.closest('input[type="date"]')) {
|
|
828
831
|
setShowDatePicker(false);
|
|
829
832
|
}
|
|
833
|
+
if (showAppointmentTypePicker && !event.target.closest('[data-appointment-type-picker]')) {
|
|
834
|
+
setShowAppointmentTypePicker(false);
|
|
835
|
+
}
|
|
830
836
|
};
|
|
831
837
|
|
|
832
838
|
document.addEventListener("click", handleClickOutside);
|
|
833
839
|
return () => {
|
|
834
840
|
document.removeEventListener("click", handleClickOutside);
|
|
835
841
|
};
|
|
836
|
-
}, [showDatePicker]);
|
|
842
|
+
}, [showDatePicker, showAppointmentTypePicker]);
|
|
837
843
|
|
|
838
844
|
let fontFamily = '"Nunito", serif';
|
|
839
845
|
|
|
@@ -1176,8 +1182,104 @@ const AppointmentPage = ({ config = {} }) => {
|
|
|
1176
1182
|
</button>
|
|
1177
1183
|
</div>
|
|
1178
1184
|
|
|
1179
|
-
{/* Date Filter */}
|
|
1180
|
-
<div style={{ display: "flex", gap: "8px", alignItems: "center", width: isMobile ? "auto" : "auto", position: "relative", justifyContent: isMobile ? "flex-start" : "flex-end" }}>
|
|
1185
|
+
{/* Date Filter + Type of Appointment Filter */}
|
|
1186
|
+
<div style={{ display: "flex", gap: "8px", alignItems: "center", width: isMobile ? "auto" : "auto", position: "relative", justifyContent: isMobile ? "flex-start" : "flex-end", flexWrap: "wrap" }}>
|
|
1187
|
+
{/* Type of Appointment Filter */}
|
|
1188
|
+
<div style={{ position: "relative" }} data-appointment-type-picker>
|
|
1189
|
+
<button
|
|
1190
|
+
onClick={() => setShowAppointmentTypePicker(!showAppointmentTypePicker)}
|
|
1191
|
+
style={{
|
|
1192
|
+
padding: isMobile ? "8px 12px" : "8px 12px",
|
|
1193
|
+
fontFamily,
|
|
1194
|
+
fontWeight: 600,
|
|
1195
|
+
border: "1px solid #E5E5E5",
|
|
1196
|
+
borderRadius: "6px",
|
|
1197
|
+
fontSize: isMobile ? "11px" : "13px",
|
|
1198
|
+
color: "#1a1a1a",
|
|
1199
|
+
background: "#FFFFFF",
|
|
1200
|
+
display: "flex",
|
|
1201
|
+
alignItems: "center",
|
|
1202
|
+
gap: isMobile ? "4px" : "6px",
|
|
1203
|
+
cursor: "pointer",
|
|
1204
|
+
flex: "none",
|
|
1205
|
+
minWidth: isMobile ? "100px" : "auto",
|
|
1206
|
+
justifyContent: "center",
|
|
1207
|
+
}}
|
|
1208
|
+
>
|
|
1209
|
+
<svg width={isMobile ? "14" : "16"} height={isMobile ? "14" : "16"} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
1210
|
+
<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" />
|
|
1211
|
+
<path d="M8 12h8M8 16h5" />
|
|
1212
|
+
</svg>
|
|
1213
|
+
<span style={{ overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", color: "#4C4DDC" }}>
|
|
1214
|
+
{appointmentTypeFilter === "all" ? "All Appointment" : appointmentTypeFilter === "ONLINE" ? "Online" : "Physical"}
|
|
1215
|
+
</span>
|
|
1216
|
+
<svg width={isMobile ? "8" : "10"} height={isMobile ? "8" : "10"} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
1217
|
+
<polyline points="6 9 12 15 18 9" />
|
|
1218
|
+
</svg>
|
|
1219
|
+
</button>
|
|
1220
|
+
{showAppointmentTypePicker && (
|
|
1221
|
+
<div
|
|
1222
|
+
style={{
|
|
1223
|
+
position: "absolute",
|
|
1224
|
+
top: "100%",
|
|
1225
|
+
right: isMobile ? "auto" : 0,
|
|
1226
|
+
left: isMobile ? 0 : "auto",
|
|
1227
|
+
marginTop: "4px",
|
|
1228
|
+
background: "#FFFFFF",
|
|
1229
|
+
border: "1px solid #E5E5E5",
|
|
1230
|
+
borderRadius: "8px",
|
|
1231
|
+
boxShadow: "0 4px 16px rgba(0,0,0,0.15)",
|
|
1232
|
+
padding: "8px",
|
|
1233
|
+
zIndex: 1000,
|
|
1234
|
+
minWidth: isMobile ? "240px" : "200px",
|
|
1235
|
+
width: isMobile ? "calc(100vw - 24px)" : "auto",
|
|
1236
|
+
maxWidth: isMobile ? "calc(100vw - 24px)" : "240px",
|
|
1237
|
+
}}
|
|
1238
|
+
>
|
|
1239
|
+
{[
|
|
1240
|
+
{ value: "all", label: "All Appointment" },
|
|
1241
|
+
{ value: "ONLINE", label: "Online" },
|
|
1242
|
+
{ value: "PHYSICAL", label: "Physical" },
|
|
1243
|
+
].map(({ value, label }) => (
|
|
1244
|
+
<button
|
|
1245
|
+
key={value}
|
|
1246
|
+
onClick={() => {
|
|
1247
|
+
setAppointmentTypeFilter(value);
|
|
1248
|
+
setShowAppointmentTypePicker(false);
|
|
1249
|
+
fetchAppointments(value);
|
|
1250
|
+
}}
|
|
1251
|
+
style={{
|
|
1252
|
+
width: "100%",
|
|
1253
|
+
padding: "10px 12px",
|
|
1254
|
+
background: appointmentTypeFilter === value ? "#E8EEF4" : "#FFFFFF",
|
|
1255
|
+
border: "none",
|
|
1256
|
+
borderRadius: "4px",
|
|
1257
|
+
fontSize: "13px",
|
|
1258
|
+
fontFamily,
|
|
1259
|
+
cursor: "pointer",
|
|
1260
|
+
textAlign: "left",
|
|
1261
|
+
fontWeight: appointmentTypeFilter === value ? 600 : 400,
|
|
1262
|
+
color: appointmentTypeFilter === value ? "#4C4DDC" : "#1a1a1a",
|
|
1263
|
+
marginBottom: "4px",
|
|
1264
|
+
display: "flex",
|
|
1265
|
+
justifyContent: "space-between",
|
|
1266
|
+
alignItems: "center",
|
|
1267
|
+
transition: "all 0.2s ease",
|
|
1268
|
+
}}
|
|
1269
|
+
onMouseEnter={(e) => {
|
|
1270
|
+
if (appointmentTypeFilter !== value) e.target.style.background = "#F5F5F5";
|
|
1271
|
+
}}
|
|
1272
|
+
onMouseLeave={(e) => {
|
|
1273
|
+
if (appointmentTypeFilter !== value) e.target.style.background = "#FFFFFF";
|
|
1274
|
+
}}
|
|
1275
|
+
>
|
|
1276
|
+
<span>{label}</span>
|
|
1277
|
+
{appointmentTypeFilter === value && <span style={{ color: "#4C4DDC", fontSize: "16px" }}>✓</span>}
|
|
1278
|
+
</button>
|
|
1279
|
+
))}
|
|
1280
|
+
</div>
|
|
1281
|
+
)}
|
|
1282
|
+
</div>
|
|
1181
1283
|
{/* Date Filter */}
|
|
1182
1284
|
<button
|
|
1183
1285
|
onClick={() => {
|
|
@@ -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, type
|
|
16
|
+
export const getAppointmentsByStatus = async (status, fromDate, toDate, type, config = {}) => {
|
|
17
17
|
// Map status to API format
|
|
18
18
|
let apiStatus = (status || "").toUpperCase();
|
|
19
19
|
|
|
@@ -26,7 +26,10 @@ export const getAppointmentsByStatus = async (status, fromDate, toDate, type = '
|
|
|
26
26
|
const doctorId = config.doctorId;
|
|
27
27
|
const token = config.token || '';
|
|
28
28
|
|
|
29
|
-
const params = { hospitalId, doctorId, fromDate, toDate, statuses: apiStatus
|
|
29
|
+
const params = { hospitalId, doctorId, fromDate, toDate, statuses: apiStatus };
|
|
30
|
+
if (type && String(type).toUpperCase() !== "ALL") {
|
|
31
|
+
params.appointmentType = String(type).toUpperCase();
|
|
32
|
+
}
|
|
30
33
|
const url = `${baseURL}${API_PATHS.APPOINTMENTS}`;
|
|
31
34
|
|
|
32
35
|
// Return raw response (including status) so caller can detect 401 and re-login
|