pih-appointment-widget 0.0.15 → 0.0.16
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.
|
@@ -195,6 +195,7 @@ const AppointmentPage = _ref7 => {
|
|
|
195
195
|
}
|
|
196
196
|
});
|
|
197
197
|
const [tokenError, setTokenError] = (0, _react.useState)(null);
|
|
198
|
+
const [redirectToHome, setRedirectToHome] = (0, _react.useState)(false);
|
|
198
199
|
const [refreshLoginTrigger, setRefreshLoginTrigger] = (0, _react.useState)(0);
|
|
199
200
|
|
|
200
201
|
// When we have appToken (e.g. from localStorage after refresh), never show loading — show main UI
|
|
@@ -202,6 +203,29 @@ const AppointmentPage = _ref7 => {
|
|
|
202
203
|
if (appToken && tokenLoading) setTokenLoading(false);
|
|
203
204
|
}, [appToken, tokenLoading]);
|
|
204
205
|
|
|
206
|
+
// No credentials: show error and auto-redirect to home
|
|
207
|
+
(0, _react.useEffect)(() => {
|
|
208
|
+
if (appToken) return;
|
|
209
|
+
if (!idToken || !email) {
|
|
210
|
+
setTokenError("Sign in required. Redirecting to home...");
|
|
211
|
+
setRedirectToHome(true);
|
|
212
|
+
} else {
|
|
213
|
+
setRedirectToHome(false);
|
|
214
|
+
setTokenError(prev => prev === "Sign in required. Redirecting to home..." ? null : prev);
|
|
215
|
+
}
|
|
216
|
+
}, [appToken, idToken, email]);
|
|
217
|
+
|
|
218
|
+
// Auto-redirect to home when error popup is shown (no credentials or 400)
|
|
219
|
+
(0, _react.useEffect)(() => {
|
|
220
|
+
if (!redirectToHome) return;
|
|
221
|
+
const homeUrl = config.homeUrl || _apiConfig.WEB_URL || "";
|
|
222
|
+
if (!homeUrl || typeof window === "undefined") return;
|
|
223
|
+
const t = setTimeout(() => {
|
|
224
|
+
window.location.href = homeUrl;
|
|
225
|
+
}, 2500);
|
|
226
|
+
return () => clearTimeout(t);
|
|
227
|
+
}, [redirectToHome, config.homeUrl]);
|
|
228
|
+
|
|
205
229
|
// Timeout so we never show "Checking authorisation..." forever (no blank-like infinite loading)
|
|
206
230
|
(0, _react.useEffect)(() => {
|
|
207
231
|
if (!tokenLoading) return;
|
|
@@ -705,16 +729,10 @@ const AppointmentPage = _ref7 => {
|
|
|
705
729
|
if (cancelled) return;
|
|
706
730
|
const token = extractAppToken(response);
|
|
707
731
|
if (response.status === 400) {
|
|
708
|
-
// Login API returned 400 — show error
|
|
709
|
-
|
|
710
|
-
setTokenError(message);
|
|
732
|
+
// Login API returned 400 — show error popup and auto-redirect to home
|
|
733
|
+
setTokenError(response.err || "Invalid request. Redirecting to home...");
|
|
711
734
|
setTokenLoading(false);
|
|
712
|
-
|
|
713
|
-
if (homeUrl && typeof window !== "undefined") {
|
|
714
|
-
setTimeout(() => {
|
|
715
|
-
window.location.href = homeUrl;
|
|
716
|
-
}, 3000);
|
|
717
|
-
}
|
|
735
|
+
setRedirectToHome(true);
|
|
718
736
|
return;
|
|
719
737
|
}
|
|
720
738
|
if (response.err || !token) {
|
|
@@ -736,6 +754,7 @@ const AppointmentPage = _ref7 => {
|
|
|
736
754
|
setDoctorIdFromLogin(doctorId);
|
|
737
755
|
setUserName(name);
|
|
738
756
|
setTokenError(null);
|
|
757
|
+
setRedirectToHome(false);
|
|
739
758
|
try {
|
|
740
759
|
if (typeof localStorage !== "undefined") {
|
|
741
760
|
localStorage.setItem(STORAGE_KEY_APP_TOKEN, token);
|
|
@@ -801,58 +820,11 @@ const AppointmentPage = _ref7 => {
|
|
|
801
820
|
}, [showDatePicker]);
|
|
802
821
|
let fontFamily = '"Nunito", serif';
|
|
803
822
|
|
|
804
|
-
//
|
|
823
|
+
// Error as popup overlay (main page stays in background); auto-redirect to home
|
|
824
|
+
const showAuthError = tokenError || !appToken && (!idToken || !email);
|
|
825
|
+
const authErrorMessage = tokenError || "Sign in required. Redirecting to home...";
|
|
805
826
|
let content;
|
|
806
|
-
if (
|
|
807
|
-
content = /*#__PURE__*/_react.default.createElement("div", {
|
|
808
|
-
style: {
|
|
809
|
-
fontFamily,
|
|
810
|
-
background: "#F5F5F7",
|
|
811
|
-
boxSizing: "border-box",
|
|
812
|
-
height: "100vh",
|
|
813
|
-
display: "flex",
|
|
814
|
-
flexDirection: "column",
|
|
815
|
-
alignItems: "center",
|
|
816
|
-
justifyContent: "center",
|
|
817
|
-
padding: "24px",
|
|
818
|
-
textAlign: "center"
|
|
819
|
-
}
|
|
820
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
821
|
-
style: {
|
|
822
|
-
maxWidth: "400px",
|
|
823
|
-
padding: "32px 24px",
|
|
824
|
-
background: "#FFFFFF",
|
|
825
|
-
borderRadius: "12px",
|
|
826
|
-
boxShadow: "0 4px 20px rgba(0,0,0,0.08)"
|
|
827
|
-
}
|
|
828
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
829
|
-
style: {
|
|
830
|
-
fontSize: "48px",
|
|
831
|
-
marginBottom: "16px"
|
|
832
|
-
}
|
|
833
|
-
}, "\uD83D\uDD12"), /*#__PURE__*/_react.default.createElement("h2", {
|
|
834
|
-
style: {
|
|
835
|
-
fontSize: "20px",
|
|
836
|
-
fontWeight: 700,
|
|
837
|
-
color: "#1a1a1a",
|
|
838
|
-
margin: "0 0 8px 0"
|
|
839
|
-
}
|
|
840
|
-
}, "Not authorised"), /*#__PURE__*/_react.default.createElement("p", {
|
|
841
|
-
style: {
|
|
842
|
-
fontSize: "14px",
|
|
843
|
-
color: "#666",
|
|
844
|
-
margin: 0,
|
|
845
|
-
lineHeight: 1.5
|
|
846
|
-
}
|
|
847
|
-
}, tokenError), /*#__PURE__*/_react.default.createElement("p", {
|
|
848
|
-
style: {
|
|
849
|
-
fontSize: "13px",
|
|
850
|
-
color: "#999",
|
|
851
|
-
marginTop: "16px",
|
|
852
|
-
marginBottom: 0
|
|
853
|
-
}
|
|
854
|
-
}, "You are not authorised to use this service. Please sign in again or contact support.")));
|
|
855
|
-
} else if (tokenLoading && idToken && email) {
|
|
827
|
+
if (tokenLoading && idToken && email) {
|
|
856
828
|
// While checking token (SSO in progress), show a simple loading state instead of the full UI
|
|
857
829
|
content = /*#__PURE__*/_react.default.createElement("div", {
|
|
858
830
|
style: {
|
|
@@ -884,7 +856,7 @@ const AppointmentPage = _ref7 => {
|
|
|
884
856
|
}
|
|
885
857
|
}, "Checking authorisation..."));
|
|
886
858
|
} else {
|
|
887
|
-
content = /*#__PURE__*/_react.default.createElement("div", {
|
|
859
|
+
content = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
888
860
|
style: {
|
|
889
861
|
fontFamily,
|
|
890
862
|
background: "#F5F5F7",
|
|
@@ -945,7 +917,7 @@ const AppointmentPage = _ref7 => {
|
|
|
945
917
|
fontSize: "16px"
|
|
946
918
|
},
|
|
947
919
|
title: "Clear search"
|
|
948
|
-
}, "\u2715")), /*#__PURE__*/_react.default.createElement("div", {
|
|
920
|
+
}, "\u2715")), false && /*#__PURE__*/_react.default.createElement("div", {
|
|
949
921
|
style: {
|
|
950
922
|
display: "flex",
|
|
951
923
|
alignItems: "center",
|
|
@@ -2325,7 +2297,56 @@ const AppointmentPage = _ref7 => {
|
|
|
2325
2297
|
pointerEvents: "none",
|
|
2326
2298
|
zIndex: 10002
|
|
2327
2299
|
}
|
|
2328
|
-
})), /*#__PURE__*/_react.default.createElement("style", null, "\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n ")))
|
|
2300
|
+
})), /*#__PURE__*/_react.default.createElement("style", null, "\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n "))), showAuthError && /*#__PURE__*/_react.default.createElement("div", {
|
|
2301
|
+
style: {
|
|
2302
|
+
position: "fixed",
|
|
2303
|
+
inset: 0,
|
|
2304
|
+
zIndex: 100000,
|
|
2305
|
+
display: "flex",
|
|
2306
|
+
alignItems: "center",
|
|
2307
|
+
justifyContent: "center",
|
|
2308
|
+
padding: "24px",
|
|
2309
|
+
background: "rgba(0,0,0,0.4)",
|
|
2310
|
+
boxSizing: "border-box"
|
|
2311
|
+
}
|
|
2312
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
2313
|
+
style: {
|
|
2314
|
+
fontFamily,
|
|
2315
|
+
maxWidth: "400px",
|
|
2316
|
+
width: "100%",
|
|
2317
|
+
padding: "32px 24px",
|
|
2318
|
+
background: "#FFFFFF",
|
|
2319
|
+
borderRadius: "12px",
|
|
2320
|
+
boxShadow: "0 8px 32px rgba(0,0,0,0.2)",
|
|
2321
|
+
textAlign: "center"
|
|
2322
|
+
}
|
|
2323
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
2324
|
+
style: {
|
|
2325
|
+
fontSize: "48px",
|
|
2326
|
+
marginBottom: "16px"
|
|
2327
|
+
}
|
|
2328
|
+
}, "\uD83D\uDD12"), /*#__PURE__*/_react.default.createElement("h2", {
|
|
2329
|
+
style: {
|
|
2330
|
+
fontSize: "20px",
|
|
2331
|
+
fontWeight: 700,
|
|
2332
|
+
color: "#1a1a1a",
|
|
2333
|
+
margin: "0 0 8px 0"
|
|
2334
|
+
}
|
|
2335
|
+
}, tokenError ? "Not authorised" : "Sign in required"), /*#__PURE__*/_react.default.createElement("p", {
|
|
2336
|
+
style: {
|
|
2337
|
+
fontSize: "14px",
|
|
2338
|
+
color: "#666",
|
|
2339
|
+
margin: 0,
|
|
2340
|
+
lineHeight: 1.5
|
|
2341
|
+
}
|
|
2342
|
+
}, authErrorMessage), /*#__PURE__*/_react.default.createElement("p", {
|
|
2343
|
+
style: {
|
|
2344
|
+
fontSize: "13px",
|
|
2345
|
+
color: "#999",
|
|
2346
|
+
marginTop: "16px",
|
|
2347
|
+
marginBottom: 0
|
|
2348
|
+
}
|
|
2349
|
+
}, "Redirecting to login..."))));
|
|
2329
2350
|
}
|
|
2330
2351
|
return /*#__PURE__*/_react.default.createElement(AppointmentErrorBoundary, null, content);
|
|
2331
2352
|
};
|
|
@@ -423,6 +423,7 @@
|
|
|
423
423
|
}
|
|
424
424
|
});
|
|
425
425
|
const [tokenError, setTokenError] = React.useState(null);
|
|
426
|
+
const [redirectToHome, setRedirectToHome] = React.useState(false);
|
|
426
427
|
const [refreshLoginTrigger, setRefreshLoginTrigger] = React.useState(0);
|
|
427
428
|
|
|
428
429
|
// When we have appToken (e.g. from localStorage after refresh), never show loading — show main UI
|
|
@@ -430,6 +431,29 @@
|
|
|
430
431
|
if (appToken && tokenLoading) setTokenLoading(false);
|
|
431
432
|
}, [appToken, tokenLoading]);
|
|
432
433
|
|
|
434
|
+
// No credentials: show error and auto-redirect to home
|
|
435
|
+
React.useEffect(() => {
|
|
436
|
+
if (appToken) return;
|
|
437
|
+
if (!idToken || !email) {
|
|
438
|
+
setTokenError("Sign in required. Redirecting to home...");
|
|
439
|
+
setRedirectToHome(true);
|
|
440
|
+
} else {
|
|
441
|
+
setRedirectToHome(false);
|
|
442
|
+
setTokenError(prev => prev === "Sign in required. Redirecting to home..." ? null : prev);
|
|
443
|
+
}
|
|
444
|
+
}, [appToken, idToken, email]);
|
|
445
|
+
|
|
446
|
+
// Auto-redirect to home when error popup is shown (no credentials or 400)
|
|
447
|
+
React.useEffect(() => {
|
|
448
|
+
if (!redirectToHome) return;
|
|
449
|
+
const homeUrl = config.homeUrl || WEB_URL || "";
|
|
450
|
+
if (!homeUrl || typeof window === "undefined") return;
|
|
451
|
+
const t = setTimeout(() => {
|
|
452
|
+
window.location.href = homeUrl;
|
|
453
|
+
}, 2500);
|
|
454
|
+
return () => clearTimeout(t);
|
|
455
|
+
}, [redirectToHome, config.homeUrl]);
|
|
456
|
+
|
|
433
457
|
// Timeout so we never show "Checking authorisation..." forever (no blank-like infinite loading)
|
|
434
458
|
React.useEffect(() => {
|
|
435
459
|
if (!tokenLoading) return;
|
|
@@ -557,7 +581,7 @@
|
|
|
557
581
|
});
|
|
558
582
|
|
|
559
583
|
// Profile dropdown (logout)
|
|
560
|
-
|
|
584
|
+
React.useState(false);
|
|
561
585
|
|
|
562
586
|
// Pagination state (Frontend only)
|
|
563
587
|
const [currentPage, setCurrentPage] = React.useState(1);
|
|
@@ -685,24 +709,6 @@
|
|
|
685
709
|
setSelectedAppointment(appointment);
|
|
686
710
|
};
|
|
687
711
|
|
|
688
|
-
// Logout: clear storage and redirect to login page
|
|
689
|
-
const handleLogout = () => {
|
|
690
|
-
try {
|
|
691
|
-
if (typeof localStorage !== "undefined") {
|
|
692
|
-
localStorage.removeItem(STORAGE_KEY_ID_TOKEN);
|
|
693
|
-
localStorage.removeItem(STORAGE_KEY_EMAIL);
|
|
694
|
-
localStorage.removeItem(STORAGE_KEY_APP_TOKEN);
|
|
695
|
-
localStorage.removeItem(STORAGE_KEY_DOCTOR_ID);
|
|
696
|
-
localStorage.removeItem(STORAGE_KEY_USER_NAME);
|
|
697
|
-
}
|
|
698
|
-
} catch (e) {}
|
|
699
|
-
setShowProfileDropdown(false);
|
|
700
|
-
const homeUrl = config.homeUrl || WEB_URL || "";
|
|
701
|
-
if (homeUrl && typeof window !== "undefined") {
|
|
702
|
-
window.location.href = homeUrl;
|
|
703
|
-
}
|
|
704
|
-
};
|
|
705
|
-
|
|
706
712
|
// Handle join call — call initiate API to get LiveKit token+url, then open PiP
|
|
707
713
|
const handleJoinCall = async () => {
|
|
708
714
|
if (!selectedAppointment || !appToken) return;
|
|
@@ -933,16 +939,10 @@
|
|
|
933
939
|
if (cancelled) return;
|
|
934
940
|
const token = extractAppToken(response);
|
|
935
941
|
if (response.status === 400) {
|
|
936
|
-
// Login API returned 400 — show error
|
|
937
|
-
|
|
938
|
-
setTokenError(message);
|
|
942
|
+
// Login API returned 400 — show error popup and auto-redirect to home
|
|
943
|
+
setTokenError(response.err || "Invalid request. Redirecting to home...");
|
|
939
944
|
setTokenLoading(false);
|
|
940
|
-
|
|
941
|
-
if (homeUrl && typeof window !== "undefined") {
|
|
942
|
-
setTimeout(() => {
|
|
943
|
-
window.location.href = homeUrl;
|
|
944
|
-
}, 3000);
|
|
945
|
-
}
|
|
945
|
+
setRedirectToHome(true);
|
|
946
946
|
return;
|
|
947
947
|
}
|
|
948
948
|
if (response.err || !token) {
|
|
@@ -964,6 +964,7 @@
|
|
|
964
964
|
setDoctorIdFromLogin(doctorId);
|
|
965
965
|
setUserName(name);
|
|
966
966
|
setTokenError(null);
|
|
967
|
+
setRedirectToHome(false);
|
|
967
968
|
try {
|
|
968
969
|
if (typeof localStorage !== "undefined") {
|
|
969
970
|
localStorage.setItem(STORAGE_KEY_APP_TOKEN, token);
|
|
@@ -1029,58 +1030,11 @@
|
|
|
1029
1030
|
}, [showDatePicker]);
|
|
1030
1031
|
let fontFamily = '"Nunito", serif';
|
|
1031
1032
|
|
|
1032
|
-
//
|
|
1033
|
+
// Error as popup overlay (main page stays in background); auto-redirect to home
|
|
1034
|
+
const showAuthError = tokenError || !appToken && (!idToken || !email);
|
|
1035
|
+
const authErrorMessage = tokenError || "Sign in required. Redirecting to home...";
|
|
1033
1036
|
let content;
|
|
1034
|
-
if (
|
|
1035
|
-
content = /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1036
|
-
style: {
|
|
1037
|
-
fontFamily,
|
|
1038
|
-
background: "#F5F5F7",
|
|
1039
|
-
boxSizing: "border-box",
|
|
1040
|
-
height: "100vh",
|
|
1041
|
-
display: "flex",
|
|
1042
|
-
flexDirection: "column",
|
|
1043
|
-
alignItems: "center",
|
|
1044
|
-
justifyContent: "center",
|
|
1045
|
-
padding: "24px",
|
|
1046
|
-
textAlign: "center"
|
|
1047
|
-
}
|
|
1048
|
-
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1049
|
-
style: {
|
|
1050
|
-
maxWidth: "400px",
|
|
1051
|
-
padding: "32px 24px",
|
|
1052
|
-
background: "#FFFFFF",
|
|
1053
|
-
borderRadius: "12px",
|
|
1054
|
-
boxShadow: "0 4px 20px rgba(0,0,0,0.08)"
|
|
1055
|
-
}
|
|
1056
|
-
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1057
|
-
style: {
|
|
1058
|
-
fontSize: "48px",
|
|
1059
|
-
marginBottom: "16px"
|
|
1060
|
-
}
|
|
1061
|
-
}, "\uD83D\uDD12"), /*#__PURE__*/React__default["default"].createElement("h2", {
|
|
1062
|
-
style: {
|
|
1063
|
-
fontSize: "20px",
|
|
1064
|
-
fontWeight: 700,
|
|
1065
|
-
color: "#1a1a1a",
|
|
1066
|
-
margin: "0 0 8px 0"
|
|
1067
|
-
}
|
|
1068
|
-
}, "Not authorised"), /*#__PURE__*/React__default["default"].createElement("p", {
|
|
1069
|
-
style: {
|
|
1070
|
-
fontSize: "14px",
|
|
1071
|
-
color: "#666",
|
|
1072
|
-
margin: 0,
|
|
1073
|
-
lineHeight: 1.5
|
|
1074
|
-
}
|
|
1075
|
-
}, tokenError), /*#__PURE__*/React__default["default"].createElement("p", {
|
|
1076
|
-
style: {
|
|
1077
|
-
fontSize: "13px",
|
|
1078
|
-
color: "#999",
|
|
1079
|
-
marginTop: "16px",
|
|
1080
|
-
marginBottom: 0
|
|
1081
|
-
}
|
|
1082
|
-
}, "You are not authorised to use this service. Please sign in again or contact support.")));
|
|
1083
|
-
} else if (tokenLoading && idToken && email) {
|
|
1037
|
+
if (tokenLoading && idToken && email) {
|
|
1084
1038
|
// While checking token (SSO in progress), show a simple loading state instead of the full UI
|
|
1085
1039
|
content = /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1086
1040
|
style: {
|
|
@@ -1112,7 +1066,7 @@
|
|
|
1112
1066
|
}
|
|
1113
1067
|
}, "Checking authorisation..."));
|
|
1114
1068
|
} else {
|
|
1115
|
-
content = /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1069
|
+
content = /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1116
1070
|
style: {
|
|
1117
1071
|
fontFamily,
|
|
1118
1072
|
background: "#F5F5F7",
|
|
@@ -1173,153 +1127,7 @@
|
|
|
1173
1127
|
fontSize: "16px"
|
|
1174
1128
|
},
|
|
1175
1129
|
title: "Clear search"
|
|
1176
|
-
}, "\u2715")), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1177
|
-
style: {
|
|
1178
|
-
display: "flex",
|
|
1179
|
-
alignItems: "center",
|
|
1180
|
-
gap: isMobile ? "10px" : "16px"
|
|
1181
|
-
}
|
|
1182
|
-
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1183
|
-
style: {
|
|
1184
|
-
position: "relative",
|
|
1185
|
-
cursor: "pointer"
|
|
1186
|
-
}
|
|
1187
|
-
}, /*#__PURE__*/React__default["default"].createElement("svg", {
|
|
1188
|
-
width: "20",
|
|
1189
|
-
height: "20",
|
|
1190
|
-
viewBox: "0 0 24 24",
|
|
1191
|
-
fill: "none",
|
|
1192
|
-
stroke: "#555",
|
|
1193
|
-
strokeWidth: "2",
|
|
1194
|
-
strokeLinecap: "round",
|
|
1195
|
-
strokeLinejoin: "round"
|
|
1196
|
-
}, /*#__PURE__*/React__default["default"].createElement("path", {
|
|
1197
|
-
d: "M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"
|
|
1198
|
-
}), /*#__PURE__*/React__default["default"].createElement("path", {
|
|
1199
|
-
d: "M13.73 21a2 2 0 0 1-3.46 0"
|
|
1200
|
-
})), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
1201
|
-
style: {
|
|
1202
|
-
position: "absolute",
|
|
1203
|
-
top: "-5px",
|
|
1204
|
-
right: "-5px",
|
|
1205
|
-
background: "#1CC3CE",
|
|
1206
|
-
color: "white",
|
|
1207
|
-
borderRadius: "50%",
|
|
1208
|
-
width: "16px",
|
|
1209
|
-
height: "16px",
|
|
1210
|
-
fontSize: "10px",
|
|
1211
|
-
fontWeight: 600,
|
|
1212
|
-
display: "flex",
|
|
1213
|
-
alignItems: "center",
|
|
1214
|
-
justifyContent: "center"
|
|
1215
|
-
}
|
|
1216
|
-
}, "1")), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1217
|
-
style: {
|
|
1218
|
-
position: "relative"
|
|
1219
|
-
}
|
|
1220
|
-
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
1221
|
-
type: "button",
|
|
1222
|
-
onClick: () => setShowProfileDropdown(v => !v),
|
|
1223
|
-
style: {
|
|
1224
|
-
display: "flex",
|
|
1225
|
-
alignItems: "center",
|
|
1226
|
-
gap: "8px",
|
|
1227
|
-
background: "none",
|
|
1228
|
-
border: "none",
|
|
1229
|
-
cursor: "pointer",
|
|
1230
|
-
padding: "4px 0",
|
|
1231
|
-
fontFamily
|
|
1232
|
-
},
|
|
1233
|
-
"aria-expanded": showProfileDropdown,
|
|
1234
|
-
"aria-haspopup": "true"
|
|
1235
|
-
}, !isMobile && /*#__PURE__*/React__default["default"].createElement("span", {
|
|
1236
|
-
style: {
|
|
1237
|
-
fontSize: "13px",
|
|
1238
|
-
color: "#555"
|
|
1239
|
-
}
|
|
1240
|
-
}, "Hello, ", /*#__PURE__*/React__default["default"].createElement("strong", {
|
|
1241
|
-
style: {
|
|
1242
|
-
color: "#1a1a1a"
|
|
1243
|
-
}
|
|
1244
|
-
}, displayName)), /*#__PURE__*/React__default["default"].createElement("img", {
|
|
1245
|
-
src: "https://w7.pngwing.com/pngs/340/946/png-transparent-avatar-user-computer-icons-software-developer-avatar-child-face-heroes-thumbnail.png",
|
|
1246
|
-
alt: "User",
|
|
1247
|
-
style: {
|
|
1248
|
-
width: "32px",
|
|
1249
|
-
height: "32px",
|
|
1250
|
-
borderRadius: "50%",
|
|
1251
|
-
objectFit: "cover"
|
|
1252
|
-
}
|
|
1253
|
-
}), /*#__PURE__*/React__default["default"].createElement("svg", {
|
|
1254
|
-
width: "12",
|
|
1255
|
-
height: "12",
|
|
1256
|
-
viewBox: "0 0 24 24",
|
|
1257
|
-
fill: "none",
|
|
1258
|
-
stroke: "currentColor",
|
|
1259
|
-
strokeWidth: "2",
|
|
1260
|
-
style: {
|
|
1261
|
-
flexShrink: 0,
|
|
1262
|
-
opacity: showProfileDropdown ? 0.8 : 0.5
|
|
1263
|
-
}
|
|
1264
|
-
}, /*#__PURE__*/React__default["default"].createElement("polyline", {
|
|
1265
|
-
points: "6 9 12 15 18 9"
|
|
1266
|
-
}))), showProfileDropdown && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1267
|
-
style: {
|
|
1268
|
-
position: "fixed",
|
|
1269
|
-
inset: 0,
|
|
1270
|
-
zIndex: 9998
|
|
1271
|
-
},
|
|
1272
|
-
onClick: () => setShowProfileDropdown(false),
|
|
1273
|
-
"aria-hidden": "true"
|
|
1274
|
-
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1275
|
-
style: {
|
|
1276
|
-
position: "absolute",
|
|
1277
|
-
right: 0,
|
|
1278
|
-
top: "100%",
|
|
1279
|
-
marginTop: "4px",
|
|
1280
|
-
minWidth: "140px",
|
|
1281
|
-
background: "#FFFFFF",
|
|
1282
|
-
border: "1px solid #E5E5E5",
|
|
1283
|
-
borderRadius: "8px",
|
|
1284
|
-
boxShadow: "0 4px 16px rgba(0,0,0,0.12)",
|
|
1285
|
-
zIndex: 9999,
|
|
1286
|
-
overflow: "hidden"
|
|
1287
|
-
}
|
|
1288
|
-
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
1289
|
-
type: "button",
|
|
1290
|
-
onClick: handleLogout,
|
|
1291
|
-
style: {
|
|
1292
|
-
width: "100%",
|
|
1293
|
-
padding: "10px 14px",
|
|
1294
|
-
textAlign: "left",
|
|
1295
|
-
background: "none",
|
|
1296
|
-
border: "none",
|
|
1297
|
-
cursor: "pointer",
|
|
1298
|
-
fontSize: "13px",
|
|
1299
|
-
fontFamily,
|
|
1300
|
-
color: "#e53935",
|
|
1301
|
-
fontWeight: 500,
|
|
1302
|
-
display: "flex",
|
|
1303
|
-
alignItems: "center",
|
|
1304
|
-
gap: "8px"
|
|
1305
|
-
}
|
|
1306
|
-
}, /*#__PURE__*/React__default["default"].createElement("svg", {
|
|
1307
|
-
width: "16",
|
|
1308
|
-
height: "16",
|
|
1309
|
-
viewBox: "0 0 24 24",
|
|
1310
|
-
fill: "none",
|
|
1311
|
-
stroke: "currentColor",
|
|
1312
|
-
strokeWidth: "2"
|
|
1313
|
-
}, /*#__PURE__*/React__default["default"].createElement("path", {
|
|
1314
|
-
d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"
|
|
1315
|
-
}), /*#__PURE__*/React__default["default"].createElement("polyline", {
|
|
1316
|
-
points: "16 17 21 12 16 7"
|
|
1317
|
-
}), /*#__PURE__*/React__default["default"].createElement("line", {
|
|
1318
|
-
x1: "21",
|
|
1319
|
-
y1: "12",
|
|
1320
|
-
x2: "9",
|
|
1321
|
-
y2: "12"
|
|
1322
|
-
})), "Logout")))))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1130
|
+
}, "\u2715")), false ), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
1323
1131
|
style: {
|
|
1324
1132
|
padding: isMobile ? "12px" : "16px 24px",
|
|
1325
1133
|
flex: 1,
|
|
@@ -2553,7 +2361,56 @@
|
|
|
2553
2361
|
pointerEvents: "none",
|
|
2554
2362
|
zIndex: 10002
|
|
2555
2363
|
}
|
|
2556
|
-
})), /*#__PURE__*/React__default["default"].createElement("style", null, "\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n ")))
|
|
2364
|
+
})), /*#__PURE__*/React__default["default"].createElement("style", null, "\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n "))), showAuthError && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2365
|
+
style: {
|
|
2366
|
+
position: "fixed",
|
|
2367
|
+
inset: 0,
|
|
2368
|
+
zIndex: 100000,
|
|
2369
|
+
display: "flex",
|
|
2370
|
+
alignItems: "center",
|
|
2371
|
+
justifyContent: "center",
|
|
2372
|
+
padding: "24px",
|
|
2373
|
+
background: "rgba(0,0,0,0.4)",
|
|
2374
|
+
boxSizing: "border-box"
|
|
2375
|
+
}
|
|
2376
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2377
|
+
style: {
|
|
2378
|
+
fontFamily,
|
|
2379
|
+
maxWidth: "400px",
|
|
2380
|
+
width: "100%",
|
|
2381
|
+
padding: "32px 24px",
|
|
2382
|
+
background: "#FFFFFF",
|
|
2383
|
+
borderRadius: "12px",
|
|
2384
|
+
boxShadow: "0 8px 32px rgba(0,0,0,0.2)",
|
|
2385
|
+
textAlign: "center"
|
|
2386
|
+
}
|
|
2387
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
2388
|
+
style: {
|
|
2389
|
+
fontSize: "48px",
|
|
2390
|
+
marginBottom: "16px"
|
|
2391
|
+
}
|
|
2392
|
+
}, "\uD83D\uDD12"), /*#__PURE__*/React__default["default"].createElement("h2", {
|
|
2393
|
+
style: {
|
|
2394
|
+
fontSize: "20px",
|
|
2395
|
+
fontWeight: 700,
|
|
2396
|
+
color: "#1a1a1a",
|
|
2397
|
+
margin: "0 0 8px 0"
|
|
2398
|
+
}
|
|
2399
|
+
}, tokenError ? "Not authorised" : "Sign in required"), /*#__PURE__*/React__default["default"].createElement("p", {
|
|
2400
|
+
style: {
|
|
2401
|
+
fontSize: "14px",
|
|
2402
|
+
color: "#666",
|
|
2403
|
+
margin: 0,
|
|
2404
|
+
lineHeight: 1.5
|
|
2405
|
+
}
|
|
2406
|
+
}, authErrorMessage), /*#__PURE__*/React__default["default"].createElement("p", {
|
|
2407
|
+
style: {
|
|
2408
|
+
fontSize: "13px",
|
|
2409
|
+
color: "#999",
|
|
2410
|
+
marginTop: "16px",
|
|
2411
|
+
marginBottom: 0
|
|
2412
|
+
}
|
|
2413
|
+
}, "Redirecting to login..."))));
|
|
2557
2414
|
}
|
|
2558
2415
|
return /*#__PURE__*/React__default["default"].createElement(AppointmentErrorBoundary, null, content);
|
|
2559
2416
|
};
|
|
@@ -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),l=o(n);function i(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const r="https://afiyaapiqa.powermindinc.com",d="/appointment/V1/consultant/all-appointments",s="/notification/V1/consultation/online/initiate",p="dMtEGhak",c=6694,u="https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/",f="https://wbaemrdevittisalwe01-fnapdpfme7bvduhh.westeurope-01.azurewebsites.net/",m=async function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=(e||"").toUpperCase();"INPROGRESS"===a&&(a="IN_PROGRESS");const l=o.apiBaseUrl||r,i=o.hospitalId||p,s=o.doctorId||c,u=o.token||"",f={hospitalId:i,doctorId:s,fromDate:t,toDate:n,statuses:a},m="".concat(l).concat(d),x=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);o.search=new URLSearchParams(t).toString();const a={method:"GET",headers:{"Content-Type":"application/json",Authorization:"".concat(n)}};return fetch(o,a).then(async e=>{const t=await e.json().catch(()=>({}));var n;return e.ok?t:{err:(null==t||null===(n=t.resultInfo)||void 0===n?void 0:n.message)||"Something went wrong!",status:e.status}}).catch(e=>(console.error("Fetch error:",e),{err:(null==e?void 0:e.message)||String(e)||"Network error"}))}(m,f,"PIH-Appointment-Widget",u);return x},x=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=(t.apiBaseUrl||r).replace(/\/$/,""),o="".concat(n).concat(s),a=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 l={"Content-Type":"application/json"};o&&(l.Authorization=o);const i={method:"POST",headers:l,body:JSON.stringify(t)};return fetch(a.toString(),i).then(async e=>{const t=await e.json().catch(()=>({}));var n;return e.ok?t:{err:(null==t||null===(n=t.resultInfo)||void 0===n?void 0:n.message)||"Something went wrong!",status:e.status}}).catch(e=>(console.error("Fetch error:",e),{err:e.message||"Network error"}))}(o,{patientId:String(e.patientId||""),primaryPatientId:String(e.primaryPatientId||e.patientId||""),hospitalId:t.hospitalId||p,doctorId:String(t.doctor_id||c),patientName:e.patientName||e.name||"",doctorName:e.doctorName||t.doctorName,appointmentId:String(e.id||e.appointmentId||e._id||"")},"PIH-Appointment-Widget",{},a)};const g="pih_appointment_idToken",h="pih_appointment_email",y="pih_appointment_appToken",E="pih_appointment_doctorId",v="pih_appointment_userName";class b extends t.Component{constructor(){super(...arguments),i(this,"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",{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 F=e=>{let{config:n={}}=e;const o=n.apiBaseUrl||r,l=n.hospitalId||p,[i,d]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(g):null}catch(e){return null}}),[s,F]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(h):null}catch(e){return null}}),w=n.idToken||n.token||i,S=n.email||s;t.useEffect(()=>{try{if("undefined"==typeof localStorage)return;const e=n.idToken||n.token;if(e&&String(e).trim()){localStorage.getItem(g)!==e&&(C(null),z(null),W(null),localStorage.removeItem(y),localStorage.removeItem(E),localStorage.removeItem(v)),localStorage.setItem(g,e),d(e)}n.email&&String(n.email).trim()&&(localStorage.setItem(h,n.email),F(n.email))}catch(e){}},[n.idToken,n.token,n.email]);const[k,C]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(y):null}catch(e){return null}}),[I,z]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(E):null}catch(e){return null}}),[D,W]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(v):null}catch(e){return null}}),[T,M]=t.useState(()=>{try{if("undefined"==typeof localStorage)return!1;const e=localStorage.getItem(y),t=localStorage.getItem(g),n=localStorage.getItem(h);return!e&&!(!t||!n)}catch(e){return!1}}),[A,R]=t.useState(null),[j,N]=t.useState(0);t.useEffect(()=>{k&&T&&M(!1)},[k,T]),t.useEffect(()=>{if(!T)return;const e=setTimeout(()=>{R("Request timed out. Please try again."),M(!1)},3e4);return()=>clearTimeout(e)},[T]);const B=n.joinCallUrl||u;k&&String(B||"").replace(/\/?$/,"/");const L=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(e){return{}}}(w),H=D||L.name||L.sub||"User",P=()=>(new Date).toISOString().split("T")[0],[Y,O]=t.useState("upcoming"),[_,U]=t.useState([]),[V,X]=t.useState(null),[$,q]=t.useState(!1),[G,J]=t.useState(null),[K,Q]=t.useState(window.innerWidth<768),[Z,ee]=t.useState("today"),[te,ne]=t.useState("today"),[oe,ae]=t.useState(!1),[le,ie]=t.useState("asc"),[re,de]=t.useState(""),[se,pe]=t.useState(!1),[ce,ue]=t.useState(!1),[fe,me]=t.useState(!1),[xe,ge]=t.useState(null),[he,ye]=t.useState(null),[Ee,ve]=t.useState(!1),[be,Fe]=t.useState(null),[we,Se]=t.useState({x:window.innerWidth-550,y:80}),[ke,Ce]=t.useState({width:550,height:450}),[Ie,ze]=t.useState(!1),[De,We]=t.useState({x:0,y:0}),[Te,Me]=t.useState(!1),[Ae,Re]=t.useState(null),[je,Ne]=t.useState({x:0,y:0,width:0,height:0}),[Be,Le]=t.useState(!1),[He,Pe]=t.useState(1),Ye=_.filter(e=>{if(!re.trim())return!0;const t=re.toLowerCase(),n=(e.patientName||"").toLowerCase(),o=String(e.patientId||"").toLowerCase();return n.includes(t)||o.includes(t)}),Oe=20*(He-1),_e=Oe+20,Ue=Ye.slice(Oe,_e),Ve=Math.ceil(Ye.length/20),Xe=Ye.length,[$e,qe]=t.useState(P()),[Ge,Je]=t.useState(P()),[Ke,Qe]=t.useState(),[Ze,et]=t.useState(),tt=e=>(null==e?void 0:e.id)||(null==e?void 0:e._id)||(null==e?void 0:e.appointmentId)||(null==e?void 0:e.patientId)||JSON.stringify(e),nt=e=>null!=e&&e.image?e.image:null,ot=e=>e?e.charAt(0).toUpperCase():"?",at=e=>{if(!e)return"#4C4DDC";const t=["#4C4DDC","#1CC3CE","#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F"];return t[e.charCodeAt(0)%t.length]},lt=()=>{const e="asc"===le?"desc":"asc";ie(e);const t=[..._].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});U(t),Pe(1),t.length>0&&X(t[0])},it=t.useCallback(async()=>{if(!k)return;const e=I||c;q(!0),J(null);try{const t={apiBaseUrl:o,hospitalId:l,doctorId:e,token:k},n=await m(Y,$e,Ge,t);if(401===n.status||403===n.status){try{"undefined"!=typeof localStorage&&(localStorage.removeItem(y),localStorage.removeItem(E),localStorage.removeItem(v))}catch(e){}return C(null),z(null),W(null),N(e=>e+1),void J("Session expired. Re-authenticating...")}if(n.err)return void J(String(n.err||"Failed to fetch appointments"));const a=n.data||n.appointments||n||[];U(Array.isArray(a)?a:[]),Array.isArray(a)&&a.length>0?X(a[0]):X(null)}catch(e){console.error("Error fetching appointments:",e),J(e.message||"Failed to fetch appointments")}finally{q(!1)}},[Y,$e,Ge,o,l,I,k]),rt=e=>{X(e)},dt=()=>{try{"undefined"!=typeof localStorage&&(localStorage.removeItem(g),localStorage.removeItem(h),localStorage.removeItem(y),localStorage.removeItem(E),localStorage.removeItem(v))}catch(e){}Le(!1);const e=n.homeUrl||f||"";e&&"undefined"!=typeof window&&(window.location.href=e)},st=async()=>{if(V&&k){ve(!0),Fe(null);try{var e;const t={apiBaseUrl:o,hospitalId:l,doctorId:I||c,doctorName:D||H,appToken:k};console.log(V,"selectedAppointment"),console.log(t,"callConfig");const a=await x(V,t);if(401===a.status||403===a.status)return Fe("Session expired. Please try again."),void ve(!1);if(a.err||null===(e=a.data)||void 0===e||!e.token)return Fe(String(a.err||"Failed to initiate call")),void ve(!1);const i=n.joinCallUrl||u,r=a.data.token?String(i||"").replace(/\/?$/,"/")+a.data.token:"";console.log("joinCallUrl",r),ge(a.data.token),ye(r||""),pe(!0),ue(!1),me(!1)}catch(e){Fe(e.message||"Failed to initiate call")}finally{ve(!1)}}},pt=()=>{pe(!1),ue(!1),me(!1),ge(null),ye(null),Fe(null)},ct=()=>{fe&&me(!1),ue(!ce)},ut=()=>{ce&&ue(!1),me(!fe)},ft=e=>{ze(!0);const t=e.currentTarget.getBoundingClientRect();We({x:e.clientX-t.left,y:e.clientY-t.top})},mt=t.useCallback(e=>{if(!fe)if(Ie){const t=e.clientX-De.x,n=e.clientY-De.y,o=window.innerWidth-ke.width,a=window.innerHeight-ke.height;Se({x:Math.max(0,Math.min(t,o)),y:Math.max(0,Math.min(n,a))})}else if(Te){const t=e.clientX-je.x,n=e.clientY-je.y;let o=je.width,a=je.height,l=je.posX,i=je.posY;const r=300,d=250,s=window.innerWidth-40,p=window.innerHeight-100;if("right"===Ae)o=Math.min(Math.max(je.width+t,r),s),l+o>window.innerWidth&&(o=window.innerWidth-l);else if("left"===Ae){const e=Math.min(Math.max(je.width-t,r),s),n=e-je.width;o=e,l=Math.max(0,je.posX-n),0===l&&(o=je.posX+je.width)}else if("bottom"===Ae)a=Math.min(Math.max(je.height+n,d),p),i+a>window.innerHeight&&(a=window.innerHeight-i);else if("top"===Ae){const e=Math.min(Math.max(je.height-n,d),p),t=e-je.height;a=e,i=Math.max(0,je.posY-t),0===i&&(a=je.posY+je.height)}Ce({width:o,height:a}),Se({x:l,y:i})}},[Ie,Te,De,Ae,je,we,ke,fe]),xt=()=>{ze(!1),Me(!1),Re(null)},gt=(e,t)=>{t.preventDefault(),t.stopPropagation(),Me(!0),Re(e),Ne({x:t.clientX,y:t.clientY,width:ke.width,height:ke.height,posX:we.x,posY:we.y})};t.useEffect(()=>{if(Ie||Te)return window.addEventListener("mousemove",mt),window.addEventListener("mouseup",xt),()=>{window.removeEventListener("mousemove",mt),window.removeEventListener("mouseup",xt)}},[Ie,Te,mt]),t.useEffect(()=>{if(!se||fe)return;const e=()=>{if(!(window.innerWidth<768)){const e=ce?350:ke.width,t=ce?60:ke.height,n=window.innerWidth-40,o=window.innerHeight-100,a=Math.min(e,n),l=Math.min(t,o);a===ke.width&&l===ke.height||Ce({width:a,height:l});const i=window.innerWidth-a-20,r=window.innerHeight-l-20;Se(e=>({x:Math.min(e.x,i),y:Math.min(e.y,r)}))}};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[se,ce,fe,ke]),t.useEffect(()=>{if(!(w&&S&&(!k||j>0)))return;let e=!1;return M(!0),R(null),(async(e,t,n,o)=>{const a=e.replace(/\/$/,""),l="".concat(a,"/um/user/V1/sso/login?hospitalId=").concat(encodeURIComponent(t)),i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({idToken:n,email:o})};return console.log("[getTokenFromSso] request",{url:l,body:{idToken:n?n.slice(0,50)+"...":null,email:o}}),fetch(l,i).then(e=>(console.log("[getTokenFromSso] response status",e.status,e.statusText),e.ok?e.json().then(e=>{var t;return console.log("[getTokenFromSso] success",{hasData:!!e,dataKeys:e?Object.keys(e):[],hasAccessToken:!(null==e||null===(t=e.data)||void 0===t||!t.access_token)}),e}):e.json().then(t=>{var n;const o=(null==t||null===(n=t.resultInfo)||void 0===n?void 0:n.message)||"SSO login failed";return console.log("[getTokenFromSso] error body",t),{err:o,status:e.status}}).catch(()=>({err:"Something went wrong!",status:e.status})))).catch(e=>(console.error("[getTokenFromSso] catch",e),{err:e.message||"Network error"}))})(o,l,w,S).then(t=>{if(e)return;const o=function(e){var t,n,o,a,l,i;return!e||e.err?null:null!==(t=null!==(n=null!==(o=null!==(a=null===(l=e.data)||void 0===l?void 0:l.access_token)&&void 0!==a?a:null===(i=e.data)||void 0===i?void 0:i.token)&&void 0!==o?o:e.token)&&void 0!==n?n:e.accessToken)&&void 0!==t?t:null}(t);if(400===t.status){const e=t.err+" Redirecting to home..."||"Invalid user. Redirecting to home...";R(e),M(!1);const o=n.homeUrl||f||"";return void(o&&"undefined"!=typeof window&&setTimeout(()=>{window.location.href=o},3e3))}if(t.err||!o){R(String(t.err||"Failed to get token")),C(null),z(null),W(null);try{"undefined"!=typeof localStorage&&(localStorage.removeItem(y),localStorage.removeItem(E),localStorage.removeItem(v))}catch(e){}}else{const e=function(e){var t,n;if(null==e||!e.data)return null;const o=null!==(t=null!==(n=e.data.doctor_id)&&void 0!==n?n:e.data.doctorId)&&void 0!==t?t:null;return null!=o?String(o):null}(t),n=function(e){var t,n,o;if(null==e||!e.data)return null;const a=null!==(t=null!==(n=null!==(o=e.data.name)&&void 0!==o?o:e.data.doctor_name)&&void 0!==n?n:e.data.userName)&&void 0!==t?t:null;return null!=a?String(a):null}(t);C(o),z(e),W(n),R(null);try{"undefined"!=typeof localStorage&&(localStorage.setItem(y,o),e&&localStorage.setItem(E,e),n&&localStorage.setItem(v,n))}catch(e){}}}).catch(()=>{}).finally(()=>{e||M(!1)}),()=>{e=!0}},[o,l,w,S,j]),t.useEffect(()=>{Pe(1)},[Y,Z,$e,Ge,re]),t.useEffect(()=>{!T&&k&&it()},[it,k,T]),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=()=>{Q(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=>{!oe||e.target.closest("button")||e.target.closest('input[type="date"]')||ae(!1)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[oe]);let ht,yt='"Nunito", serif';return ht=A?a.default.createElement("div",{style:{fontFamily:yt,background:"#F5F5F7",boxSizing:"border-box",height:"100vh",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"24px",textAlign:"center"}},a.default.createElement("div",{style:{maxWidth:"400px",padding:"32px 24px",background:"#FFFFFF",borderRadius:"12px",boxShadow:"0 4px 20px rgba(0,0,0,0.08)"}},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"}},"Not authorised"),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0,lineHeight:1.5}},A),a.default.createElement("p",{style:{fontSize:"13px",color:"#999",marginTop:"16px",marginBottom:0}},"You are not authorised to use this service. Please sign in again or contact support."))):T&&w&&S?a.default.createElement("div",{style:{fontFamily:yt,background:"#F5F5F7",boxSizing:"border-box",height:"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("div",{style:{fontFamily:yt,background:"#F5F5F7",boxSizing:"border-box",height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"}},a.default.createElement("div",{style:{background:"#FFFFFF",padding:K?"10px 12px":"12px 24px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #E5E5E5",flexWrap:"nowrap",gap:K?"8px":"0"}},a.default.createElement("div",{style:{position:"relative",width:K?"calc(100% - 90px)":"480px",maxWidth:K?"none":"480px"}},a.default.createElement("input",{type:"text",placeholder:"Search by patient name or ID",value:re,onChange:e=>de(e.target.value),style:{width:"100%",padding:K?"8px 32px 8px 10px":"8px 36px 8px 14px",border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:K?"12px":"13px",fontFamily:yt,background:"#FFFFFF",outline:"none",boxSizing:"border-box"}}),re&&a.default.createElement("button",{onClick:()=>de(""),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"},"✕")),a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:K?"10px":"16px"}},a.default.createElement("div",{style:{position:"relative",cursor:"pointer"}},a.default.createElement("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#555",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},a.default.createElement("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),a.default.createElement("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})),a.default.createElement("span",{style:{position:"absolute",top:"-5px",right:"-5px",background:"#1CC3CE",color:"white",borderRadius:"50%",width:"16px",height:"16px",fontSize:"10px",fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center"}},"1")),a.default.createElement("div",{style:{position:"relative"}},a.default.createElement("button",{type:"button",onClick:()=>Le(e=>!e),style:{display:"flex",alignItems:"center",gap:"8px",background:"none",border:"none",cursor:"pointer",padding:"4px 0",fontFamily:yt},"aria-expanded":Be,"aria-haspopup":"true"},!K&&a.default.createElement("span",{style:{fontSize:"13px",color:"#555"}},"Hello, ",a.default.createElement("strong",{style:{color:"#1a1a1a"}},H)),a.default.createElement("img",{src:"https://w7.pngwing.com/pngs/340/946/png-transparent-avatar-user-computer-icons-software-developer-avatar-child-face-heroes-thumbnail.png",alt:"User",style:{width:"32px",height:"32px",borderRadius:"50%",objectFit:"cover"}}),a.default.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{flexShrink:0,opacity:Be?.8:.5}},a.default.createElement("polyline",{points:"6 9 12 15 18 9"}))),Be&&a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{style:{position:"fixed",inset:0,zIndex:9998},onClick:()=>Le(!1),"aria-hidden":"true"}),a.default.createElement("div",{style:{position:"absolute",right:0,top:"100%",marginTop:"4px",minWidth:"140px",background:"#FFFFFF",border:"1px solid #E5E5E5",borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.12)",zIndex:9999,overflow:"hidden"}},a.default.createElement("button",{type:"button",onClick:dt,style:{width:"100%",padding:"10px 14px",textAlign:"left",background:"none",border:"none",cursor:"pointer",fontSize:"13px",fontFamily:yt,color:"#e53935",fontWeight:500,display:"flex",alignItems:"center",gap:"8px"}},a.default.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},a.default.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),a.default.createElement("polyline",{points:"16 17 21 12 16 7"}),a.default.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"})),"Logout")))))),a.default.createElement("div",{style:{padding:K?"12px":"16px 24px",flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}},a.default.createElement("div",{style:{marginBottom:K?"10px":"14px"}},a.default.createElement("h1",{style:{fontSize:K?"18px":"22px",fontWeight:700,color:"#1a1a1a",margin:"0 0 2px 0"}},"Tele Consultation"),a.default.createElement("p",{style:{fontSize:K?"11px":"12px",color:"#999",margin:0}},"Displaying All Tele Consultation Appointments")),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:K?"flex-start":"center",marginBottom:K?"10px":"14px",flexDirection:K?"column":"row",gap:K?"12px":"0"}},a.default.createElement("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",width:K?"100%":"auto"}},a.default.createElement("button",{onClick:()=>O("upcoming"),style:{background:"upcoming"===Y?"#4C4DDC":"#FFFFFF",padding:K?"8px 10px":"9px 16px",border:"upcoming"===Y?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:K?"10px":"13px",color:"upcoming"===Y?"white":"#555555",fontWeight:600,fontFamily:yt,cursor:"pointer",flex:K?"1 1 auto":"none",minWidth:K?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Upcoming Appointments"),a.default.createElement("button",{onClick:()=>O("completed"),style:{background:"completed"===Y?"#4C4DDC":"#FFFFFF",padding:K?"8px 10px":"9px 16px",border:"completed"===Y?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:K?"10px":"13px",color:"completed"===Y?"white":"#555555",fontWeight:600,fontFamily:yt,cursor:"pointer",flex:K?"1 1 auto":"none",minWidth:K?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Completed Appointments"),a.default.createElement("button",{onClick:()=>O("cancelled"),style:{background:"cancelled"===Y?"#4C4DDC":"#FFFFFF",padding:K?"8px 10px":"9px 16px",border:"cancelled"===Y?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:K?"10px":"13px",color:"cancelled"===Y?"white":"#555555",fontWeight:600,fontFamily:yt,cursor:"pointer",flex:K?"1 1 auto":"none",minWidth:K?"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:K?"flex-start":"flex-end"}},a.default.createElement("button",{onClick:()=>{oe||(Qe($e),et(Ge),ne(Z)),ae(!oe)},style:{padding:"8px 12px",fontFamily:yt,fontWeight:600,border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:K?"11px":"13px",color:"#1a1a1a",background:"#FFFFFF",display:"flex",alignItems:"center",gap:K?"4px":"6px",cursor:"pointer",flex:"none",minWidth:K?"100px":"auto",justifyContent:"center"}},a.default.createElement("svg",{width:K?"12":"14",height:K?"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(Z){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 K?"Custom":"".concat($e," to ").concat(Ge)}})()),a.default.createElement("svg",{width:K?"8":"10",height:K?"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"}))),oe&&a.default.createElement("div",{style:{position:"absolute",top:"100%",right:K?"auto":0,left:K?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:K?"280px":"240px",width:K?"calc(100vw - 24px)":"auto",maxWidth:K?"calc(100vw - 24px)":"280px"}},a.default.createElement("div",{style:{marginBottom:"custom"===te?"12px":"0"}},["thisMonth","today","tomorrow","currentWeek","currentYear","custom"].map(e=>a.default.createElement("button",{key:e,onClick:()=>{if(ne(e),"custom"!==e){const t=(e=>{const t=new Date;let n,o;switch(e){case"today":default:n=o=P();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),l=new Date(t),i=t.getDay(),r=0===i?-6:1-i;a.setDate(t.getDate()+r),l.setDate(a.getDate()+6),n=a.toISOString().split("T")[0],o=l.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="".concat(t.getFullYear(),"-01-01"),o="".concat(t.getFullYear(),"-12-31")}return{from:n,to:o}})(e);ee(e),qe(t.from),Je(t.to),Qe(t.from),et(t.to),ae(!1)}else Qe(""),et("")},style:{width:"100%",padding:"10px 12px",background:te===e?"#E8EEF4":"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:yt,cursor:"pointer",textAlign:"left",fontWeight:te===e?600:400,color:te===e?"#4C4DDC":"#1a1a1a",marginBottom:"4px",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.2s ease"},onMouseEnter:t=>{te!==e&&(t.target.style.background="#F5F5F5")},onMouseLeave:t=>{te!==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]),te===e&&a.default.createElement("span",{style:{color:"#4C4DDC",fontSize:"16px"}},"✓")))),"custom"===te&&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:Ke,onChange:e=>Qe(e.target.value),placeholder:"Start Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:yt,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{marginBottom:"12px"}},a.default.createElement("input",{type:"date",value:Ze,onChange:e=>et(e.target.value),placeholder:"End Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:yt,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{display:"flex",gap:"8px"}},a.default.createElement("button",{onClick:()=>{ne(Z),Qe($e),et(Ge),ae(!1)},style:{flex:1,padding:"10px 12px",background:"#FFFFFF",color:"#4C4DDC",border:"1px solid #4C4DDC",borderRadius:"4px",fontSize:"13px",fontFamily:yt,fontWeight:600,cursor:"pointer"}},"Cancel"),a.default.createElement("button",{onClick:()=>{Ke&&Ze&&(ee("custom"),qe(Ke),Je(Ze),ae(!1))},style:{flex:1,padding:"10px 12px",background:"#4C4DDC",color:"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:yt,fontWeight:600,cursor:"pointer"}},"Submit")))))),a.default.createElement("div",{style:{display:"flex",flexDirection:K?"column":"row",gap:K?"12px":"14px",flex:1,minHeight:0,overflow:K?"auto":"hidden"}},a.default.createElement("div",{style:{flex:K?"none":"1 1 65%",width:K?"100%":"auto",display:"flex",flexDirection:"column",minHeight:K?"400px":"auto"}},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",height:K?"auto":"100%"}},a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:K?"12px 14px":"14px 18px",borderBottom:"1px solid #F1F1F1"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:K?"6px":"8px"}},a.default.createElement("span",{style:{fontSize:K?"14px":"15px",fontWeight:700,color:"#1a1a1a"}},"Appointments"),a.default.createElement("span",{style:{background:"#4C4DDC",color:"#fff",fontSize:K?"10px":"11px",fontWeight:600,padding:K?"2px 7px":"3px 8px",borderRadius:"12px"}},Xe))),a.default.createElement("div",{className:"appointments-header-grid",style:{display:"grid",gridTemplateColumns:K?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:K?"8px":"12px",padding:K?"8px 12px":"10px 18px",background:"#F5F5F5",fontSize:K?"10px":"12px",fontWeight:600,color:"#666"}},a.default.createElement("div",null,"Patients name"),!K&&a.default.createElement("div",null,"Patient ID"),a.default.createElement("div",{onClick:lt,style:{display:"flex",alignItems:"center",gap:"3px",cursor:"pointer",userSelect:"none"}},"Date",a.default.createElement("span",{style:{opacity:.7,fontSize:"10px"}},"asc"===le?"▲":"▼")),!K&&a.default.createElement("div",null,"Slot"),!K&&a.default.createElement("div",null,"Doctor")),a.default.createElement("div",{style:{overflow:"auto",flex:1}},T?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...")):$?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...")):G?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"}},G),a.default.createElement("button",{onClick:it,style:{marginTop:"16px",padding:"8px 16px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontFamily:yt}},"Retry")):0===Ue.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"}},re?'No appointments found for "'.concat(re,'"'):"No appointments found"),re&&a.default.createElement("button",{onClick:()=>de(""),style:{marginTop:"12px",padding:"6px 12px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px",fontFamily:yt}},"Clear Search")):Ue.map(e=>a.default.createElement("div",{key:tt(e),role:"button",tabIndex:0,onClick:()=>rt(e),onKeyDown:t=>"Enter"===t.key&&rt(e),className:"appointments-grid",style:{display:"grid",gridTemplateColumns:K?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:K?"8px":"12px",padding:K?"10px 12px":"12px 18px",background:tt(V)===tt(e)?"#E8EEF4":"#FFFFFF",borderTop:"1px solid #F1F1F1",alignItems:"center",cursor:"pointer",fontSize:K?"11px":"13px"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:K?"8px":"10px"}},nt(e)?a.default.createElement("img",{src:e.image,alt:"",style:{width:K?"32px":"36px",height:K?"32px":"36px",borderRadius:"50%",objectFit:"cover"}}):a.default.createElement("div",{style:{width:K?"32px":"36px",height:K?"32px":"36px",borderRadius:"50%",background:at(e.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:600,fontSize:K?"14px":"16px"}},ot(e.patientName)),a.default.createElement("div",null,a.default.createElement("div",{style:{fontWeight:600,color:"#1a1a1a",fontSize:K?"11px":"13px"}},e.patientName),a.default.createElement("div",{style:{fontSize:K?"9px":"11px",color:"#888"}},e.email))),!K&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.patientId),a.default.createElement("div",{style:{color:"#555",fontSize:K?"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:K?"9px":"11px",color:"#888"}},n[1].trim())):a.default.createElement("div",null,t)})()),!K&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.appointmentTime||"-"),!K&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.doctorName||e.doctor||"-")))),!$&&!G&&Ue.length>0&&a.default.createElement("div",{style:{padding:K?"12px 14px":"14px 18px",borderTop:"1px solid #F1F1F1",display:"flex",justifyContent:"space-between",alignItems:"center",background:"#FFFFFF",flexWrap:K?"wrap":"nowrap",gap:K?"10px":"0"}},a.default.createElement("div",{style:{fontSize:K?"11px":"12px",color:"#666"}},"Showing page ",He," of ",Ve," (",Xe," total)"),a.default.createElement("div",{style:{display:"flex",gap:"6px",alignItems:"center"}},a.default.createElement("button",{onClick:()=>Pe(e=>Math.max(1,e-1)),disabled:1===He,style:{padding:K?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:1===He?"#F5F5F5":"#FFFFFF",color:1===He?"#999":"#1a1a1a",fontSize:K?"11px":"12px",fontFamily:yt,fontWeight:600,cursor:1===He?"not-allowed":"pointer",opacity:1===He?.5:1}},"Previous"),a.default.createElement("div",{style:{display:"flex",gap:"4px"}},[...Array(Math.min(5,Ve))].map((e,t)=>{let n;return n=Ve<=5||He<=3?t+1:He>=Ve-2?Ve-4+t:He-2+t,a.default.createElement("button",{key:n,onClick:()=>Pe(n),style:{padding:K?"6px 10px":"6px 12px",border:He===n?"none":"1px solid #E5E5E5",borderRadius:"4px",background:He===n?"#4C4DDC":"#FFFFFF",color:He===n?"#FFFFFF":"#1a1a1a",fontSize:K?"11px":"12px",fontFamily:yt,fontWeight:600,cursor:"pointer",minWidth:K?"32px":"36px"}},n)})),a.default.createElement("button",{onClick:()=>Pe(e=>Math.min(Ve,e+1)),disabled:He===Ve,style:{padding:K?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:He===Ve?"#F5F5F5":"#FFFFFF",color:He===Ve?"#999":"#1a1a1a",fontSize:K?"11px":"12px",fontFamily:yt,fontWeight:600,cursor:He===Ve?"not-allowed":"pointer",opacity:He===Ve?.5:1}},"Next"))))),a.default.createElement("div",{style:{flex:K?"none":"1 1 35%",width:K?"100%":"auto",display:V||!K?"flex":"none",flexDirection:"column",minHeight:"auto"}},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",height:K?"auto":"100%"}},V?a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:K?"12px 14px":"16px 18px",background:"#E8EEF4",borderBottom:"1px solid #E5E5E5"}},a.default.createElement("div",null,a.default.createElement("div",{style:{color:"#002668",fontSize:K?"14px":"16px",fontWeight:"700"}},V.patientName||"N/A"),a.default.createElement("div",{style:{color:"#002668",fontSize:K?"11px":"13px"}},V.patientId||V.mrn||"N/A")),a.default.createElement("div",null,nt(V)?a.default.createElement("img",{style:{width:K?"36px":"44px",height:K?"36px":"44px",borderRadius:"50%",objectFit:"cover"},src:V.image,alt:V.patientName}):a.default.createElement("div",{style:{width:K?"36px":"44px",height:K?"36px":"44px",borderRadius:"50%",background:at(V.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:700,fontSize:K?"16px":"20px"}},ot(V.patientName)))),a.default.createElement("div",{style:{padding:K?"12px 14px":"14px 18px",gap:K?"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:K?"10px":"11px",color:"#888",marginBottom:"3px"}},"Speciality"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:K?"12px":"13px"}},(null==V?void 0:V.specialisation)||(null==V?void 0:V.speciality)||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:K?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Type"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:K?"12px":"13px"}},(null==V?void 0:V.type)||(null==V?void 0:V.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:K?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Date"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:K?"12px":"13px"}},(null==V?void 0:V.date)||(null==V?void 0:V.appointmentDate)||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:K?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Time"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:K?"12px":"13px"}},(null==V?void 0:V.time)||(null==V?void 0:V.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:K?"10px":"11px",color:"#888",marginBottom:"3px"}},"Doctor"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:K?"12px":"13px"}},(null==V?void 0:V.doctor)||(null==V?void 0:V.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:K?"10px":"11px",color:"#888",marginBottom:"3px"}},"Hospital"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:K?"12px":"13px"}},(null==V?void 0:V.hospital)||(null==V?void 0:V.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:K?"10px":"11px",color:"#888",marginBottom:"3px"}},"Reason for Appointment"),a.default.createElement("div",{style:{fontWeight:"600",fontSize:K?"11px":"12px",lineHeight:"1.4"}},(null==V?void 0:V.reason)||(null==V?void 0:V.reasonForAppointment)||"No reason provided"))),a.default.createElement("div",{style:{display:"flex",flexDirection:K?"column":"row",gap:"6px",marginTop:"10px"}},a.default.createElement("button",{type:"button",onClick:st,disabled:Ee,style:{flex:1,background:Ee?"#99e4e8":"#1CC3CE",color:"#FFFFFF",border:"1px solid #1CC3CE",borderRadius:"6px",padding:K?"10px 8px":"8px 6px",fontFamily:yt,fontWeight:600,fontSize:K?"11px":"12px",cursor:Ee?"not-allowed":"pointer"}},Ee?"Connecting...":"Join Call >")),be&&a.default.createElement("div",{style:{fontSize:"11px",color:"#e53935",marginTop:"6px",textAlign:"center",width:"100%"}},"⚠️ ",be))):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"))))))),se&&a.default.createElement("div",{style:{position:"fixed",left:fe?"0":K?"10px":"".concat(we.x,"px"),top:fe?"0":K?"70px":"".concat(we.y,"px"),right:fe?"0":K?"10px":"auto",bottom:fe?"0":"auto",width:fe?"100vw":K?"calc(100vw - 20px)":ce?"350px":"".concat(ke.width,"px"),height:fe?"100vh":ce?"auto":K?"300px":"".concat(ke.height,"px"),background:"#FFFFFF",borderRadius:fe?"0":"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",zIndex:1e4,overflow:"hidden",display:"flex",flexDirection:"column",transition:Ie||Te?"none":"all 0.3s ease"}},a.default.createElement("div",{onMouseDown:K||fe?void 0:ft,style:{background:"linear-gradient(135deg, #4C4DDC 0%, #3A3BBD 100%)",color:"#FFFFFF",padding:K?"8px 10px":"10px 12px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:!K&&!fe&&(Ie?"grabbing":"grab"),userSelect:"none"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:K?"6px":"8px",flex:1,minWidth:0}},a.default.createElement("div",{style:{width:K?"6px":"8px",height:K?"6px":"8px",borderRadius:"50%",background:"#FF4444",animation:"pulse 2s infinite",flexShrink:0}}),a.default.createElement("span",{style:{fontSize:K?"11px":"13px",fontWeight:600,fontFamily:yt,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},"Video Call - ",(null==V?void 0:V.patientName)||"Patient")),a.default.createElement("div",{style:{display:"flex",gap:K?"4px":"6px",alignItems:"center",flexShrink:0}},!fe&&a.default.createElement("button",{onClick:ct,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:K?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:K?"28px":"32px",height:K?"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:ce?"Restore":"Minimize"},ce?a.default.createElement("svg",{width:K?"14":"16",height:K?"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:K?"14":"16",height:K?"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: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:K?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:K?"28px":"32px",height:K?"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?"Exit Fullscreen":"Fullscreen"},fe?a.default.createElement("svg",{width:K?"14":"16",height:K?"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:K?"14":"16",height:K?"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:pt,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:K?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:K?"28px":"32px",height:K?"28px":"32px",fontWeight:"bold",fontSize:K?"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"},"×"))),!ce&&a.default.createElement("div",{style:{flex:1,background:"#000000",position:"relative"}},a.default.createElement("iframe",{src:(()=>{if(!xe)return"";const e=String(B||"").replace(/\/?$/,"/");return console.log("${base}token=${callToken}","".concat(e,"token=").concat(xe)),"".concat(e,"token=").concat(xe)})(),style:{width:"100%",height:"100%",border:"none"},allow:"camera; microphone; display-capture; autoplay",allowFullScreen:!0,title:"Video Call"})),!K&&!fe&&!ce&&a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{onMouseDown:e=>gt("left",e),style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:"8px",height:"60px",cursor:"ew-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onMouseDown:e=>gt("right",e),style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:"8px",height:"60px",cursor:"ew-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onMouseDown:e=>gt("top",e),style:{position:"absolute",left:"50%",transform:"translateX(-50%)",top:0,width:"60px",height:"8px",cursor:"ns-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onMouseDown:e=>gt("bottom",e),style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:0,width:"60px",height:"8px",cursor:"ns-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:"4px",height:"30px",background:"rgba(76, 77, 220, 0.6)",borderRadius:"0 2px 2px 0",opacity:Te&&"left"===Ae?1:0,transition:"opacity 0.2s ease",pointerEvents:"none",zIndex:10002}}),a.default.createElement("div",{style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:"4px",height:"30px",background:"rgba(76, 77, 220, 0.6)",borderRadius:"2px 0 0 2px",opacity:Te&&"right"===Ae?1:0,transition:"opacity 0.2s ease",pointerEvents:"none",zIndex:10002}})),a.default.createElement("style",null,"\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n "))),a.default.createElement(b,null,ht)};let w=null;const S={showWidget:(e,t)=>{w||(w=document.createElement("div"),document.body.appendChild(w));const n=()=>a.default.createElement(a.default.Fragment,null,a.default.createElement(F,{config:e}));l.default.render(a.default.createElement(n,null),w)},closePopup:()=>{w&&(l.default.unmountComponentAtNode(w),w=null)}};window.BookingSDK=S,e.AppointmentPage=F,e.default=S,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),l=o(n);function i(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const r="https://afiyaapiqa.powermindinc.com",d="/appointment/V1/consultant/all-appointments",s="/notification/V1/consultation/online/initiate",p="dMtEGhak",c=6694,u="https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/",f=async function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=(e||"").toUpperCase();"INPROGRESS"===a&&(a="IN_PROGRESS");const l=o.apiBaseUrl||r,i=o.hospitalId||p,s=o.doctorId||c,u=o.token||"",f={hospitalId:i,doctorId:s,fromDate:t,toDate:n,statuses:a},m="".concat(l).concat(d),x=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);o.search=new URLSearchParams(t).toString();const a={method:"GET",headers:{"Content-Type":"application/json",Authorization:"".concat(n)}};return fetch(o,a).then(async e=>{const t=await e.json().catch(()=>({}));var n;return e.ok?t:{err:(null==t||null===(n=t.resultInfo)||void 0===n?void 0:n.message)||"Something went wrong!",status:e.status}}).catch(e=>(console.error("Fetch error:",e),{err:(null==e?void 0:e.message)||String(e)||"Network error"}))}(m,f,"PIH-Appointment-Widget",u);return x},m=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=(t.apiBaseUrl||r).replace(/\/$/,""),o="".concat(n).concat(s),a=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 l={"Content-Type":"application/json"};o&&(l.Authorization=o);const i={method:"POST",headers:l,body:JSON.stringify(t)};return fetch(a.toString(),i).then(async e=>{const t=await e.json().catch(()=>({}));var n;return e.ok?t:{err:(null==t||null===(n=t.resultInfo)||void 0===n?void 0:n.message)||"Something went wrong!",status:e.status}}).catch(e=>(console.error("Fetch error:",e),{err:e.message||"Network error"}))}(o,{patientId:String(e.patientId||""),primaryPatientId:String(e.primaryPatientId||e.patientId||""),hospitalId:t.hospitalId||p,doctorId:String(t.doctor_id||c),patientName:e.patientName||e.name||"",doctorName:e.doctorName||t.doctorName,appointmentId:String(e.id||e.appointmentId||e._id||"")},"PIH-Appointment-Widget",{},a)};const x="pih_appointment_idToken",g="pih_appointment_email",h="pih_appointment_appToken",y="pih_appointment_doctorId",E="pih_appointment_userName";class v extends t.Component{constructor(){super(...arguments),i(this,"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",{style:{fontFamily:'"Nunito", serif',background:"#F5F5F7",boxSizing:"border-box",minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",padding:"24px",textAlign:"center"}},a.default.createElement("div",{style:{maxWidth:"400px"}},a.default.createElement("div",{style:{fontSize:"48px",marginBottom:"16px"}},"⚠️"),a.default.createElement("h2",{style:{fontSize:"20px",fontWeight:700,color:"#1a1a1a",margin:"0 0 8px 0"}},"Something went wrong"),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0,lineHeight:1.5}},"Please refresh the page or try again later."))):this.props.children}}const b=e=>{let{config:n={}}=e;const o=n.apiBaseUrl||r,l=n.hospitalId||p,[i,d]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(x):null}catch(e){return null}}),[s,b]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(g):null}catch(e){return null}}),F=n.idToken||n.token||i,w=n.email||s;t.useEffect(()=>{try{if("undefined"==typeof localStorage)return;const e=n.idToken||n.token;if(e&&String(e).trim()){localStorage.getItem(x)!==e&&(k(null),I(null),D(null),localStorage.removeItem(h),localStorage.removeItem(y),localStorage.removeItem(E)),localStorage.setItem(x,e),d(e)}n.email&&String(n.email).trim()&&(localStorage.setItem(g,n.email),b(n.email))}catch(e){}},[n.idToken,n.token,n.email]);const[S,k]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(h):null}catch(e){return null}}),[C,I]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(y):null}catch(e){return null}}),[z,D]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(E):null}catch(e){return null}}),[W,T]=t.useState(()=>{try{if("undefined"==typeof localStorage)return!1;const e=localStorage.getItem(h),t=localStorage.getItem(x),n=localStorage.getItem(g);return!e&&!(!t||!n)}catch(e){return!1}}),[M,R]=t.useState(null),[A,j]=t.useState(!1),[N,B]=t.useState(0);t.useEffect(()=>{S&&W&&T(!1)},[S,W]),t.useEffect(()=>{S||(F&&w?(j(!1),R(e=>"Sign in required. Redirecting to home..."===e?null:e)):(R("Sign in required. Redirecting to home..."),j(!0)))},[S,F,w]),t.useEffect(()=>{if(!A)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)},[A,n.homeUrl]),t.useEffect(()=>{if(!W)return;const e=setTimeout(()=>{R("Request timed out. Please try again."),T(!1)},3e4);return()=>clearTimeout(e)},[W]);const L=n.joinCallUrl||u;S&&String(L||"").replace(/\/?$/,"/");const H=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(e){return{}}}(F),P=z||H.name||H.sub||"User",O=()=>(new Date).toISOString().split("T")[0],[Y,_]=t.useState("upcoming"),[U,V]=t.useState([]),[q,X]=t.useState(null),[$,G]=t.useState(!1),[J,K]=t.useState(null),[Q,Z]=t.useState(window.innerWidth<768),[ee,te]=t.useState("today"),[ne,oe]=t.useState("today"),[ae,le]=t.useState(!1),[ie,re]=t.useState("asc"),[de,se]=t.useState(""),[pe,ce]=t.useState(!1),[ue,fe]=t.useState(!1),[me,xe]=t.useState(!1),[ge,he]=t.useState(null),[ye,Ee]=t.useState(null),[ve,be]=t.useState(!1),[Fe,we]=t.useState(null),[Se,ke]=t.useState({x:window.innerWidth-550,y:80}),[Ce,Ie]=t.useState({width:550,height:450}),[ze,De]=t.useState(!1),[We,Te]=t.useState({x:0,y:0}),[Me,Re]=t.useState(!1),[Ae,je]=t.useState(null),[Ne,Be]=t.useState({x:0,y:0,width:0,height:0});t.useState(!1);const[Le,He]=t.useState(1),Pe=U.filter(e=>{if(!de.trim())return!0;const t=de.toLowerCase(),n=(e.patientName||"").toLowerCase(),o=String(e.patientId||"").toLowerCase();return n.includes(t)||o.includes(t)}),Oe=20*(Le-1),Ye=Oe+20,_e=Pe.slice(Oe,Ye),Ue=Math.ceil(Pe.length/20),Ve=Pe.length,[qe,Xe]=t.useState(O()),[$e,Ge]=t.useState(O()),[Je,Ke]=t.useState(),[Qe,Ze]=t.useState(),et=e=>(null==e?void 0:e.id)||(null==e?void 0:e._id)||(null==e?void 0:e.appointmentId)||(null==e?void 0:e.patientId)||JSON.stringify(e),tt=e=>null!=e&&e.image?e.image:null,nt=e=>e?e.charAt(0).toUpperCase():"?",ot=e=>{if(!e)return"#4C4DDC";const t=["#4C4DDC","#1CC3CE","#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F"];return t[e.charCodeAt(0)%t.length]},at=()=>{const e="asc"===ie?"desc":"asc";re(e);const t=[...U].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});V(t),He(1),t.length>0&&X(t[0])},lt=t.useCallback(async()=>{if(!S)return;const e=C||c;G(!0),K(null);try{const t={apiBaseUrl:o,hospitalId:l,doctorId:e,token:S},n=await f(Y,qe,$e,t);if(401===n.status||403===n.status){try{"undefined"!=typeof localStorage&&(localStorage.removeItem(h),localStorage.removeItem(y),localStorage.removeItem(E))}catch(e){}return k(null),I(null),D(null),B(e=>e+1),void K("Session expired. Re-authenticating...")}if(n.err)return void K(String(n.err||"Failed to fetch appointments"));const a=n.data||n.appointments||n||[];V(Array.isArray(a)?a:[]),Array.isArray(a)&&a.length>0?X(a[0]):X(null)}catch(e){console.error("Error fetching appointments:",e),K(e.message||"Failed to fetch appointments")}finally{G(!1)}},[Y,qe,$e,o,l,C,S]),it=e=>{X(e)},rt=async()=>{if(q&&S){be(!0),we(null);try{var e;const t={apiBaseUrl:o,hospitalId:l,doctorId:C||c,doctorName:z||P,appToken:S};console.log(q,"selectedAppointment"),console.log(t,"callConfig");const a=await m(q,t);if(401===a.status||403===a.status)return we("Session expired. Please try again."),void be(!1);if(a.err||null===(e=a.data)||void 0===e||!e.token)return we(String(a.err||"Failed to initiate call")),void be(!1);const i=n.joinCallUrl||u,r=a.data.token?String(i||"").replace(/\/?$/,"/")+a.data.token:"";console.log("joinCallUrl",r),he(a.data.token),Ee(r||""),ce(!0),fe(!1),xe(!1)}catch(e){we(e.message||"Failed to initiate call")}finally{be(!1)}}},dt=()=>{ce(!1),fe(!1),xe(!1),he(null),Ee(null),we(null)},st=()=>{me&&xe(!1),fe(!ue)},pt=()=>{ue&&fe(!1),xe(!me)},ct=e=>{De(!0);const t=e.currentTarget.getBoundingClientRect();Te({x:e.clientX-t.left,y:e.clientY-t.top})},ut=t.useCallback(e=>{if(!me)if(ze){const t=e.clientX-We.x,n=e.clientY-We.y,o=window.innerWidth-Ce.width,a=window.innerHeight-Ce.height;ke({x:Math.max(0,Math.min(t,o)),y:Math.max(0,Math.min(n,a))})}else if(Me){const t=e.clientX-Ne.x,n=e.clientY-Ne.y;let o=Ne.width,a=Ne.height,l=Ne.posX,i=Ne.posY;const r=300,d=250,s=window.innerWidth-40,p=window.innerHeight-100;if("right"===Ae)o=Math.min(Math.max(Ne.width+t,r),s),l+o>window.innerWidth&&(o=window.innerWidth-l);else if("left"===Ae){const e=Math.min(Math.max(Ne.width-t,r),s),n=e-Ne.width;o=e,l=Math.max(0,Ne.posX-n),0===l&&(o=Ne.posX+Ne.width)}else if("bottom"===Ae)a=Math.min(Math.max(Ne.height+n,d),p),i+a>window.innerHeight&&(a=window.innerHeight-i);else if("top"===Ae){const e=Math.min(Math.max(Ne.height-n,d),p),t=e-Ne.height;a=e,i=Math.max(0,Ne.posY-t),0===i&&(a=Ne.posY+Ne.height)}Ie({width:o,height:a}),ke({x:l,y:i})}},[ze,Me,We,Ae,Ne,Se,Ce,me]),ft=()=>{De(!1),Re(!1),je(null)},mt=(e,t)=>{t.preventDefault(),t.stopPropagation(),Re(!0),je(e),Be({x:t.clientX,y:t.clientY,width:Ce.width,height:Ce.height,posX:Se.x,posY:Se.y})};t.useEffect(()=>{if(ze||Me)return window.addEventListener("mousemove",ut),window.addEventListener("mouseup",ft),()=>{window.removeEventListener("mousemove",ut),window.removeEventListener("mouseup",ft)}},[ze,Me,ut]),t.useEffect(()=>{if(!pe||me)return;const e=()=>{if(!(window.innerWidth<768)){const e=ue?350:Ce.width,t=ue?60:Ce.height,n=window.innerWidth-40,o=window.innerHeight-100,a=Math.min(e,n),l=Math.min(t,o);a===Ce.width&&l===Ce.height||Ie({width:a,height:l});const i=window.innerWidth-a-20,r=window.innerHeight-l-20;ke(e=>({x:Math.min(e.x,i),y:Math.min(e.y,r)}))}};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[pe,ue,me,Ce]),t.useEffect(()=>{if(!(F&&w&&(!S||N>0)))return;let e=!1;return T(!0),R(null),(async(e,t,n,o)=>{const a=e.replace(/\/$/,""),l="".concat(a,"/um/user/V1/sso/login?hospitalId=").concat(encodeURIComponent(t)),i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({idToken:n,email:o})};return console.log("[getTokenFromSso] request",{url:l,body:{idToken:n?n.slice(0,50)+"...":null,email:o}}),fetch(l,i).then(e=>(console.log("[getTokenFromSso] response status",e.status,e.statusText),e.ok?e.json().then(e=>{var t;return console.log("[getTokenFromSso] success",{hasData:!!e,dataKeys:e?Object.keys(e):[],hasAccessToken:!(null==e||null===(t=e.data)||void 0===t||!t.access_token)}),e}):e.json().then(t=>{var n;const o=(null==t||null===(n=t.resultInfo)||void 0===n?void 0:n.message)||"SSO login failed";return console.log("[getTokenFromSso] error body",t),{err:o,status:e.status}}).catch(()=>({err:"Something went wrong!",status:e.status})))).catch(e=>(console.error("[getTokenFromSso] catch",e),{err:e.message||"Network error"}))})(o,l,F,w).then(t=>{if(e)return;const n=function(e){var t,n,o,a,l,i;return!e||e.err?null:null!==(t=null!==(n=null!==(o=null!==(a=null===(l=e.data)||void 0===l?void 0:l.access_token)&&void 0!==a?a:null===(i=e.data)||void 0===i?void 0:i.token)&&void 0!==o?o:e.token)&&void 0!==n?n:e.accessToken)&&void 0!==t?t:null}(t);if(400===t.status)return R(t.err||"Invalid request. Redirecting to home..."),T(!1),void j(!0);if(t.err||!n){R(String(t.err||"Failed to get token")),k(null),I(null),D(null);try{"undefined"!=typeof localStorage&&(localStorage.removeItem(h),localStorage.removeItem(y),localStorage.removeItem(E))}catch(e){}}else{const e=function(e){var t,n;if(null==e||!e.data)return null;const o=null!==(t=null!==(n=e.data.doctor_id)&&void 0!==n?n:e.data.doctorId)&&void 0!==t?t:null;return null!=o?String(o):null}(t),o=function(e){var t,n,o;if(null==e||!e.data)return null;const a=null!==(t=null!==(n=null!==(o=e.data.name)&&void 0!==o?o:e.data.doctor_name)&&void 0!==n?n:e.data.userName)&&void 0!==t?t:null;return null!=a?String(a):null}(t);k(n),I(e),D(o),R(null),j(!1);try{"undefined"!=typeof localStorage&&(localStorage.setItem(h,n),e&&localStorage.setItem(y,e),o&&localStorage.setItem(E,o))}catch(e){}}}).catch(()=>{}).finally(()=>{e||T(!1)}),()=>{e=!0}},[o,l,F,w,N]),t.useEffect(()=>{He(1)},[Y,ee,qe,$e,de]),t.useEffect(()=>{!W&&S&<()},[lt,S,W]),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=()=>{Z(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=>{!ae||e.target.closest("button")||e.target.closest('input[type="date"]')||le(!1)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[ae]);let xt='"Nunito", serif';const gt=M||!S&&(!F||!w),ht=M||"Sign in required. Redirecting to home...";let yt;return yt=W&&F&&w?a.default.createElement("div",{style:{fontFamily:xt,background:"#F5F5F7",boxSizing:"border-box",height:"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",{style:{fontFamily:xt,background:"#F5F5F7",boxSizing:"border-box",height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"}},a.default.createElement("div",{style:{background:"#FFFFFF",padding:Q?"10px 12px":"12px 24px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #E5E5E5",flexWrap:"nowrap",gap:Q?"8px":"0"}},a.default.createElement("div",{style:{position:"relative",width:Q?"calc(100% - 90px)":"480px",maxWidth:Q?"none":"480px"}},a.default.createElement("input",{type:"text",placeholder:"Search by patient name or ID",value:de,onChange:e=>se(e.target.value),style:{width:"100%",padding:Q?"8px 32px 8px 10px":"8px 36px 8px 14px",border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:Q?"12px":"13px",fontFamily:xt,background:"#FFFFFF",outline:"none",boxSizing:"border-box"}}),de&&a.default.createElement("button",{onClick:()=>se(""),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:Q?"12px":"16px 24px",flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}},a.default.createElement("div",{style:{marginBottom:Q?"10px":"14px"}},a.default.createElement("h1",{style:{fontSize:Q?"18px":"22px",fontWeight:700,color:"#1a1a1a",margin:"0 0 2px 0"}},"Tele Consultation"),a.default.createElement("p",{style:{fontSize:Q?"11px":"12px",color:"#999",margin:0}},"Displaying All Tele Consultation Appointments")),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:Q?"flex-start":"center",marginBottom:Q?"10px":"14px",flexDirection:Q?"column":"row",gap:Q?"12px":"0"}},a.default.createElement("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",width:Q?"100%":"auto"}},a.default.createElement("button",{onClick:()=>_("upcoming"),style:{background:"upcoming"===Y?"#4C4DDC":"#FFFFFF",padding:Q?"8px 10px":"9px 16px",border:"upcoming"===Y?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:Q?"10px":"13px",color:"upcoming"===Y?"white":"#555555",fontWeight:600,fontFamily:xt,cursor:"pointer",flex:Q?"1 1 auto":"none",minWidth:Q?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Upcoming Appointments"),a.default.createElement("button",{onClick:()=>_("completed"),style:{background:"completed"===Y?"#4C4DDC":"#FFFFFF",padding:Q?"8px 10px":"9px 16px",border:"completed"===Y?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:Q?"10px":"13px",color:"completed"===Y?"white":"#555555",fontWeight:600,fontFamily:xt,cursor:"pointer",flex:Q?"1 1 auto":"none",minWidth:Q?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Completed Appointments"),a.default.createElement("button",{onClick:()=>_("cancelled"),style:{background:"cancelled"===Y?"#4C4DDC":"#FFFFFF",padding:Q?"8px 10px":"9px 16px",border:"cancelled"===Y?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:Q?"10px":"13px",color:"cancelled"===Y?"white":"#555555",fontWeight:600,fontFamily:xt,cursor:"pointer",flex:Q?"1 1 auto":"none",minWidth:Q?"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:Q?"flex-start":"flex-end"}},a.default.createElement("button",{onClick:()=>{ae||(Ke(qe),Ze($e),oe(ee)),le(!ae)},style:{padding:"8px 12px",fontFamily:xt,fontWeight:600,border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:Q?"11px":"13px",color:"#1a1a1a",background:"#FFFFFF",display:"flex",alignItems:"center",gap:Q?"4px":"6px",cursor:"pointer",flex:"none",minWidth:Q?"100px":"auto",justifyContent:"center"}},a.default.createElement("svg",{width:Q?"12":"14",height:Q?"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(ee){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 Q?"Custom":"".concat(qe," to ").concat($e)}})()),a.default.createElement("svg",{width:Q?"8":"10",height:Q?"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"}))),ae&&a.default.createElement("div",{style:{position:"absolute",top:"100%",right:Q?"auto":0,left:Q?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:Q?"280px":"240px",width:Q?"calc(100vw - 24px)":"auto",maxWidth:Q?"calc(100vw - 24px)":"280px"}},a.default.createElement("div",{style:{marginBottom:"custom"===ne?"12px":"0"}},["thisMonth","today","tomorrow","currentWeek","currentYear","custom"].map(e=>a.default.createElement("button",{key:e,onClick:()=>{if(oe(e),"custom"!==e){const t=(e=>{const t=new Date;let n,o;switch(e){case"today":default:n=o=O();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),l=new Date(t),i=t.getDay(),r=0===i?-6:1-i;a.setDate(t.getDate()+r),l.setDate(a.getDate()+6),n=a.toISOString().split("T")[0],o=l.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="".concat(t.getFullYear(),"-01-01"),o="".concat(t.getFullYear(),"-12-31")}return{from:n,to:o}})(e);te(e),Xe(t.from),Ge(t.to),Ke(t.from),Ze(t.to),le(!1)}else Ke(""),Ze("")},style:{width:"100%",padding:"10px 12px",background:ne===e?"#E8EEF4":"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:xt,cursor:"pointer",textAlign:"left",fontWeight:ne===e?600:400,color:ne===e?"#4C4DDC":"#1a1a1a",marginBottom:"4px",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.2s ease"},onMouseEnter:t=>{ne!==e&&(t.target.style.background="#F5F5F5")},onMouseLeave:t=>{ne!==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]),ne===e&&a.default.createElement("span",{style:{color:"#4C4DDC",fontSize:"16px"}},"✓")))),"custom"===ne&&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:Je,onChange:e=>Ke(e.target.value),placeholder:"Start Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:xt,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{marginBottom:"12px"}},a.default.createElement("input",{type:"date",value:Qe,onChange:e=>Ze(e.target.value),placeholder:"End Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:xt,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{display:"flex",gap:"8px"}},a.default.createElement("button",{onClick:()=>{oe(ee),Ke(qe),Ze($e),le(!1)},style:{flex:1,padding:"10px 12px",background:"#FFFFFF",color:"#4C4DDC",border:"1px solid #4C4DDC",borderRadius:"4px",fontSize:"13px",fontFamily:xt,fontWeight:600,cursor:"pointer"}},"Cancel"),a.default.createElement("button",{onClick:()=>{Je&&Qe&&(te("custom"),Xe(Je),Ge(Qe),le(!1))},style:{flex:1,padding:"10px 12px",background:"#4C4DDC",color:"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:xt,fontWeight:600,cursor:"pointer"}},"Submit")))))),a.default.createElement("div",{style:{display:"flex",flexDirection:Q?"column":"row",gap:Q?"12px":"14px",flex:1,minHeight:0,overflow:Q?"auto":"hidden"}},a.default.createElement("div",{style:{flex:Q?"none":"1 1 65%",width:Q?"100%":"auto",display:"flex",flexDirection:"column",minHeight:Q?"400px":"auto"}},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",height:Q?"auto":"100%"}},a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:Q?"12px 14px":"14px 18px",borderBottom:"1px solid #F1F1F1"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:Q?"6px":"8px"}},a.default.createElement("span",{style:{fontSize:Q?"14px":"15px",fontWeight:700,color:"#1a1a1a"}},"Appointments"),a.default.createElement("span",{style:{background:"#4C4DDC",color:"#fff",fontSize:Q?"10px":"11px",fontWeight:600,padding:Q?"2px 7px":"3px 8px",borderRadius:"12px"}},Ve))),a.default.createElement("div",{className:"appointments-header-grid",style:{display:"grid",gridTemplateColumns:Q?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:Q?"8px":"12px",padding:Q?"8px 12px":"10px 18px",background:"#F5F5F5",fontSize:Q?"10px":"12px",fontWeight:600,color:"#666"}},a.default.createElement("div",null,"Patients name"),!Q&&a.default.createElement("div",null,"Patient ID"),a.default.createElement("div",{onClick:at,style:{display:"flex",alignItems:"center",gap:"3px",cursor:"pointer",userSelect:"none"}},"Date",a.default.createElement("span",{style:{opacity:.7,fontSize:"10px"}},"asc"===ie?"▲":"▼")),!Q&&a.default.createElement("div",null,"Slot"),!Q&&a.default.createElement("div",null,"Doctor")),a.default.createElement("div",{style:{overflow:"auto",flex:1}},W?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...")):$?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...")):J?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"}},J),a.default.createElement("button",{onClick:lt,style:{marginTop:"16px",padding:"8px 16px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontFamily:xt}},"Retry")):0===_e.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"}},de?'No appointments found for "'.concat(de,'"'):"No appointments found"),de&&a.default.createElement("button",{onClick:()=>se(""),style:{marginTop:"12px",padding:"6px 12px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px",fontFamily:xt}},"Clear Search")):_e.map(e=>a.default.createElement("div",{key:et(e),role:"button",tabIndex:0,onClick:()=>it(e),onKeyDown:t=>"Enter"===t.key&&it(e),className:"appointments-grid",style:{display:"grid",gridTemplateColumns:Q?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:Q?"8px":"12px",padding:Q?"10px 12px":"12px 18px",background:et(q)===et(e)?"#E8EEF4":"#FFFFFF",borderTop:"1px solid #F1F1F1",alignItems:"center",cursor:"pointer",fontSize:Q?"11px":"13px"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:Q?"8px":"10px"}},tt(e)?a.default.createElement("img",{src:e.image,alt:"",style:{width:Q?"32px":"36px",height:Q?"32px":"36px",borderRadius:"50%",objectFit:"cover"}}):a.default.createElement("div",{style:{width:Q?"32px":"36px",height:Q?"32px":"36px",borderRadius:"50%",background:ot(e.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:600,fontSize:Q?"14px":"16px"}},nt(e.patientName)),a.default.createElement("div",null,a.default.createElement("div",{style:{fontWeight:600,color:"#1a1a1a",fontSize:Q?"11px":"13px"}},e.patientName),a.default.createElement("div",{style:{fontSize:Q?"9px":"11px",color:"#888"}},e.email))),!Q&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.patientId),a.default.createElement("div",{style:{color:"#555",fontSize:Q?"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:Q?"9px":"11px",color:"#888"}},n[1].trim())):a.default.createElement("div",null,t)})()),!Q&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.appointmentTime||"-"),!Q&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.doctorName||e.doctor||"-")))),!$&&!J&&_e.length>0&&a.default.createElement("div",{style:{padding:Q?"12px 14px":"14px 18px",borderTop:"1px solid #F1F1F1",display:"flex",justifyContent:"space-between",alignItems:"center",background:"#FFFFFF",flexWrap:Q?"wrap":"nowrap",gap:Q?"10px":"0"}},a.default.createElement("div",{style:{fontSize:Q?"11px":"12px",color:"#666"}},"Showing page ",Le," of ",Ue," (",Ve," total)"),a.default.createElement("div",{style:{display:"flex",gap:"6px",alignItems:"center"}},a.default.createElement("button",{onClick:()=>He(e=>Math.max(1,e-1)),disabled:1===Le,style:{padding:Q?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:1===Le?"#F5F5F5":"#FFFFFF",color:1===Le?"#999":"#1a1a1a",fontSize:Q?"11px":"12px",fontFamily:xt,fontWeight:600,cursor:1===Le?"not-allowed":"pointer",opacity:1===Le?.5:1}},"Previous"),a.default.createElement("div",{style:{display:"flex",gap:"4px"}},[...Array(Math.min(5,Ue))].map((e,t)=>{let n;return n=Ue<=5||Le<=3?t+1:Le>=Ue-2?Ue-4+t:Le-2+t,a.default.createElement("button",{key:n,onClick:()=>He(n),style:{padding:Q?"6px 10px":"6px 12px",border:Le===n?"none":"1px solid #E5E5E5",borderRadius:"4px",background:Le===n?"#4C4DDC":"#FFFFFF",color:Le===n?"#FFFFFF":"#1a1a1a",fontSize:Q?"11px":"12px",fontFamily:xt,fontWeight:600,cursor:"pointer",minWidth:Q?"32px":"36px"}},n)})),a.default.createElement("button",{onClick:()=>He(e=>Math.min(Ue,e+1)),disabled:Le===Ue,style:{padding:Q?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:Le===Ue?"#F5F5F5":"#FFFFFF",color:Le===Ue?"#999":"#1a1a1a",fontSize:Q?"11px":"12px",fontFamily:xt,fontWeight:600,cursor:Le===Ue?"not-allowed":"pointer",opacity:Le===Ue?.5:1}},"Next"))))),a.default.createElement("div",{style:{flex:Q?"none":"1 1 35%",width:Q?"100%":"auto",display:q||!Q?"flex":"none",flexDirection:"column",minHeight:"auto"}},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",height:Q?"auto":"100%"}},q?a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:Q?"12px 14px":"16px 18px",background:"#E8EEF4",borderBottom:"1px solid #E5E5E5"}},a.default.createElement("div",null,a.default.createElement("div",{style:{color:"#002668",fontSize:Q?"14px":"16px",fontWeight:"700"}},q.patientName||"N/A"),a.default.createElement("div",{style:{color:"#002668",fontSize:Q?"11px":"13px"}},q.patientId||q.mrn||"N/A")),a.default.createElement("div",null,tt(q)?a.default.createElement("img",{style:{width:Q?"36px":"44px",height:Q?"36px":"44px",borderRadius:"50%",objectFit:"cover"},src:q.image,alt:q.patientName}):a.default.createElement("div",{style:{width:Q?"36px":"44px",height:Q?"36px":"44px",borderRadius:"50%",background:ot(q.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:700,fontSize:Q?"16px":"20px"}},nt(q.patientName)))),a.default.createElement("div",{style:{padding:Q?"12px 14px":"14px 18px",gap:Q?"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:Q?"10px":"11px",color:"#888",marginBottom:"3px"}},"Speciality"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:Q?"12px":"13px"}},(null==q?void 0:q.specialisation)||(null==q?void 0:q.speciality)||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:Q?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Type"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:Q?"12px":"13px"}},(null==q?void 0:q.type)||(null==q?void 0:q.appointmentType)||"Online"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:Q?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Date"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:Q?"12px":"13px"}},(null==q?void 0:q.date)||(null==q?void 0:q.appointmentDate)||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:Q?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Time"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:Q?"12px":"13px"}},(null==q?void 0:q.time)||(null==q?void 0:q.appointmentTime)||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:Q?"10px":"11px",color:"#888",marginBottom:"3px"}},"Doctor"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:Q?"12px":"13px"}},(null==q?void 0:q.doctor)||(null==q?void 0:q.doctorName)||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:Q?"10px":"11px",color:"#888",marginBottom:"3px"}},"Hospital"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:Q?"12px":"13px"}},(null==q?void 0:q.hospital)||(null==q?void 0:q.hospitalName)||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:Q?"10px":"11px",color:"#888",marginBottom:"3px"}},"Reason for Appointment"),a.default.createElement("div",{style:{fontWeight:"600",fontSize:Q?"11px":"12px",lineHeight:"1.4"}},(null==q?void 0:q.reason)||(null==q?void 0:q.reasonForAppointment)||"No reason provided"))),a.default.createElement("div",{style:{display:"flex",flexDirection:Q?"column":"row",gap:"6px",marginTop:"10px"}},a.default.createElement("button",{type:"button",onClick:rt,disabled:ve,style:{flex:1,background:ve?"#99e4e8":"#1CC3CE",color:"#FFFFFF",border:"1px solid #1CC3CE",borderRadius:"6px",padding:Q?"10px 8px":"8px 6px",fontFamily:xt,fontWeight:600,fontSize:Q?"11px":"12px",cursor:ve?"not-allowed":"pointer"}},ve?"Connecting...":"Join Call >")),Fe&&a.default.createElement("div",{style:{fontSize:"11px",color:"#e53935",marginTop:"6px",textAlign:"center",width:"100%"}},"⚠️ ",Fe))):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"))))))),pe&&a.default.createElement("div",{style:{position:"fixed",left:me?"0":Q?"10px":"".concat(Se.x,"px"),top:me?"0":Q?"70px":"".concat(Se.y,"px"),right:me?"0":Q?"10px":"auto",bottom:me?"0":"auto",width:me?"100vw":Q?"calc(100vw - 20px)":ue?"350px":"".concat(Ce.width,"px"),height:me?"100vh":ue?"auto":Q?"300px":"".concat(Ce.height,"px"),background:"#FFFFFF",borderRadius:me?"0":"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",zIndex:1e4,overflow:"hidden",display:"flex",flexDirection:"column",transition:ze||Me?"none":"all 0.3s ease"}},a.default.createElement("div",{onMouseDown:Q||me?void 0:ct,style:{background:"linear-gradient(135deg, #4C4DDC 0%, #3A3BBD 100%)",color:"#FFFFFF",padding:Q?"8px 10px":"10px 12px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:!Q&&!me&&(ze?"grabbing":"grab"),userSelect:"none"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:Q?"6px":"8px",flex:1,minWidth:0}},a.default.createElement("div",{style:{width:Q?"6px":"8px",height:Q?"6px":"8px",borderRadius:"50%",background:"#FF4444",animation:"pulse 2s infinite",flexShrink:0}}),a.default.createElement("span",{style:{fontSize:Q?"11px":"13px",fontWeight:600,fontFamily:xt,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},"Video Call - ",(null==q?void 0:q.patientName)||"Patient")),a.default.createElement("div",{style:{display:"flex",gap:Q?"4px":"6px",alignItems:"center",flexShrink:0}},!me&&a.default.createElement("button",{onClick:st,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:Q?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:Q?"28px":"32px",height:Q?"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:ue?"Restore":"Minimize"},ue?a.default.createElement("svg",{width:Q?"14":"16",height:Q?"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:Q?"14":"16",height:Q?"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:pt,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:Q?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:Q?"28px":"32px",height:Q?"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:me?"Exit Fullscreen":"Fullscreen"},me?a.default.createElement("svg",{width:Q?"14":"16",height:Q?"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:Q?"14":"16",height:Q?"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:dt,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:Q?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:Q?"28px":"32px",height:Q?"28px":"32px",fontWeight:"bold",fontSize:Q?"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"},"×"))),!ue&&a.default.createElement("div",{style:{flex:1,background:"#000000",position:"relative"}},a.default.createElement("iframe",{src:(()=>{if(!ge)return"";const e=String(L||"").replace(/\/?$/,"/");return console.log("${base}token=${callToken}","".concat(e,"token=").concat(ge)),"".concat(e,"token=").concat(ge)})(),style:{width:"100%",height:"100%",border:"none"},allow:"camera; microphone; display-capture; autoplay",allowFullScreen:!0,title:"Video Call"})),!Q&&!me&&!ue&&a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{onMouseDown:e=>mt("left",e),style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:"8px",height:"60px",cursor:"ew-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onMouseDown:e=>mt("right",e),style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:"8px",height:"60px",cursor:"ew-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onMouseDown:e=>mt("top",e),style:{position:"absolute",left:"50%",transform:"translateX(-50%)",top:0,width:"60px",height:"8px",cursor:"ns-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onMouseDown:e=>mt("bottom",e),style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:0,width:"60px",height:"8px",cursor:"ns-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:"4px",height:"30px",background:"rgba(76, 77, 220, 0.6)",borderRadius:"0 2px 2px 0",opacity:Me&&"left"===Ae?1:0,transition:"opacity 0.2s ease",pointerEvents:"none",zIndex:10002}}),a.default.createElement("div",{style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:"4px",height:"30px",background:"rgba(76, 77, 220, 0.6)",borderRadius:"2px 0 0 2px",opacity:Me&&"right"===Ae?1:0,transition:"opacity 0.2s ease",pointerEvents:"none",zIndex:10002}})),a.default.createElement("style",null,"\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n "))),gt&&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:xt,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"}},M?"Not authorised":"Sign in required"),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0,lineHeight:1.5}},ht),a.default.createElement("p",{style:{fontSize:"13px",color:"#999",marginTop:"16px",marginBottom:0}},"Redirecting to login...")))),a.default.createElement(v,null,yt)};let F=null;const w={showWidget:(e,t)=>{F||(F=document.createElement("div"),document.body.appendChild(F));const n=()=>a.default.createElement(a.default.Fragment,null,a.default.createElement(b,{config:e}));l.default.render(a.default.createElement(n,null),F)},closePopup:()=>{F&&(l.default.unmountComponentAtNode(F),F=null)}};window.BookingSDK=w,e.AppointmentPage=b,e.default=w,Object.defineProperty(e,"__esModule",{value:!0})});
|
package/package.json
CHANGED
|
@@ -167,6 +167,7 @@ const AppointmentPage = ({ config = {}}) => {
|
|
|
167
167
|
}
|
|
168
168
|
});
|
|
169
169
|
const [tokenError, setTokenError] = useState(null);
|
|
170
|
+
const [redirectToHome, setRedirectToHome] = useState(false);
|
|
170
171
|
const [refreshLoginTrigger, setRefreshLoginTrigger] = useState(0);
|
|
171
172
|
|
|
172
173
|
// When we have appToken (e.g. from localStorage after refresh), never show loading — show main UI
|
|
@@ -174,6 +175,29 @@ const AppointmentPage = ({ config = {}}) => {
|
|
|
174
175
|
if (appToken && tokenLoading) setTokenLoading(false);
|
|
175
176
|
}, [appToken, tokenLoading]);
|
|
176
177
|
|
|
178
|
+
// No credentials: show error and auto-redirect to home
|
|
179
|
+
useEffect(() => {
|
|
180
|
+
if (appToken) return;
|
|
181
|
+
if (!idToken || !email) {
|
|
182
|
+
setTokenError("Sign in required. Redirecting to home...");
|
|
183
|
+
setRedirectToHome(true);
|
|
184
|
+
} else {
|
|
185
|
+
setRedirectToHome(false);
|
|
186
|
+
setTokenError((prev) => (prev === "Sign in required. Redirecting to home..." ? null : prev));
|
|
187
|
+
}
|
|
188
|
+
}, [appToken, idToken, email]);
|
|
189
|
+
|
|
190
|
+
// Auto-redirect to home when error popup is shown (no credentials or 400)
|
|
191
|
+
useEffect(() => {
|
|
192
|
+
if (!redirectToHome) return;
|
|
193
|
+
const homeUrl = config.homeUrl || WEB_URL || "";
|
|
194
|
+
if (!homeUrl || typeof window === "undefined") return;
|
|
195
|
+
const t = setTimeout(() => {
|
|
196
|
+
window.location.href = homeUrl;
|
|
197
|
+
}, 2500);
|
|
198
|
+
return () => clearTimeout(t);
|
|
199
|
+
}, [redirectToHome, config.homeUrl]);
|
|
200
|
+
|
|
177
201
|
// Timeout so we never show "Checking authorisation..." forever (no blank-like infinite loading)
|
|
178
202
|
useEffect(() => {
|
|
179
203
|
if (!tokenLoading) return;
|
|
@@ -663,16 +687,10 @@ const AppointmentPage = ({ config = {}}) => {
|
|
|
663
687
|
if (cancelled) return;
|
|
664
688
|
const token = extractAppToken(response);
|
|
665
689
|
if (response.status === 400) {
|
|
666
|
-
// Login API returned 400 — show error
|
|
667
|
-
|
|
668
|
-
setTokenError(message);
|
|
690
|
+
// Login API returned 400 — show error popup and auto-redirect to home
|
|
691
|
+
setTokenError(response.err || "Invalid request. Redirecting to home...");
|
|
669
692
|
setTokenLoading(false);
|
|
670
|
-
|
|
671
|
-
if (homeUrl && typeof window !== "undefined") {
|
|
672
|
-
setTimeout(() => {
|
|
673
|
-
window.location.href = homeUrl;
|
|
674
|
-
}, 3000);
|
|
675
|
-
}
|
|
693
|
+
setRedirectToHome(true);
|
|
676
694
|
return;
|
|
677
695
|
}
|
|
678
696
|
if (response.err || !token) {
|
|
@@ -694,6 +712,7 @@ const AppointmentPage = ({ config = {}}) => {
|
|
|
694
712
|
setDoctorIdFromLogin(doctorId);
|
|
695
713
|
setUserName(name);
|
|
696
714
|
setTokenError(null);
|
|
715
|
+
setRedirectToHome(false);
|
|
697
716
|
try {
|
|
698
717
|
if (typeof localStorage !== "undefined") {
|
|
699
718
|
localStorage.setItem(STORAGE_KEY_APP_TOKEN, token);
|
|
@@ -789,47 +808,11 @@ const AppointmentPage = ({ config = {}}) => {
|
|
|
789
808
|
|
|
790
809
|
let fontFamily = '"Nunito", serif';
|
|
791
810
|
|
|
792
|
-
//
|
|
811
|
+
// Error as popup overlay (main page stays in background); auto-redirect to home
|
|
812
|
+
const showAuthError = tokenError || (!appToken && (!idToken || !email));
|
|
813
|
+
const authErrorMessage = tokenError || "Sign in required. Redirecting to home...";
|
|
793
814
|
let content;
|
|
794
|
-
if (
|
|
795
|
-
content = (
|
|
796
|
-
<div
|
|
797
|
-
style={{
|
|
798
|
-
fontFamily,
|
|
799
|
-
background: "#F5F5F7",
|
|
800
|
-
boxSizing: "border-box",
|
|
801
|
-
height: "100vh",
|
|
802
|
-
display: "flex",
|
|
803
|
-
flexDirection: "column",
|
|
804
|
-
alignItems: "center",
|
|
805
|
-
justifyContent: "center",
|
|
806
|
-
padding: "24px",
|
|
807
|
-
textAlign: "center",
|
|
808
|
-
}}
|
|
809
|
-
>
|
|
810
|
-
<div
|
|
811
|
-
style={{
|
|
812
|
-
maxWidth: "400px",
|
|
813
|
-
padding: "32px 24px",
|
|
814
|
-
background: "#FFFFFF",
|
|
815
|
-
borderRadius: "12px",
|
|
816
|
-
boxShadow: "0 4px 20px rgba(0,0,0,0.08)",
|
|
817
|
-
}}
|
|
818
|
-
>
|
|
819
|
-
<div style={{ fontSize: "48px", marginBottom: "16px" }}>🔒</div>
|
|
820
|
-
<h2 style={{ fontSize: "20px", fontWeight: 700, color: "#1a1a1a", margin: "0 0 8px 0" }}>
|
|
821
|
-
Not authorised
|
|
822
|
-
</h2>
|
|
823
|
-
<p style={{ fontSize: "14px", color: "#666", margin: 0, lineHeight: 1.5 }}>
|
|
824
|
-
{tokenError}
|
|
825
|
-
</p>
|
|
826
|
-
<p style={{ fontSize: "13px", color: "#999", marginTop: "16px", marginBottom: 0 }}>
|
|
827
|
-
You are not authorised to use this service. Please sign in again or contact support.
|
|
828
|
-
</p>
|
|
829
|
-
</div>
|
|
830
|
-
</div>
|
|
831
|
-
);
|
|
832
|
-
} else if (tokenLoading && idToken && email) {
|
|
815
|
+
if (tokenLoading && idToken && email) {
|
|
833
816
|
// While checking token (SSO in progress), show a simple loading state instead of the full UI
|
|
834
817
|
content = (
|
|
835
818
|
<div
|
|
@@ -862,6 +845,7 @@ const AppointmentPage = ({ config = {}}) => {
|
|
|
862
845
|
);
|
|
863
846
|
} else {
|
|
864
847
|
content = (
|
|
848
|
+
<>
|
|
865
849
|
<div
|
|
866
850
|
style={{
|
|
867
851
|
fontFamily,
|
|
@@ -930,7 +914,8 @@ const AppointmentPage = ({ config = {}}) => {
|
|
|
930
914
|
)}
|
|
931
915
|
</div>
|
|
932
916
|
|
|
933
|
-
{/*
|
|
917
|
+
{/* Profile and notification — commented out for widget */}
|
|
918
|
+
{false && (
|
|
934
919
|
<div style={{ display: "flex", alignItems: "center", gap: isMobile ? "10px" : "16px" }}>
|
|
935
920
|
{/* Notification Bell */}
|
|
936
921
|
<div style={{ position: "relative", cursor: "pointer" }}>
|
|
@@ -1058,6 +1043,7 @@ const AppointmentPage = ({ config = {}}) => {
|
|
|
1058
1043
|
)}
|
|
1059
1044
|
</div>
|
|
1060
1045
|
</div>
|
|
1046
|
+
)}
|
|
1061
1047
|
</div>
|
|
1062
1048
|
|
|
1063
1049
|
{/* Main Content Area */}
|
|
@@ -2260,6 +2246,48 @@ const AppointmentPage = ({ config = {}}) => {
|
|
|
2260
2246
|
</div>
|
|
2261
2247
|
)}
|
|
2262
2248
|
</div>
|
|
2249
|
+
|
|
2250
|
+
{/* Error popup overlay — main page visible in background */}
|
|
2251
|
+
{showAuthError && (
|
|
2252
|
+
<div
|
|
2253
|
+
style={{
|
|
2254
|
+
position: "fixed",
|
|
2255
|
+
inset: 0,
|
|
2256
|
+
zIndex: 100000,
|
|
2257
|
+
display: "flex",
|
|
2258
|
+
alignItems: "center",
|
|
2259
|
+
justifyContent: "center",
|
|
2260
|
+
padding: "24px",
|
|
2261
|
+
background: "rgba(0,0,0,0.4)",
|
|
2262
|
+
boxSizing: "border-box",
|
|
2263
|
+
}}
|
|
2264
|
+
>
|
|
2265
|
+
<div
|
|
2266
|
+
style={{
|
|
2267
|
+
fontFamily,
|
|
2268
|
+
maxWidth: "400px",
|
|
2269
|
+
width: "100%",
|
|
2270
|
+
padding: "32px 24px",
|
|
2271
|
+
background: "#FFFFFF",
|
|
2272
|
+
borderRadius: "12px",
|
|
2273
|
+
boxShadow: "0 8px 32px rgba(0,0,0,0.2)",
|
|
2274
|
+
textAlign: "center",
|
|
2275
|
+
}}
|
|
2276
|
+
>
|
|
2277
|
+
<div style={{ fontSize: "48px", marginBottom: "16px" }}>🔒</div>
|
|
2278
|
+
<h2 style={{ fontSize: "20px", fontWeight: 700, color: "#1a1a1a", margin: "0 0 8px 0" }}>
|
|
2279
|
+
{tokenError ? "Not authorised" : "Sign in required"}
|
|
2280
|
+
</h2>
|
|
2281
|
+
<p style={{ fontSize: "14px", color: "#666", margin: 0, lineHeight: 1.5 }}>
|
|
2282
|
+
{authErrorMessage}
|
|
2283
|
+
</p>
|
|
2284
|
+
<p style={{ fontSize: "13px", color: "#999", marginTop: "16px", marginBottom: 0 }}>
|
|
2285
|
+
Redirecting to login...
|
|
2286
|
+
</p>
|
|
2287
|
+
</div>
|
|
2288
|
+
</div>
|
|
2289
|
+
)}
|
|
2290
|
+
</>
|
|
2263
2291
|
);
|
|
2264
2292
|
}
|
|
2265
2293
|
return <AppointmentErrorBoundary>{content}</AppointmentErrorBoundary>;
|