pih-appointment-widget 0.0.25 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -70
- package/babel.config.js +5 -5
- package/dist/App.js +9 -10
- package/dist/components/AppointmentPage.js +79 -79
- package/dist/pih-appointment-widget.umd.js +138 -113
- package/dist/pih-appointment-widget.umd.min.js +1 -1
- package/dist/services/appointmentService.js +20 -20
- package/dist/services/httpService.js +18 -14
- package/package.json +67 -67
- package/public/index.html +43 -43
- package/public/manifest.json +25 -25
- package/public/robots.txt +3 -3
- package/rollup.config.js +43 -43
- package/src/App.js +48 -48
- package/src/Example.js +11 -11
- package/src/components/AppointmentPage.js +2455 -2438
- package/src/constants/apiConfig.js +28 -28
- package/src/index.js +6 -6
- package/src/services/appointmentService.js +88 -88
- package/src/services/httpService.js +103 -103
package/README.md
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
# Getting Started with Create React App
|
|
2
|
-
|
|
3
|
-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
|
4
|
-
|
|
5
|
-
## Available Scripts
|
|
6
|
-
|
|
7
|
-
In the project directory, you can run:
|
|
8
|
-
|
|
9
|
-
### `npm start`
|
|
10
|
-
|
|
11
|
-
Runs the app in the development mode.\
|
|
12
|
-
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
|
|
13
|
-
|
|
14
|
-
The page will reload when you make changes.\
|
|
15
|
-
You may also see any lint errors in the console.
|
|
16
|
-
|
|
17
|
-
### `npm test`
|
|
18
|
-
|
|
19
|
-
Launches the test runner in the interactive watch mode.\
|
|
20
|
-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
|
21
|
-
|
|
22
|
-
### `npm run build`
|
|
23
|
-
|
|
24
|
-
Builds the app for production to the `build` folder.\
|
|
25
|
-
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
26
|
-
|
|
27
|
-
The build is minified and the filenames include the hashes.\
|
|
28
|
-
Your app is ready to be deployed!
|
|
29
|
-
|
|
30
|
-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
|
31
|
-
|
|
32
|
-
### `npm run eject`
|
|
33
|
-
|
|
34
|
-
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
|
|
35
|
-
|
|
36
|
-
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
|
37
|
-
|
|
38
|
-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
|
|
39
|
-
|
|
40
|
-
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
|
|
41
|
-
|
|
42
|
-
## Learn More
|
|
43
|
-
|
|
44
|
-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
|
45
|
-
|
|
46
|
-
To learn React, check out the [React documentation](https://reactjs.org/).
|
|
47
|
-
|
|
48
|
-
### Code Splitting
|
|
49
|
-
|
|
50
|
-
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
|
|
51
|
-
|
|
52
|
-
### Analyzing the Bundle Size
|
|
53
|
-
|
|
54
|
-
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
|
|
55
|
-
|
|
56
|
-
### Making a Progressive Web App
|
|
57
|
-
|
|
58
|
-
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
|
|
59
|
-
|
|
60
|
-
### Advanced Configuration
|
|
61
|
-
|
|
62
|
-
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
|
|
63
|
-
|
|
64
|
-
### Deployment
|
|
65
|
-
|
|
66
|
-
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
|
|
67
|
-
|
|
68
|
-
### `npm run build` fails to minify
|
|
69
|
-
|
|
70
|
-
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
|
|
1
|
+
# Getting Started with Create React App
|
|
2
|
+
|
|
3
|
+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
|
4
|
+
|
|
5
|
+
## Available Scripts
|
|
6
|
+
|
|
7
|
+
In the project directory, you can run:
|
|
8
|
+
|
|
9
|
+
### `npm start`
|
|
10
|
+
|
|
11
|
+
Runs the app in the development mode.\
|
|
12
|
+
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
|
|
13
|
+
|
|
14
|
+
The page will reload when you make changes.\
|
|
15
|
+
You may also see any lint errors in the console.
|
|
16
|
+
|
|
17
|
+
### `npm test`
|
|
18
|
+
|
|
19
|
+
Launches the test runner in the interactive watch mode.\
|
|
20
|
+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
|
21
|
+
|
|
22
|
+
### `npm run build`
|
|
23
|
+
|
|
24
|
+
Builds the app for production to the `build` folder.\
|
|
25
|
+
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
26
|
+
|
|
27
|
+
The build is minified and the filenames include the hashes.\
|
|
28
|
+
Your app is ready to be deployed!
|
|
29
|
+
|
|
30
|
+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
|
31
|
+
|
|
32
|
+
### `npm run eject`
|
|
33
|
+
|
|
34
|
+
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
|
|
35
|
+
|
|
36
|
+
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
|
37
|
+
|
|
38
|
+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
|
|
39
|
+
|
|
40
|
+
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
|
|
41
|
+
|
|
42
|
+
## Learn More
|
|
43
|
+
|
|
44
|
+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
|
45
|
+
|
|
46
|
+
To learn React, check out the [React documentation](https://reactjs.org/).
|
|
47
|
+
|
|
48
|
+
### Code Splitting
|
|
49
|
+
|
|
50
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
|
|
51
|
+
|
|
52
|
+
### Analyzing the Bundle Size
|
|
53
|
+
|
|
54
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
|
|
55
|
+
|
|
56
|
+
### Making a Progressive Web App
|
|
57
|
+
|
|
58
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
|
|
59
|
+
|
|
60
|
+
### Advanced Configuration
|
|
61
|
+
|
|
62
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
|
|
63
|
+
|
|
64
|
+
### Deployment
|
|
65
|
+
|
|
66
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
|
|
67
|
+
|
|
68
|
+
### `npm run build` fails to minify
|
|
69
|
+
|
|
70
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
|
package/babel.config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
presets: [
|
|
3
|
-
'@babel/preset-env',
|
|
4
|
-
'@babel/preset-react'
|
|
5
|
-
],
|
|
1
|
+
module.exports = {
|
|
2
|
+
presets: [
|
|
3
|
+
'@babel/preset-env',
|
|
4
|
+
'@babel/preset-react'
|
|
5
|
+
],
|
|
6
6
|
};
|
package/dist/App.js
CHANGED
|
@@ -19,21 +19,20 @@ exports.default = void 0;
|
|
|
19
19
|
var _react = _interopRequireDefault(require("react"));
|
|
20
20
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
21
21
|
var _AppointmentPage = _interopRequireWildcard(require("./components/AppointmentPage.js"));
|
|
22
|
-
function
|
|
23
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
24
23
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
25
24
|
let bookingWidgetInstance = null;
|
|
26
25
|
|
|
27
26
|
// SDK for embedding appointment widget
|
|
28
27
|
const BookingSDK = {
|
|
29
|
-
/**
|
|
30
|
-
* Show appointment widget with configuration
|
|
31
|
-
* @param {object} config - Configuration object
|
|
32
|
-
* @param {string} config.apiBaseUrl - Base URL for API
|
|
33
|
-
* @param {string} config.hospitalId - Hospital ID
|
|
34
|
-
* @param {number} config.doctorId - Doctor ID
|
|
35
|
-
* @param {string} config.joinCallUrl - Video call URL
|
|
36
|
-
* @param {function} onAction - Optional callback for actions
|
|
28
|
+
/**
|
|
29
|
+
* Show appointment widget with configuration
|
|
30
|
+
* @param {object} config - Configuration object
|
|
31
|
+
* @param {string} config.apiBaseUrl - Base URL for API
|
|
32
|
+
* @param {string} config.hospitalId - Hospital ID
|
|
33
|
+
* @param {number} config.doctorId - Doctor ID
|
|
34
|
+
* @param {string} config.joinCallUrl - Video call URL
|
|
35
|
+
* @param {function} onAction - Optional callback for actions
|
|
37
36
|
*/
|
|
38
37
|
showWidget: (config, onAction) => {
|
|
39
38
|
if (!bookingWidgetInstance) {
|
|
@@ -8,8 +8,10 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _appointmentService = require("../services/appointmentService");
|
|
9
9
|
var _httpService = require("../services/httpService");
|
|
10
10
|
var _apiConfig = require("../constants/apiConfig");
|
|
11
|
-
function
|
|
12
|
-
function
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
15
|
// Decode JWT payload (no verification; for display only). Returns {} on invalid/missing.
|
|
14
16
|
function getJwtPayload(token) {
|
|
15
17
|
if (!token || typeof token !== "string") return {};
|
|
@@ -19,7 +21,7 @@ function getJwtPayload(token) {
|
|
|
19
21
|
const base64 = parts[1].replace(/-/g, "+").replace(/_/g, "/");
|
|
20
22
|
const padded = base64.padEnd(base64.length + (4 - base64.length % 4) % 4, "=");
|
|
21
23
|
return JSON.parse(atob(padded));
|
|
22
|
-
} catch {
|
|
24
|
+
} catch (_unused) {
|
|
23
25
|
return {};
|
|
24
26
|
}
|
|
25
27
|
}
|
|
@@ -39,26 +41,32 @@ const PIH_APPOINTMENT_WIDGET_DATA_ATTR = "data-pih-widget";
|
|
|
39
41
|
|
|
40
42
|
// Extract from SSO login response (not from appToken JWT — these are only in login response)
|
|
41
43
|
function extractAppToken(response) {
|
|
44
|
+
var _ref, _ref2, _ref3, _response$data$access, _response$data, _response$data2;
|
|
42
45
|
if (!response || response.err) return null;
|
|
43
|
-
return response.data
|
|
46
|
+
return (_ref = (_ref2 = (_ref3 = (_response$data$access = (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.access_token) !== null && _response$data$access !== void 0 ? _response$data$access : (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.token) !== null && _ref3 !== void 0 ? _ref3 : response.token) !== null && _ref2 !== void 0 ? _ref2 : response.accessToken) !== null && _ref !== void 0 ? _ref : null;
|
|
44
47
|
}
|
|
45
48
|
function extractDoctorIdFromLoginResponse(response) {
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
var _ref4, _response$data$doctor;
|
|
50
|
+
if (!(response !== null && response !== void 0 && response.data)) return null;
|
|
51
|
+
const id = (_ref4 = (_response$data$doctor = response.data.doctor_id) !== null && _response$data$doctor !== void 0 ? _response$data$doctor : response.data.doctorId) !== null && _ref4 !== void 0 ? _ref4 : null;
|
|
48
52
|
console.log(id, 'extractDoctorIdFromLoginResponse -> id');
|
|
49
53
|
return id != null ? String(id) : null;
|
|
50
54
|
}
|
|
51
55
|
function extractUserNameFromLoginResponse(response) {
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
var _ref5, _ref6, _response$data$name;
|
|
57
|
+
if (!(response !== null && response !== void 0 && response.data)) return null;
|
|
58
|
+
const name = (_ref5 = (_ref6 = (_response$data$name = response.data.name) !== null && _response$data$name !== void 0 ? _response$data$name : response.data.doctor_name) !== null && _ref6 !== void 0 ? _ref6 : response.data.userName) !== null && _ref5 !== void 0 ? _ref5 : null;
|
|
54
59
|
return name != null ? String(name) : null;
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
// Error boundary so a render error never shows a blank screen
|
|
58
63
|
class AppointmentErrorBoundary extends _react.Component {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
constructor() {
|
|
65
|
+
super(...arguments);
|
|
66
|
+
_defineProperty(this, "state", {
|
|
67
|
+
hasError: false
|
|
68
|
+
});
|
|
69
|
+
}
|
|
62
70
|
static getDerivedStateFromError() {
|
|
63
71
|
return {
|
|
64
72
|
hasError: true
|
|
@@ -115,21 +123,21 @@ class AppointmentErrorBoundary extends _react.Component {
|
|
|
115
123
|
}
|
|
116
124
|
|
|
117
125
|
// SDK Component - accepts configuration from parent app
|
|
118
|
-
const AppointmentPage =
|
|
126
|
+
const AppointmentPage = _ref7 => {
|
|
119
127
|
let {
|
|
120
128
|
config = {}
|
|
121
|
-
} =
|
|
129
|
+
} = _ref7;
|
|
122
130
|
const [storedApiBaseUrl, setStoredApiBaseUrl] = (0, _react.useState)(() => {
|
|
123
131
|
try {
|
|
124
132
|
return typeof localStorage !== "undefined" ? localStorage.getItem(STORAGE_KEY_API_BASE_URL) : null;
|
|
125
|
-
} catch {
|
|
133
|
+
} catch (_unused2) {
|
|
126
134
|
return null;
|
|
127
135
|
}
|
|
128
136
|
});
|
|
129
137
|
const [storedHospitalId, setStoredHospitalId] = (0, _react.useState)(() => {
|
|
130
138
|
try {
|
|
131
139
|
return typeof localStorage !== "undefined" ? localStorage.getItem(STORAGE_KEY_HOSPITAL_ID) : null;
|
|
132
|
-
} catch {
|
|
140
|
+
} catch (_unused3) {
|
|
133
141
|
return null;
|
|
134
142
|
}
|
|
135
143
|
});
|
|
@@ -140,14 +148,14 @@ const AppointmentPage = _ref => {
|
|
|
140
148
|
const [storedIdToken, setStoredIdToken] = (0, _react.useState)(() => {
|
|
141
149
|
try {
|
|
142
150
|
return typeof localStorage !== "undefined" ? localStorage.getItem(STORAGE_KEY_ID_TOKEN) : null;
|
|
143
|
-
} catch {
|
|
151
|
+
} catch (_unused4) {
|
|
144
152
|
return null;
|
|
145
153
|
}
|
|
146
154
|
});
|
|
147
155
|
const [storedEmail, setStoredEmail] = (0, _react.useState)(() => {
|
|
148
156
|
try {
|
|
149
157
|
return typeof localStorage !== "undefined" ? localStorage.getItem(STORAGE_KEY_EMAIL) : null;
|
|
150
|
-
} catch {
|
|
158
|
+
} catch (_unused5) {
|
|
151
159
|
return null;
|
|
152
160
|
}
|
|
153
161
|
});
|
|
@@ -190,21 +198,21 @@ const AppointmentPage = _ref => {
|
|
|
190
198
|
const [appToken, setAppToken] = (0, _react.useState)(() => {
|
|
191
199
|
try {
|
|
192
200
|
return typeof localStorage !== "undefined" ? localStorage.getItem(STORAGE_KEY_APP_TOKEN) : null;
|
|
193
|
-
} catch {
|
|
201
|
+
} catch (_unused6) {
|
|
194
202
|
return null;
|
|
195
203
|
}
|
|
196
204
|
});
|
|
197
205
|
const [doctorIdFromLogin, setDoctorIdFromLogin] = (0, _react.useState)(() => {
|
|
198
206
|
try {
|
|
199
207
|
return typeof localStorage !== "undefined" ? localStorage.getItem(STORAGE_KEY_DOCTOR_ID) : null;
|
|
200
|
-
} catch {
|
|
208
|
+
} catch (_unused7) {
|
|
201
209
|
return null;
|
|
202
210
|
}
|
|
203
211
|
});
|
|
204
212
|
const [userName, setUserName] = (0, _react.useState)(() => {
|
|
205
213
|
try {
|
|
206
214
|
return typeof localStorage !== "undefined" ? localStorage.getItem(STORAGE_KEY_USER_NAME) : null;
|
|
207
|
-
} catch {
|
|
215
|
+
} catch (_unused8) {
|
|
208
216
|
return null;
|
|
209
217
|
}
|
|
210
218
|
});
|
|
@@ -215,7 +223,7 @@ const AppointmentPage = _ref => {
|
|
|
215
223
|
const hasId = localStorage.getItem(STORAGE_KEY_ID_TOKEN);
|
|
216
224
|
const hasEmail = localStorage.getItem(STORAGE_KEY_EMAIL);
|
|
217
225
|
return !hasApp && !!(hasId && hasEmail);
|
|
218
|
-
} catch {
|
|
226
|
+
} catch (_unused9) {
|
|
219
227
|
return false;
|
|
220
228
|
}
|
|
221
229
|
});
|
|
@@ -277,7 +285,7 @@ const AppointmentPage = _ref => {
|
|
|
277
285
|
const y = date.getFullYear();
|
|
278
286
|
const m = String(date.getMonth() + 1).padStart(2, "0");
|
|
279
287
|
const d = String(date.getDate()).padStart(2, "0");
|
|
280
|
-
return
|
|
288
|
+
return "".concat(y, "-").concat(m, "-").concat(d);
|
|
281
289
|
};
|
|
282
290
|
const getDateRange = option => {
|
|
283
291
|
const today = new Date();
|
|
@@ -308,8 +316,8 @@ const AppointmentPage = _ref => {
|
|
|
308
316
|
to = formatLocalDate(lastOfMonth);
|
|
309
317
|
break;
|
|
310
318
|
case "currentYear":
|
|
311
|
-
from =
|
|
312
|
-
to =
|
|
319
|
+
from = "".concat(today.getFullYear(), "-01-01");
|
|
320
|
+
to = "".concat(today.getFullYear(), "-12-31");
|
|
313
321
|
break;
|
|
314
322
|
default:
|
|
315
323
|
from = to = getTodayDate();
|
|
@@ -334,7 +342,7 @@ const AppointmentPage = _ref => {
|
|
|
334
342
|
case "currentYear":
|
|
335
343
|
return "Current Year";
|
|
336
344
|
case "custom":
|
|
337
|
-
return isMobile ? "Custom" :
|
|
345
|
+
return isMobile ? "Custom" : "".concat(fromDate, " to ").concat(toDate);
|
|
338
346
|
default:
|
|
339
347
|
return "Today";
|
|
340
348
|
}
|
|
@@ -419,12 +427,12 @@ const AppointmentPage = _ref => {
|
|
|
419
427
|
|
|
420
428
|
// Helper to get unique identifier from appointment
|
|
421
429
|
const getAppointmentId = appointment => {
|
|
422
|
-
return appointment
|
|
430
|
+
return (appointment === null || appointment === void 0 ? void 0 : appointment.id) || (appointment === null || appointment === void 0 ? void 0 : appointment._id) || (appointment === null || appointment === void 0 ? void 0 : appointment.appointmentId) || (appointment === null || appointment === void 0 ? void 0 : appointment.patientId) || JSON.stringify(appointment);
|
|
423
431
|
};
|
|
424
432
|
|
|
425
433
|
// Generate avatar with first letter if no image
|
|
426
434
|
const getPatientAvatar = appointment => {
|
|
427
|
-
if (appointment
|
|
435
|
+
if (appointment !== null && appointment !== void 0 && appointment.image) {
|
|
428
436
|
return appointment.image;
|
|
429
437
|
}
|
|
430
438
|
// Return null to use the letter avatar component
|
|
@@ -543,6 +551,7 @@ const AppointmentPage = _ref => {
|
|
|
543
551
|
setCallLoading(true);
|
|
544
552
|
setCallError(null);
|
|
545
553
|
try {
|
|
554
|
+
var _response$data3;
|
|
546
555
|
const callConfig = {
|
|
547
556
|
apiBaseUrl,
|
|
548
557
|
hospitalId,
|
|
@@ -570,7 +579,7 @@ const AppointmentPage = _ref => {
|
|
|
570
579
|
setCallError("Session expired. Re-authenticating...");
|
|
571
580
|
return;
|
|
572
581
|
}
|
|
573
|
-
if (response.err || !response.data
|
|
582
|
+
if (response.err || !((_response$data3 = response.data) !== null && _response$data3 !== void 0 && _response$data3.token)) {
|
|
574
583
|
setCallError(String(response.err || "Failed to initiate call"));
|
|
575
584
|
return;
|
|
576
585
|
}
|
|
@@ -609,6 +618,25 @@ const AppointmentPage = _ref => {
|
|
|
609
618
|
fetchAppointments();
|
|
610
619
|
};
|
|
611
620
|
|
|
621
|
+
// End call silently when user presses browser back button during an active call.
|
|
622
|
+
(0, _react.useEffect)(() => {
|
|
623
|
+
if (!showPipVideo) return;
|
|
624
|
+
window.history.pushState({
|
|
625
|
+
pipActive: true
|
|
626
|
+
}, "");
|
|
627
|
+
const handlePopState = () => {
|
|
628
|
+
setShowPipVideo(false);
|
|
629
|
+
setIsPipMinimized(false);
|
|
630
|
+
setIsPipFullscreen(false);
|
|
631
|
+
setCallToken(null);
|
|
632
|
+
setCallUrl(null);
|
|
633
|
+
setCallError(null);
|
|
634
|
+
window.history.back();
|
|
635
|
+
};
|
|
636
|
+
window.addEventListener("popstate", handlePopState);
|
|
637
|
+
return () => window.removeEventListener("popstate", handlePopState);
|
|
638
|
+
}, [showPipVideo]);
|
|
639
|
+
|
|
612
640
|
// Handle PiP minimize
|
|
613
641
|
const handleTogglePipSize = () => {
|
|
614
642
|
if (isPipFullscreen) {
|
|
@@ -844,32 +872,7 @@ const AppointmentPage = _ref => {
|
|
|
844
872
|
|
|
845
873
|
// Add responsive styles and animations
|
|
846
874
|
const style = document.createElement("style");
|
|
847
|
-
style.innerHTML =
|
|
848
|
-
@keyframes spin {
|
|
849
|
-
0% { transform: rotate(0deg); }
|
|
850
|
-
100% { transform: rotate(360deg); }
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
@media (max-width: 768px) {
|
|
854
|
-
.appointments-grid {
|
|
855
|
-
grid-template-columns: 1.5fr 1fr 0.8fr !important;
|
|
856
|
-
}
|
|
857
|
-
.appointments-header-grid {
|
|
858
|
-
grid-template-columns: 1.5fr 1fr 0.8fr !important;
|
|
859
|
-
}
|
|
860
|
-
.hide-on-mobile {
|
|
861
|
-
display: none !important;
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
@media (max-width: 480px) {
|
|
865
|
-
.appointments-header-grid {
|
|
866
|
-
font-size: 10px !important;
|
|
867
|
-
}
|
|
868
|
-
.appointments-grid {
|
|
869
|
-
font-size: 11px !important;
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
`;
|
|
875
|
+
style.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 ";
|
|
873
876
|
document.head.appendChild(style);
|
|
874
877
|
|
|
875
878
|
// Handle window resize
|
|
@@ -922,7 +925,7 @@ const AppointmentPage = _ref => {
|
|
|
922
925
|
justifyContent: "center",
|
|
923
926
|
padding: "24px"
|
|
924
927
|
}
|
|
925
|
-
}, /*#__PURE__*/_react.default.createElement("style", null,
|
|
928
|
+
}, /*#__PURE__*/_react.default.createElement("style", null, "@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }"), /*#__PURE__*/_react.default.createElement("div", {
|
|
926
929
|
style: {
|
|
927
930
|
width: "40px",
|
|
928
931
|
height: "40px",
|
|
@@ -1673,7 +1676,7 @@ const AppointmentPage = _ref => {
|
|
|
1673
1676
|
style: {
|
|
1674
1677
|
fontSize: "13px"
|
|
1675
1678
|
}
|
|
1676
|
-
}, searchQuery ?
|
|
1679
|
+
}, searchQuery ? "No appointments found for \"".concat(searchQuery, "\"") : "No appointments found"), searchQuery && /*#__PURE__*/_react.default.createElement("button", {
|
|
1677
1680
|
onClick: () => setSearchQuery(""),
|
|
1678
1681
|
style: {
|
|
1679
1682
|
marginTop: "12px",
|
|
@@ -1952,7 +1955,7 @@ const AppointmentPage = _ref => {
|
|
|
1952
1955
|
fontWeight: "700",
|
|
1953
1956
|
fontSize: isMobile ? "12px" : "13px"
|
|
1954
1957
|
}
|
|
1955
|
-
}, selectedAppointment
|
|
1958
|
+
}, (selectedAppointment === null || selectedAppointment === void 0 ? void 0 : selectedAppointment.specialisation) || (selectedAppointment === null || selectedAppointment === void 0 ? void 0 : selectedAppointment.speciality) || "N/A")), /*#__PURE__*/_react.default.createElement("div", {
|
|
1956
1959
|
style: {
|
|
1957
1960
|
textAlign: "right"
|
|
1958
1961
|
}
|
|
@@ -1967,7 +1970,7 @@ const AppointmentPage = _ref => {
|
|
|
1967
1970
|
fontWeight: "700",
|
|
1968
1971
|
fontSize: isMobile ? "12px" : "13px"
|
|
1969
1972
|
}
|
|
1970
|
-
}, selectedAppointment
|
|
1973
|
+
}, (selectedAppointment === null || selectedAppointment === void 0 ? void 0 : selectedAppointment.type) || (selectedAppointment === null || selectedAppointment === void 0 ? void 0 : selectedAppointment.appointmentType) || "Online"))), /*#__PURE__*/_react.default.createElement("div", {
|
|
1971
1974
|
style: {
|
|
1972
1975
|
display: "flex",
|
|
1973
1976
|
justifyContent: "space-between"
|
|
@@ -1987,7 +1990,7 @@ const AppointmentPage = _ref => {
|
|
|
1987
1990
|
fontWeight: "700",
|
|
1988
1991
|
fontSize: isMobile ? "12px" : "13px"
|
|
1989
1992
|
}
|
|
1990
|
-
}, selectedAppointment
|
|
1993
|
+
}, (selectedAppointment === null || selectedAppointment === void 0 ? void 0 : selectedAppointment.date) || (selectedAppointment === null || selectedAppointment === void 0 ? void 0 : selectedAppointment.appointmentDate) || "N/A")), /*#__PURE__*/_react.default.createElement("div", {
|
|
1991
1994
|
style: {
|
|
1992
1995
|
textAlign: "right"
|
|
1993
1996
|
}
|
|
@@ -2002,7 +2005,7 @@ const AppointmentPage = _ref => {
|
|
|
2002
2005
|
fontWeight: "700",
|
|
2003
2006
|
fontSize: isMobile ? "12px" : "13px"
|
|
2004
2007
|
}
|
|
2005
|
-
}, selectedAppointment
|
|
2008
|
+
}, (selectedAppointment === null || selectedAppointment === void 0 ? void 0 : selectedAppointment.time) || (selectedAppointment === null || selectedAppointment === void 0 ? void 0 : selectedAppointment.appointmentTime) || "N/A"))), /*#__PURE__*/_react.default.createElement("div", {
|
|
2006
2009
|
style: {
|
|
2007
2010
|
display: "flex",
|
|
2008
2011
|
justifyContent: "space-between"
|
|
@@ -2022,7 +2025,7 @@ const AppointmentPage = _ref => {
|
|
|
2022
2025
|
fontWeight: "700",
|
|
2023
2026
|
fontSize: isMobile ? "12px" : "13px"
|
|
2024
2027
|
}
|
|
2025
|
-
}, selectedAppointment
|
|
2028
|
+
}, (selectedAppointment === null || selectedAppointment === void 0 ? void 0 : selectedAppointment.doctor) || (selectedAppointment === null || selectedAppointment === void 0 ? void 0 : selectedAppointment.doctorName) || "N/A"))), /*#__PURE__*/_react.default.createElement("div", {
|
|
2026
2029
|
style: {
|
|
2027
2030
|
display: "flex",
|
|
2028
2031
|
justifyContent: "space-between"
|
|
@@ -2042,7 +2045,7 @@ const AppointmentPage = _ref => {
|
|
|
2042
2045
|
fontWeight: "700",
|
|
2043
2046
|
fontSize: isMobile ? "12px" : "13px"
|
|
2044
2047
|
}
|
|
2045
|
-
}, selectedAppointment
|
|
2048
|
+
}, (selectedAppointment === null || selectedAppointment === void 0 ? void 0 : selectedAppointment.hospital) || (selectedAppointment === null || selectedAppointment === void 0 ? void 0 : selectedAppointment.hospitalName) || "N/A"))), /*#__PURE__*/_react.default.createElement("div", {
|
|
2046
2049
|
style: {
|
|
2047
2050
|
display: "flex",
|
|
2048
2051
|
justifyContent: "space-between"
|
|
@@ -2063,7 +2066,7 @@ const AppointmentPage = _ref => {
|
|
|
2063
2066
|
fontSize: isMobile ? "11px" : "12px",
|
|
2064
2067
|
lineHeight: "1.4"
|
|
2065
2068
|
}
|
|
2066
|
-
}, selectedAppointment
|
|
2069
|
+
}, (selectedAppointment === null || selectedAppointment === void 0 ? void 0 : selectedAppointment.reason) || (selectedAppointment === null || selectedAppointment === void 0 ? void 0 : selectedAppointment.reasonForAppointment) || "No reason provided"))), activeTab === "upcoming" && /*#__PURE__*/_react.default.createElement("div", {
|
|
2067
2070
|
style: {
|
|
2068
2071
|
display: "flex",
|
|
2069
2072
|
flexDirection: isMobile ? "column" : "row",
|
|
@@ -2116,12 +2119,12 @@ const AppointmentPage = _ref => {
|
|
|
2116
2119
|
}, "Select an appointment to view details"))))))), showPipVideo && /*#__PURE__*/_react.default.createElement("div", {
|
|
2117
2120
|
style: {
|
|
2118
2121
|
position: "fixed",
|
|
2119
|
-
left: isPipFullscreen ? "0" : isMobile ? "10px" :
|
|
2120
|
-
top: isPipFullscreen ? "0" : isMobile ? "70px" :
|
|
2122
|
+
left: isPipFullscreen ? "0" : isMobile ? "10px" : "".concat(pipPosition.x, "px"),
|
|
2123
|
+
top: isPipFullscreen ? "0" : isMobile ? "70px" : "".concat(pipPosition.y, "px"),
|
|
2121
2124
|
right: isPipFullscreen ? "0" : isMobile ? "10px" : "auto",
|
|
2122
2125
|
bottom: isPipFullscreen ? "0" : "auto",
|
|
2123
|
-
width: isPipFullscreen ? "100vw" : isMobile ? "calc(100vw - 20px)" : isPipMinimized ? "350px" :
|
|
2124
|
-
height: isPipFullscreen ? "100vh" : isPipMinimized ? "auto" : isMobile ? "300px" :
|
|
2126
|
+
width: isPipFullscreen ? "100vw" : isMobile ? "calc(100vw - 20px)" : isPipMinimized ? "350px" : "".concat(pipSize.width, "px"),
|
|
2127
|
+
height: isPipFullscreen ? "100vh" : isPipMinimized ? "auto" : isMobile ? "300px" : "".concat(pipSize.height, "px"),
|
|
2125
2128
|
background: "#FFFFFF",
|
|
2126
2129
|
borderRadius: isPipFullscreen ? "0" : "8px",
|
|
2127
2130
|
boxShadow: "0 8px 24px rgba(0, 0, 0, 0.3)",
|
|
@@ -2172,7 +2175,7 @@ const AppointmentPage = _ref => {
|
|
|
2172
2175
|
textOverflow: "ellipsis",
|
|
2173
2176
|
whiteSpace: "nowrap"
|
|
2174
2177
|
}
|
|
2175
|
-
}, "Video Call - ", selectedAppointment
|
|
2178
|
+
}, "Video Call - ", (selectedAppointment === null || selectedAppointment === void 0 ? void 0 : selectedAppointment.patientName) || "Patient")), /*#__PURE__*/_react.default.createElement("div", {
|
|
2176
2179
|
style: {
|
|
2177
2180
|
display: "flex",
|
|
2178
2181
|
gap: isMobile ? "4px" : "6px",
|
|
@@ -2289,23 +2292,25 @@ const AppointmentPage = _ref => {
|
|
|
2289
2292
|
onMouseEnter: e => e.target.style.background = "rgba(255, 255, 255, 0.3)",
|
|
2290
2293
|
onMouseLeave: e => e.target.style.background = "rgba(255, 255, 255, 0.2)",
|
|
2291
2294
|
title: "Close"
|
|
2292
|
-
}, "\xD7"))),
|
|
2295
|
+
}, "\xD7"))), /*#__PURE__*/_react.default.createElement("div", {
|
|
2293
2296
|
style: {
|
|
2294
2297
|
flex: 1,
|
|
2295
2298
|
background: "#000000",
|
|
2296
|
-
position: "relative"
|
|
2299
|
+
position: "relative",
|
|
2300
|
+
display: isPipMinimized ? "none" : "flex",
|
|
2301
|
+
flexDirection: "column"
|
|
2297
2302
|
}
|
|
2298
2303
|
}, /*#__PURE__*/_react.default.createElement("iframe", {
|
|
2299
2304
|
src: (() => {
|
|
2300
2305
|
if (!callToken) return "";
|
|
2301
2306
|
const base = String(joinCallUrlBase || "").replace(/\/?$/, "/");
|
|
2302
|
-
|
|
2303
|
-
return `${base}token=${callToken}`;
|
|
2307
|
+
return "".concat(base).concat(callToken);
|
|
2304
2308
|
})(),
|
|
2305
2309
|
style: {
|
|
2306
2310
|
width: "100%",
|
|
2307
2311
|
height: "100%",
|
|
2308
|
-
border: "none"
|
|
2312
|
+
border: "none",
|
|
2313
|
+
flex: 1
|
|
2309
2314
|
},
|
|
2310
2315
|
allow: "camera; microphone; display-capture; autoplay",
|
|
2311
2316
|
allowFullScreen: true,
|
|
@@ -2370,12 +2375,7 @@ const AppointmentPage = _ref => {
|
|
|
2370
2375
|
background: "transparent",
|
|
2371
2376
|
zIndex: 10001
|
|
2372
2377
|
}
|
|
2373
|
-
})), /*#__PURE__*/_react.default.createElement("style", null,
|
|
2374
|
-
@keyframes pulse {
|
|
2375
|
-
0%, 100% { opacity: 1; }
|
|
2376
|
-
50% { opacity: 0.5; }
|
|
2377
|
-
}
|
|
2378
|
-
`))), showAuthError && /*#__PURE__*/_react.default.createElement("div", {
|
|
2378
|
+
})), /*#__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", {
|
|
2379
2379
|
style: {
|
|
2380
2380
|
position: "fixed",
|
|
2381
2381
|
inset: 0,
|