fix: take-home and translate-languages fetch URLs must be /api-prefixed
This commit is contained in:
parent
09a4e02e39
commit
2e0951995c
2 changed files with 8 additions and 8 deletions
|
|
@ -56,7 +56,7 @@ import {
|
|||
function refreshTranslateLanguages(pop) {
|
||||
if (translateLanguagesLoading) return;
|
||||
translateLanguagesLoading = true;
|
||||
fetch('/clinical-assistant/translate/languages', { headers: getAuthHeaders(), credentials: 'same-origin' })
|
||||
fetch('/api/clinical-assistant/translate/languages', { headers: getAuthHeaders(), credentials: 'same-origin' })
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(data) {
|
||||
if (data && data.success && data.languages) translateLanguagesAvailable = data.languages;
|
||||
|
|
@ -1140,7 +1140,7 @@ import {
|
|||
modal.addEventListener('click', function(event) {
|
||||
if (event.target === modal || event.target.closest('[data-assistant-takehome-close]')) closePatientTakehomeModal();
|
||||
});
|
||||
fetch('/clinical-assistant/patient-takehome', {
|
||||
fetch('/api/clinical-assistant/patient-takehome', {
|
||||
method: 'POST',
|
||||
headers: getAuthHeaders(Object.assign({ 'Content-Type': 'application/json' })),
|
||||
body: JSON.stringify({ answer: lastAnswer })
|
||||
|
|
@ -1188,7 +1188,7 @@ import {
|
|||
if (!to) { if (typeof showToast === 'function') showToast('Enter an email address', 'error'); return; }
|
||||
var btn = event.target.closest('[data-assistant-takehome-send]');
|
||||
btn.disabled = true;
|
||||
fetch('/clinical-assistant/patient-takehome/email', {
|
||||
fetch('/api/clinical-assistant/patient-takehome/email', {
|
||||
method: 'POST',
|
||||
headers: getAuthHeaders(Object.assign({ 'Content-Type': 'application/json' })),
|
||||
body: JSON.stringify({ to: to, text: takehomeText })
|
||||
|
|
|
|||
|
|
@ -138,14 +138,14 @@ function client(t, options = {}) {
|
|||
window.URL.revokeObjectURL = () => {};
|
||||
const apiFetch = async (url, options) => {
|
||||
calls.push({ url, options });
|
||||
if (url === '/clinical-assistant/patient-takehome') {
|
||||
if (url === '/api/clinical-assistant/patient-takehome') {
|
||||
return new Response(JSON.stringify({ success: true, text: options.takehomeText || 'Patient take home sheet.' }));
|
||||
}
|
||||
if (url === '/clinical-assistant/patient-takehome/email') {
|
||||
if (url === '/api/clinical-assistant/patient-takehome/email') {
|
||||
if (options.failEmail) return new Response(JSON.stringify({ error: 'Email is not configured on this server yet' }), { status: 503 });
|
||||
return new Response(JSON.stringify({ success: true }));
|
||||
}
|
||||
if (url === '/clinical-assistant/translate/languages') {
|
||||
if (url === '/api/clinical-assistant/translate/languages') {
|
||||
return new Response(JSON.stringify({ success: true, languages: { libretranslate: ['en', 'es', 'de'], deepl: ['en', 'es', 'fr'] } }));
|
||||
}
|
||||
return new Response(JSON.stringify({ success: true, chats: [] }));
|
||||
|
|
@ -181,7 +181,7 @@ test('Patient take home button opens the modal, generates, and offers Copy/Expor
|
|||
assert.ok(modal.querySelector('[data-assistant-takehome-copy]'));
|
||||
assert.ok(modal.querySelector('[data-assistant-takehome-export]'));
|
||||
assert.ok(modal.querySelector('[data-assistant-takehome-send]'));
|
||||
const call = app.calls.find(c => c.url === '/clinical-assistant/patient-takehome');
|
||||
const call = app.calls.find(c => c.url === '/api/clinical-assistant/patient-takehome');
|
||||
assert.equal(JSON.parse(call.options.body).answer, 'Answer [1].');
|
||||
});
|
||||
|
||||
|
|
@ -190,7 +190,7 @@ test('take home refuses honestly when there is no answer yet', async t => {
|
|||
app.document.getElementById('btn-assistant-takehome').click();
|
||||
await new Promise(r => setImmediate(r));
|
||||
assert.equal(app.document.getElementById('assistant-takehome-modal'), null);
|
||||
assert.equal(app.calls.filter(c => c.url === '/clinical-assistant/patient-takehome').length, 0);
|
||||
assert.equal(app.calls.filter(c => c.url === '/api/clinical-assistant/patient-takehome').length, 0);
|
||||
assert.match(app.toasts[0][0], /Ask a question first/);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue