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)}`)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Configuration for n8n Integration.
|
||||
* Replace webhook URLs and API keys with actual values provided by n8n.
|
||||
*/
|
||||
|
||||
// n8n API Key
|
||||
export const API_KEY = '63350077-643e-40d8-8d34-378495c81203'
|
||||
|
||||
// Travel Health Risk Audit Webhook
|
||||
export const AUDIT_WEBHOOK_URL = 'https://n8n.wirediv.dev/webhook/travel-health-audit'
|
||||
export const AUDIT_API_KEY = API_KEY
|
||||
|
||||
// Reports & Revenue Progression Webhook
|
||||
export const REPORTS_WEBHOOK_URL = 'https://n8n.wirediv.dev/webhook/ctm-reports'
|
||||
export const REPORTS_API_KEY = API_KEY
|
||||
@@ -32,6 +32,7 @@ const ALLOWED_SEND_CHANNELS = [
|
||||
'pb:archive-notification',
|
||||
'audit:run-health-audit',
|
||||
'juvonno:fetch-chart',
|
||||
'reports:fetch-report',
|
||||
]
|
||||
|
||||
const ALLOWED_RECEIVE_CHANNELS = [
|
||||
@@ -56,6 +57,7 @@ const ALLOWED_RECEIVE_CHANNELS = [
|
||||
'pb:archive-notification',
|
||||
'audit:run-health-audit',
|
||||
'juvonno:fetch-chart',
|
||||
'reports:fetch-report',
|
||||
]
|
||||
|
||||
// ─── Exposed API ──────────────────────────────────────────────────────────
|
||||
@@ -95,6 +97,13 @@ contextBridge.exposeInMainWorld('api', {
|
||||
fetchChart: (emrId) => ipcRenderer.invoke('juvonno:fetch-chart', emrId),
|
||||
},
|
||||
|
||||
/**
|
||||
* Reports helper methods
|
||||
*/
|
||||
reports: {
|
||||
fetchReport: (payload) => ipcRenderer.invoke('reports:fetch-report', payload),
|
||||
},
|
||||
|
||||
/**
|
||||
* Send a one-way message to the main process.
|
||||
* @param {string} channel - Must be in ALLOWED_SEND_CHANNELS
|
||||
|
||||
Reference in new issue
Block a user