Added Messaging and Reports pages; connected Reports to n8n.
This commit is contained in:
1 parent
697d72f379
commit
cb3325d6df
19 files changed
+3793
-21
No files matched your search
+30
-3
@@ -19,6 +19,12 @@ import {
|
||||
archiveNotification,
|
||||
} from './pocketbase.js'
|
||||
import { JUVONNO_API_URL, JUVONNO_API_KEY } from './juvonno-config.js'
|
||||
import {
|
||||
AUDIT_WEBHOOK_URL,
|
||||
AUDIT_API_KEY,
|
||||
REPORTS_WEBHOOK_URL,
|
||||
REPORTS_API_KEY,
|
||||
} from './n8n-config.js'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
@@ -161,9 +167,6 @@ ipcMain.handle('pb:archive-notification', async (_event, id, isArchived) => {
|
||||
|
||||
// ─── Health Risk Audit IPC Handler (Node-side to avoid CORS) ────────────────
|
||||
ipcMain.handle('audit:run-health-audit', async (_event, payload) => {
|
||||
const AUDIT_WEBHOOK_URL = 'https://n8n.wirediv.dev/webhook/travel-health-audit'
|
||||
const AUDIT_API_KEY = '63350077-643e-40d8-8d34-378495c81203'
|
||||
|
||||
const response = await fetch(AUDIT_WEBHOOK_URL, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -208,5 +211,29 @@ ipcMain.handle('juvonno:fetch-chart', async (_event, emrId) => {
|
||||
return await response.json()
|
||||
})
|
||||
|
||||
// ─── Reports Webhook IPC Handler (Node-side to avoid CORS) ──────────────────
|
||||
ipcMain.handle('reports:fetch-report', async (_event, payload) => {
|
||||
const response = await fetch(REPORTS_WEBHOOK_URL, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-API-Key': REPORTS_API_KEY,
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
const text = await response.text()
|
||||
if (!response.ok) {
|
||||
throw new Error(`Reports webhook returned HTTP ${response.status} ${response.statusText}${text ? ` - ${text.slice(0, 150)}` : ''}`)
|
||||
}
|
||||
|
||||
try {
|
||||
return JSON.parse(text)
|
||||
} catch {
|
||||
throw new Error(`Invalid JSON response from webhook: ${text.slice(0, 150)}`)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user