@eka-care/medassist-widget-embed 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/iframe.html +4 -0
- package/dist/iframe.js +49 -34
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -2
- package/dist/src/medassist-widget.js +160 -28
- package/dist/src/medassist-widget.js.map +1 -1
- package/iframe.html +4 -0
- package/iframe.ts +48 -41
- package/index.ts +43 -2
- package/package.json +1 -1
- package/src/medassist-widget.js +160 -28
- package/src/medassist-widget.js.map +1 -1
package/iframe.html
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>MedAssist Widget</title>
|
|
7
|
+
|
|
8
|
+
<!-- Resouce hints for faster loading -->
|
|
9
|
+
<link rel="preconnect" href="https://unpkg.com" crossorigin/>
|
|
10
|
+
<link rel="dns-prefetch" href="https://unpkg.com"/>
|
|
7
11
|
<style>
|
|
8
12
|
* {
|
|
9
13
|
margin: 0;
|
package/iframe.ts
CHANGED
|
@@ -88,57 +88,61 @@
|
|
|
88
88
|
const environment =
|
|
89
89
|
getEnvironment(urlParams.get("environment")) ?? "production";
|
|
90
90
|
const container = document.getElementById("root") || document.body;
|
|
91
|
+
try {
|
|
92
|
+
await Promise.all([
|
|
93
|
+
loadWidgetCss(),
|
|
94
|
+
loadWidgetScript(),
|
|
95
|
+
])
|
|
96
|
+
if (!window?.renderMedAssist || typeof window?.renderMedAssist !== "function") {
|
|
97
|
+
throw new Error("renderMedAssist is not available on window");
|
|
98
|
+
}
|
|
91
99
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
const config = {
|
|
101
|
+
title,
|
|
102
|
+
iconUrl,
|
|
103
|
+
environment,
|
|
104
|
+
onClose: () => {
|
|
105
|
+
// Send message to parent window to close iframe
|
|
106
|
+
if (window.parent !== window) {
|
|
107
|
+
window.parent.postMessage({ type: "WIDGET_CLOSE" }, "*");
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
context: context ? JSON.parse(context) : undefined,
|
|
111
|
+
baseUrl,
|
|
112
|
+
displayMode: "full" as "full" | "widget",//for iframe default display mode is full
|
|
113
|
+
};
|
|
114
|
+
window.renderMedAssist(container, agentId, config);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
console.error("Failed to initialize MedAssist widget", error);
|
|
117
|
+
throw error;
|
|
100
118
|
}
|
|
101
|
-
|
|
102
|
-
const config = {
|
|
103
|
-
title,
|
|
104
|
-
iconUrl,
|
|
105
|
-
environment,
|
|
106
|
-
onClose: () => {
|
|
107
|
-
// Send message to parent window to close iframe
|
|
108
|
-
if (window.parent !== window) {
|
|
109
|
-
window.parent.postMessage({ type: "WIDGET_CLOSE" }, "*");
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
context: context ? JSON.parse(context) : undefined,
|
|
113
|
-
baseUrl,
|
|
114
|
-
displayMode: "full" as "full" | "widget",//for iframe default display mode is full
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
window.renderMedAssist(container, agentId, config);
|
|
118
119
|
};
|
|
119
120
|
|
|
120
121
|
async function loadWidgetCss(): Promise<void> {
|
|
121
122
|
// Check if already loaded
|
|
122
|
-
|
|
123
|
+
const existingLink = document.querySelector<HTMLLinkElement>(`link[data-medassist-style='true']`);
|
|
124
|
+
|
|
125
|
+
if (existingLink) {
|
|
123
126
|
return;
|
|
124
127
|
}
|
|
125
|
-
|
|
126
128
|
if (!widgetCssTextPromise) {
|
|
127
|
-
widgetCssTextPromise =
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
widgetCssTextPromise = new Promise((resolve, reject) => {
|
|
130
|
+
const link = document.createElement("link");
|
|
131
|
+
link.rel = "stylesheet";
|
|
132
|
+
link.href = WIDGET_CSS_URL;
|
|
133
|
+
link.setAttribute("data-medassist-style", "true");
|
|
134
|
+
|
|
135
|
+
link.onload = () => {
|
|
136
|
+
resolve("");
|
|
137
|
+
};
|
|
138
|
+
link.onerror = () => {
|
|
139
|
+
reject(new Error(`Failed to load ${WIDGET_CSS_URL}`));
|
|
140
|
+
};
|
|
141
|
+
document.head.appendChild(link);
|
|
134
142
|
});
|
|
135
143
|
}
|
|
136
144
|
|
|
137
|
-
|
|
138
|
-
const styleTag = document.createElement("style");
|
|
139
|
-
styleTag.setAttribute("data-medassist-style", "true");
|
|
140
|
-
styleTag.textContent = cssText;
|
|
141
|
-
document.head.appendChild(styleTag);
|
|
145
|
+
await widgetCssTextPromise;
|
|
142
146
|
}
|
|
143
147
|
|
|
144
148
|
function loadWidgetScript(): Promise<void> {
|
|
@@ -180,7 +184,6 @@
|
|
|
180
184
|
document.head.appendChild(script);
|
|
181
185
|
});
|
|
182
186
|
}
|
|
183
|
-
|
|
184
187
|
return widgetScriptPromise;
|
|
185
188
|
}
|
|
186
189
|
|
|
@@ -189,7 +192,11 @@
|
|
|
189
192
|
if (document.readyState === "loading") {
|
|
190
193
|
document.addEventListener("DOMContentLoaded", initializeFromUrlParams);
|
|
191
194
|
} else {
|
|
192
|
-
|
|
195
|
+
try {
|
|
196
|
+
initializeFromUrlParams();
|
|
197
|
+
} catch (error) {
|
|
198
|
+
console.error("Failed to initialize MedAssist widget", error);
|
|
199
|
+
}
|
|
193
200
|
}
|
|
194
201
|
}
|
|
195
202
|
})();
|
package/index.ts
CHANGED
|
@@ -141,6 +141,10 @@ class MedAssistWidgetLoader extends HTMLElement {
|
|
|
141
141
|
this.defaultIconUrl = "https://cdn.eka.care/bot-icon.svg";
|
|
142
142
|
this.widgetLoaded = false;
|
|
143
143
|
this.displayMode = this.getAttribute("display-mode") === "full" ? "full" : "widget";
|
|
144
|
+
|
|
145
|
+
this.preloadResources();
|
|
146
|
+
// Listen for AUTH_EXPIRED events from the widget and forward to parent
|
|
147
|
+
this.setupAuthExpirationListener();
|
|
144
148
|
}
|
|
145
149
|
|
|
146
150
|
static get observedAttributes(): string[] {
|
|
@@ -174,15 +178,52 @@ class MedAssistWidgetLoader extends HTMLElement {
|
|
|
174
178
|
}
|
|
175
179
|
}
|
|
176
180
|
|
|
181
|
+
// Preload resources in the background
|
|
182
|
+
private preloadResources(): void {
|
|
183
|
+
// Preload CSS (browser will cache it)
|
|
184
|
+
if (!document.querySelector(`link[href="${WIDGET_CSS_URL}"]`)) {
|
|
185
|
+
const cssLink = document.createElement("link");
|
|
186
|
+
cssLink.rel = "preload";
|
|
187
|
+
cssLink.href = WIDGET_CSS_URL;
|
|
188
|
+
cssLink.as = "style";
|
|
189
|
+
document.head.appendChild(cssLink);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Preload JS (browser will cache it)
|
|
193
|
+
if (!document.querySelector(`link[href="${WIDGET_JS_URL}"]`)) {
|
|
194
|
+
const jsLink = document.createElement("link");
|
|
195
|
+
jsLink.rel = "preload";
|
|
196
|
+
jsLink.href = WIDGET_JS_URL;
|
|
197
|
+
jsLink.as = "script";
|
|
198
|
+
jsLink.crossOrigin = "anonymous";
|
|
199
|
+
document.head.appendChild(jsLink);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
private setupAuthExpirationListener(): void {
|
|
204
|
+
if (typeof window === "undefined") return;
|
|
205
|
+
|
|
206
|
+
const messageHandler = (event: MessageEvent) => {
|
|
207
|
+
if (event.data?.type === "AUTH_EXPIRED") {
|
|
208
|
+
if (window.parent !== window) {
|
|
209
|
+
window.parent.postMessage({ type: "AUTH_EXPIRED", message: "Authentication expired" }, "*");
|
|
210
|
+
}
|
|
211
|
+
// window.webkit.messageHandlers.authTokenExpired.postMessage({});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
window.addEventListener("message", messageHandler);
|
|
216
|
+
}
|
|
217
|
+
|
|
177
218
|
public openFromBridge(): void {
|
|
219
|
+
this.displayMode = this.getAttribute("display-mode") === "full" ? "full" : "widget";
|
|
178
220
|
if (this.displayMode === "full") {
|
|
179
221
|
this.initializeFullMode();
|
|
180
222
|
} else {
|
|
181
223
|
this.renderButton();
|
|
182
224
|
}
|
|
183
225
|
|
|
184
|
-
this.loadWidgetCss()
|
|
185
|
-
.then(() => this.loadWidgetScript())
|
|
226
|
+
Promise.all([this.loadWidgetCss(), this.loadWidgetScript()])
|
|
186
227
|
.then(() => this.loadAndRender())
|
|
187
228
|
.catch((error) => {
|
|
188
229
|
console.error("Failed to open MedAssist widget from bridge", error);
|
package/package.json
CHANGED
package/src/medassist-widget.js
CHANGED
|
@@ -26737,7 +26737,7 @@ var MedAssistWidget = (function(exports) {
|
|
|
26737
26737
|
hasRequired_Error$1 = 1;
|
|
26738
26738
|
(function(exports$1) {
|
|
26739
26739
|
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
26740
|
-
exports$1.ValidationError = exports$1.ConfigurationError = exports$1.StoreError = exports$1.MessageError = exports$1.SessionError = exports$1.FileError = exports$1.RecordingError = exports$1.ConnectionError = exports$1.InternalServerError = exports$1.RateLimitError = exports$1.MethodNotAllowedError = exports$1.NotFoundError = exports$1.PermissionDeniedError = exports$1.UnauthorizedError = exports$1.BadRequestError = exports$1.APIConnectionTimeoutError = exports$1.APIUserAbortError = exports$1.APIError = exports$1.SynapseError = exports$1.SynapseErrorCode = void 0;
|
|
26740
|
+
exports$1.ValidationError = exports$1.ConfigurationError = exports$1.StoreError = exports$1.MessageError = exports$1.SessionError = exports$1.FileError = exports$1.AuthenticationError = exports$1.RecordingError = exports$1.ConnectionError = exports$1.InternalServerError = exports$1.RateLimitError = exports$1.MethodNotAllowedError = exports$1.NotFoundError = exports$1.PermissionDeniedError = exports$1.UnauthorizedError = exports$1.BadRequestError = exports$1.APIConnectionTimeoutError = exports$1.APIUserAbortError = exports$1.APIError = exports$1.SynapseError = exports$1.SynapseErrorCode = void 0;
|
|
26741
26741
|
exports$1.normalizeError = normalizeError;
|
|
26742
26742
|
exports$1.SynapseErrorCode = {
|
|
26743
26743
|
API: "API_ERROR",
|
|
@@ -26915,6 +26915,13 @@ var MedAssistWidget = (function(exports) {
|
|
|
26915
26915
|
}
|
|
26916
26916
|
}
|
|
26917
26917
|
exports$1.RecordingError = RecordingError;
|
|
26918
|
+
class AuthenticationError extends SynapseError {
|
|
26919
|
+
constructor(message, options = {}) {
|
|
26920
|
+
super(message, exports$1.SynapseErrorCode.AUTH, options);
|
|
26921
|
+
this.name = "AuthenticationError";
|
|
26922
|
+
}
|
|
26923
|
+
}
|
|
26924
|
+
exports$1.AuthenticationError = AuthenticationError;
|
|
26918
26925
|
class FileError extends SynapseError {
|
|
26919
26926
|
constructor(message, options = {}) {
|
|
26920
26927
|
super(message, exports$1.SynapseErrorCode.FILE, options);
|
|
@@ -27464,11 +27471,11 @@ var MedAssistWidget = (function(exports) {
|
|
|
27464
27471
|
};
|
|
27465
27472
|
var SYNAPSE_TOOL_CALLBACK_NAME;
|
|
27466
27473
|
(function(SYNAPSE_TOOL_CALLBACK_NAME2) {
|
|
27467
|
-
SYNAPSE_TOOL_CALLBACK_NAME2["DOCTOR_AVAILABILITY"] = "
|
|
27468
|
-
SYNAPSE_TOOL_CALLBACK_NAME2["AVAILABILITY_DATES"] = "
|
|
27469
|
-
SYNAPSE_TOOL_CALLBACK_NAME2["AVAILABILITY_SLOTS"] = "
|
|
27470
|
-
SYNAPSE_TOOL_CALLBACK_NAME2["MOBILE_VERIFICATION"] = "
|
|
27471
|
-
SYNAPSE_TOOL_CALLBACK_NAME2["DOCTOR_DETAILS"] = "
|
|
27474
|
+
SYNAPSE_TOOL_CALLBACK_NAME2["DOCTOR_AVAILABILITY"] = "get_doctor_availability";
|
|
27475
|
+
SYNAPSE_TOOL_CALLBACK_NAME2["AVAILABILITY_DATES"] = "get_available_dates";
|
|
27476
|
+
SYNAPSE_TOOL_CALLBACK_NAME2["AVAILABILITY_SLOTS"] = "get_available_slots";
|
|
27477
|
+
SYNAPSE_TOOL_CALLBACK_NAME2["MOBILE_VERIFICATION"] = "verify_mobile_number";
|
|
27478
|
+
SYNAPSE_TOOL_CALLBACK_NAME2["DOCTOR_DETAILS"] = "get_doctor_details";
|
|
27472
27479
|
})(SYNAPSE_TOOL_CALLBACK_NAME || (types$7.SYNAPSE_TOOL_CALLBACK_NAME = SYNAPSE_TOOL_CALLBACK_NAME = {}));
|
|
27473
27480
|
return types$7;
|
|
27474
27481
|
}
|
|
@@ -27908,7 +27915,9 @@ var MedAssistWidget = (function(exports) {
|
|
|
27908
27915
|
FILE_UPLOAD_INPROGRESS: "file_upload_inprogress",
|
|
27909
27916
|
TIMEOUT: "timeout",
|
|
27910
27917
|
SERVER_ERROR: "server_error",
|
|
27911
|
-
SESSION_TOKEN_MISMATCH: "session_token_mismatch"
|
|
27918
|
+
SESSION_TOKEN_MISMATCH: "session_token_mismatch",
|
|
27919
|
+
PROMPT_FETCH_ERROR: "prompt_fetch_error",
|
|
27920
|
+
INVALID_FILE_REQUEST: "invalid_file_request"
|
|
27912
27921
|
};
|
|
27913
27922
|
types$6.SYNAPSE_REALTIME_RESERVED_EVENTS = {
|
|
27914
27923
|
SESSION_EXPIRED: "session_expired"
|
|
@@ -28473,19 +28482,25 @@ var MedAssistWidget = (function(exports) {
|
|
|
28473
28482
|
*/
|
|
28474
28483
|
handleIncomingSocketErrorMessage(message) {
|
|
28475
28484
|
const connection = this.assertConnection("handleIncomingSocketErrorMessage");
|
|
28476
|
-
switch (message
|
|
28485
|
+
switch (message?.data?.code) {
|
|
28477
28486
|
case types_1.SYNAPSE_REALTIME_ERROR_CODES.SESSION_EXPIRED:
|
|
28478
28487
|
connection.emit(types_1.SYNAPSE_REALTIME_RESERVED_EVENTS.SESSION_EXPIRED);
|
|
28479
28488
|
break;
|
|
28489
|
+
case types_1.SYNAPSE_REALTIME_ERROR_CODES.INVALID_EVENT:
|
|
28490
|
+
console.log("invalid event error", message);
|
|
28491
|
+
break;
|
|
28480
28492
|
default:
|
|
28481
|
-
const error = new Error_1.MessageError(message
|
|
28493
|
+
const error = new Error_1.MessageError(message?.data?.msg || "Socket error received", {
|
|
28482
28494
|
context: {
|
|
28483
28495
|
stage: "handleIncomingSocketErrorMessage",
|
|
28484
|
-
errorCode: message
|
|
28485
|
-
}
|
|
28496
|
+
errorCode: message?.data?.code
|
|
28497
|
+
},
|
|
28498
|
+
hint: message?.data?.msg,
|
|
28499
|
+
cause: message,
|
|
28500
|
+
displayMessage: message?.data?.msg
|
|
28486
28501
|
});
|
|
28487
|
-
|
|
28488
|
-
|
|
28502
|
+
console.log("error from socket", error);
|
|
28503
|
+
connection.emit(types_1.SYNAPSE_REALTIME_EVENTS.ERROR, message);
|
|
28489
28504
|
}
|
|
28490
28505
|
}
|
|
28491
28506
|
/**
|
|
@@ -30337,8 +30352,26 @@ var MedAssistWidget = (function(exports) {
|
|
|
30337
30352
|
if (error instanceof distExports.SynapseError) {
|
|
30338
30353
|
switch (error.code) {
|
|
30339
30354
|
case distExports.SynapseErrorCode.SESSION:
|
|
30340
|
-
|
|
30341
|
-
|
|
30355
|
+
const errorContext = error.context;
|
|
30356
|
+
const isRefreshFailure = errorContext?.stage === "handleSessionExpiry" || errorContext?.stage === "refreshSession";
|
|
30357
|
+
if (isRefreshFailure) {
|
|
30358
|
+
if (!isOnline) {
|
|
30359
|
+
setError({
|
|
30360
|
+
title: "Session expired",
|
|
30361
|
+
description: "Please check your connection and try again"
|
|
30362
|
+
});
|
|
30363
|
+
setShowRetryButton(true);
|
|
30364
|
+
} else {
|
|
30365
|
+
setError({
|
|
30366
|
+
title: "Session not found",
|
|
30367
|
+
description: "Please start a new session"
|
|
30368
|
+
});
|
|
30369
|
+
setStartNewConnection(true);
|
|
30370
|
+
}
|
|
30371
|
+
} else {
|
|
30372
|
+
setConnectionStatus(distExports.ConnectionStatus.NOT_CONNECTED);
|
|
30373
|
+
setShowRetryButton(true);
|
|
30374
|
+
}
|
|
30342
30375
|
break;
|
|
30343
30376
|
case distExports.SynapseErrorCode.RECORDING:
|
|
30344
30377
|
setError({
|
|
@@ -30346,8 +30379,22 @@ var MedAssistWidget = (function(exports) {
|
|
|
30346
30379
|
description: error?.displayMessage || "Please try again later"
|
|
30347
30380
|
});
|
|
30348
30381
|
break;
|
|
30382
|
+
case distExports.SynapseErrorCode.CONNECTION:
|
|
30383
|
+
setError({
|
|
30384
|
+
title: "Connecting..."
|
|
30385
|
+
});
|
|
30386
|
+
setShowRetryButton(true);
|
|
30387
|
+
break;
|
|
30388
|
+
// case SynapseErrorCode.AUTH:
|
|
30389
|
+
// setError({
|
|
30390
|
+
// title: "Authentication failed",
|
|
30391
|
+
// description:
|
|
30392
|
+
// error?.displayMessage || "Please try again later",
|
|
30393
|
+
// });
|
|
30394
|
+
// window.parent.postMessage({ type: "AUTH_EXPIRED"})
|
|
30395
|
+
// break;
|
|
30349
30396
|
default:
|
|
30350
|
-
console.error("useChat: Error from SDK", error.code);
|
|
30397
|
+
console.error("useChat: Error from SDK from onError callback", error.code, error);
|
|
30351
30398
|
setError({
|
|
30352
30399
|
title: "Something went wrong",
|
|
30353
30400
|
description: "Please try again later"
|
|
@@ -30552,6 +30599,9 @@ var MedAssistWidget = (function(exports) {
|
|
|
30552
30599
|
);
|
|
30553
30600
|
return;
|
|
30554
30601
|
}
|
|
30602
|
+
if (isWaitingForResponse) {
|
|
30603
|
+
setIsWaitingForResponse(false);
|
|
30604
|
+
}
|
|
30555
30605
|
const messageId = toolCallData.messageId;
|
|
30556
30606
|
const timestamp = toolCallData.timestamp ?? Date.now();
|
|
30557
30607
|
setMessages((prevMessages) => {
|
|
@@ -30600,14 +30650,96 @@ var MedAssistWidget = (function(exports) {
|
|
|
30600
30650
|
}
|
|
30601
30651
|
});
|
|
30602
30652
|
synapseRef.current?.on(distExports.SYNAPSE_REALTIME_EVENTS.ERROR, (error) => {
|
|
30603
|
-
console.log("error from sdk", error);
|
|
30604
|
-
const
|
|
30605
|
-
|
|
30606
|
-
|
|
30607
|
-
|
|
30608
|
-
|
|
30609
|
-
|
|
30610
|
-
|
|
30653
|
+
console.log("error from sdk on ERROR event", error);
|
|
30654
|
+
const errorCode = error?.data?.code;
|
|
30655
|
+
switch (errorCode) {
|
|
30656
|
+
case distExports.SYNAPSE_REALTIME_ERROR_CODES.SESSION_INACTIVE:
|
|
30657
|
+
setError({
|
|
30658
|
+
title: "Session not found",
|
|
30659
|
+
description: "Please start a new session"
|
|
30660
|
+
});
|
|
30661
|
+
setStartNewConnection(true);
|
|
30662
|
+
setRecordingStatus(AudioRecordingStatus.IDLE);
|
|
30663
|
+
return;
|
|
30664
|
+
case distExports.SYNAPSE_REALTIME_ERROR_CODES.SESSION_EXPIRED:
|
|
30665
|
+
if (!isOnline) {
|
|
30666
|
+
setError({
|
|
30667
|
+
title: "Session expired",
|
|
30668
|
+
description: "Please check your connection and try again"
|
|
30669
|
+
});
|
|
30670
|
+
setShowRetryButton(true);
|
|
30671
|
+
} else {
|
|
30672
|
+
setError({
|
|
30673
|
+
title: "Session not found",
|
|
30674
|
+
description: "Please start a new session"
|
|
30675
|
+
});
|
|
30676
|
+
setStartNewConnection(true);
|
|
30677
|
+
}
|
|
30678
|
+
setRecordingStatus(AudioRecordingStatus.IDLE);
|
|
30679
|
+
return;
|
|
30680
|
+
case distExports.SYNAPSE_REALTIME_ERROR_CODES.SESSION_TOKEN_MISMATCH:
|
|
30681
|
+
setError({
|
|
30682
|
+
title: "Session not found",
|
|
30683
|
+
description: "Please start a new session"
|
|
30684
|
+
});
|
|
30685
|
+
setStartNewConnection(true);
|
|
30686
|
+
setRecordingStatus(AudioRecordingStatus.IDLE);
|
|
30687
|
+
return;
|
|
30688
|
+
case distExports.SYNAPSE_REALTIME_ERROR_CODES.INVALID_EVENT:
|
|
30689
|
+
console.log("invalid event error", error);
|
|
30690
|
+
return;
|
|
30691
|
+
case distExports.SYNAPSE_REALTIME_ERROR_CODES.INVALID_CONTENT_TYPE:
|
|
30692
|
+
console.log("invalid content type error", error);
|
|
30693
|
+
return;
|
|
30694
|
+
case distExports.SYNAPSE_REALTIME_ERROR_CODES.PARSING_ERROR:
|
|
30695
|
+
setError({
|
|
30696
|
+
title: "Error parsing request",
|
|
30697
|
+
description: "please try again"
|
|
30698
|
+
});
|
|
30699
|
+
setShowRetryButton(true);
|
|
30700
|
+
setRecordingStatus(AudioRecordingStatus.IDLE);
|
|
30701
|
+
return;
|
|
30702
|
+
case distExports.SYNAPSE_REALTIME_ERROR_CODES.TIMEOUT:
|
|
30703
|
+
setError({
|
|
30704
|
+
title: "Request timed out",
|
|
30705
|
+
description: "please try again"
|
|
30706
|
+
});
|
|
30707
|
+
setShowRetryButton(true);
|
|
30708
|
+
setRecordingStatus(AudioRecordingStatus.IDLE);
|
|
30709
|
+
return;
|
|
30710
|
+
case distExports.SYNAPSE_REALTIME_ERROR_CODES.PROMPT_FETCH_ERROR:
|
|
30711
|
+
setError({
|
|
30712
|
+
title: "Something went wrong",
|
|
30713
|
+
description: "please try again"
|
|
30714
|
+
});
|
|
30715
|
+
setShowRetryButton(true);
|
|
30716
|
+
setRecordingStatus(AudioRecordingStatus.IDLE);
|
|
30717
|
+
return;
|
|
30718
|
+
case distExports.SYNAPSE_REALTIME_ERROR_CODES.INVALID_FILE_REQUEST:
|
|
30719
|
+
setError({
|
|
30720
|
+
title: "Something went wrong",
|
|
30721
|
+
description: "please try again"
|
|
30722
|
+
});
|
|
30723
|
+
setShowRetryButton(true);
|
|
30724
|
+
setRecordingStatus(AudioRecordingStatus.IDLE);
|
|
30725
|
+
return;
|
|
30726
|
+
case distExports.SYNAPSE_REALTIME_ERROR_CODES.SERVER_ERROR:
|
|
30727
|
+
setError({
|
|
30728
|
+
title: "Something went wrong",
|
|
30729
|
+
description: "please try again"
|
|
30730
|
+
});
|
|
30731
|
+
setShowRetryButton(true);
|
|
30732
|
+
setRecordingStatus(AudioRecordingStatus.IDLE);
|
|
30733
|
+
return;
|
|
30734
|
+
default:
|
|
30735
|
+
setError({
|
|
30736
|
+
title: "Something went wrong",
|
|
30737
|
+
description: "please try again"
|
|
30738
|
+
});
|
|
30739
|
+
setShowRetryButton(true);
|
|
30740
|
+
setRecordingStatus(AudioRecordingStatus.IDLE);
|
|
30741
|
+
return;
|
|
30742
|
+
}
|
|
30611
30743
|
});
|
|
30612
30744
|
synapseRef.current?.on(distExports.SYNAPSE_REALTIME_EVENTS.AUDIO_TRANSCRIPT, async (data) => {
|
|
30613
30745
|
const inlineTextData = data;
|
|
@@ -41921,10 +42053,10 @@ var MedAssistWidget = (function(exports) {
|
|
|
41921
42053
|
}
|
|
41922
42054
|
}, [selectedHospital, doctor.doctor_id]);
|
|
41923
42055
|
reactExports.useEffect(() => {
|
|
41924
|
-
if (callbacks?.[distExports.SYNAPSE_TOOL_CALLBACK_NAME.AVAILABILITY_DATES] && !
|
|
42056
|
+
if (callbacks?.[distExports.SYNAPSE_TOOL_CALLBACK_NAME.AVAILABILITY_DATES] && selectedHospital && !availability[selectedHospital]?.length) {
|
|
41925
42057
|
getAvailabilityDates(callbacks[distExports.SYNAPSE_TOOL_CALLBACK_NAME.AVAILABILITY_DATES].tool_name);
|
|
41926
42058
|
}
|
|
41927
|
-
}, [callbacks,
|
|
42059
|
+
}, [callbacks, selectedHospital]);
|
|
41928
42060
|
const availabilityForSelectedHospital = reactExports.useMemo(() => {
|
|
41929
42061
|
return availability[selectedHospital] || [];
|
|
41930
42062
|
}, [availability, selectedHospital]);
|
|
@@ -42101,7 +42233,7 @@ var MedAssistWidget = (function(exports) {
|
|
|
42101
42233
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-slate-600", children: doctorDetails.hospitals?.[0].name || "" })
|
|
42102
42234
|
] })
|
|
42103
42235
|
] }),
|
|
42104
|
-
availabilityForSelectedHospital.length || loadingAvailabilityDates ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42236
|
+
availabilityForSelectedHospital.length > 0 || loadingAvailabilityDates ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42105
42237
|
Button,
|
|
42106
42238
|
{
|
|
42107
42239
|
type: "button",
|
|
@@ -42126,7 +42258,7 @@ var MedAssistWidget = (function(exports) {
|
|
|
42126
42258
|
] })
|
|
42127
42259
|
}
|
|
42128
42260
|
) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-3 w-full flex items-center justify-center py-3 px-4 bg-lavender-50 border border-lavender-200 rounded-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm text-slate-600 font-medium", children: "No details available" }) }),
|
|
42129
|
-
open && availabilityForSelectedHospital.length && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42261
|
+
open && availabilityForSelectedHospital.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
42130
42262
|
"div",
|
|
42131
42263
|
{
|
|
42132
42264
|
id: "ap-slots",
|