Added pre-travel screen; added country polygons for maps

This commit is contained in:
2026-08-10 10:52:04 -04:00
parent 08b753f89e
commit e8c69d6558
16 changed files with 7842 additions and 4109 deletions
+15 -1
View File
@@ -1,7 +1,7 @@
import { app, BrowserWindow, shell, ipcMain } from 'electron'
import { fileURLToPath } from 'node:url'
import path from 'node:path'
import { fetchEntries } from './pocketbase.js'
import { fetchEntries, createEntry, updateEntry, deleteEntry, fetchVaccines } from './pocketbase.js'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
@@ -90,3 +90,17 @@ ipcMain.handle('app:get-version', () => app.getVersion())
ipcMain.handle('pb:fetch-entries', async () => {
return await fetchEntries()
})
ipcMain.handle('pb:create-entry', async (_event, trip) => {
return await createEntry(trip)
})
ipcMain.handle('pb:update-entry', async (_event, id, trip) => {
return await updateEntry(id, trip)
})
ipcMain.handle('pb:delete-entry', async (_event, id) => {
return await deleteEntry(id)
})
ipcMain.handle('pb:fetch-vaccines', async () => {
return await fetchVaccines()
})
+68 -1
View File
@@ -2,6 +2,7 @@ import PocketBase from 'pocketbase'
import { POCKETBASE_URL, PB_ADMIN_EMAIL, PB_ADMIN_PASSWORD } from './pocketbase-config.js'
const COLLECTION = 'travellers'
const VACCINES_COLLECTION = 'vaccines'
let pb = null
let authPromise = null
@@ -18,7 +19,8 @@ function getClient() {
function parseEntry(r) {
return {
id: r.emr_id,
id: r.id,
emrID: r.emr_id ?? '',
name: r.name ?? '',
location: r.location ?? '',
countryISO: r.country_iso ?? '',
@@ -58,3 +60,68 @@ export async function fetchEntries() {
return list.map(parseEntry)
}
export async function createEntry(trip) {
await ensureAuth()
const payload = {
name: trip.name,
location: trip.location,
countries_iso: trip.countriesISO,
departure: trip.departure,
arrival: trip.arrival,
}
if (trip.emrID !== undefined && trip.emrID !== null && trip.emrID !== '') {
const emrNum = Number(trip.emrID)
payload.emr_id = !isNaN(emrNum) ? emrNum : trip.emrID
}
const record = await getClient().collection(COLLECTION).create(payload)
return parseEntry(record)
}
export async function updateEntry(id, trip) {
await ensureAuth()
const payload = {
name: trip.name,
location: trip.location,
countries_iso: trip.countriesISO,
departure: trip.departure,
arrival: trip.arrival,
}
if (trip.emrID !== undefined && trip.emrID !== null && trip.emrID !== '') {
const emrNum = Number(trip.emrID)
payload.emr_id = !isNaN(emrNum) ? emrNum : trip.emrID
} else if (trip.emrID === '') {
payload.emr_id = null
}
const record = await getClient().collection(COLLECTION).update(id, payload)
return parseEntry(record)
}
export async function deleteEntry(id) {
await ensureAuth()
await getClient().collection(COLLECTION).delete(id)
}
/**
* Fetches all records from the vaccines collection.
* Returns raw records with all fields preserved.
*/
export async function fetchVaccines() {
await ensureAuth()
const list = await getClient().collection(VACCINES_COLLECTION).getFullList({ sort: 'name' })
return list.map((r) => ({
id: r.id,
name: r.name ?? '',
vaccine_type: r.vaccine_type ?? '',
total_doses: r.total_doses ?? 1,
dose_intervals: r.dose_intervals ?? [],
min_days_before_travel: r.min_days_before_travel ?? 0,
allows_grace_period: r.allows_grace_period ?? false,
has_accelerated_schedule: r.has_accelerated_schedule ?? false,
requires_icvp_certificate: r.requires_icvp_certificate ?? false,
created: r.created,
updated: r.updated,
}))
}
+12
View File
@@ -16,6 +16,10 @@ const ALLOWED_SEND_CHANNELS = [
'schedule:fetch',
'app:ready',
'pb:fetch-entries',
'pb:create-entry',
'pb:update-entry',
'pb:delete-entry',
'pb:fetch-vaccines',
]
const ALLOWED_RECEIVE_CHANNELS = [
@@ -24,6 +28,10 @@ const ALLOWED_RECEIVE_CHANNELS = [
'schedule:response',
'app:get-version',
'pb:fetch-entries',
'pb:create-entry',
'pb:update-entry',
'pb:delete-entry',
'pb:fetch-vaccines',
]
// ─── Exposed API ──────────────────────────────────────────────────────────
@@ -33,6 +41,10 @@ contextBridge.exposeInMainWorld('api', {
*/
pb: {
fetchEntries: () => ipcRenderer.invoke('pb:fetch-entries'),
createEntry: (trip) => ipcRenderer.invoke('pb:create-entry', trip),
updateEntry: (id, trip) => ipcRenderer.invoke('pb:update-entry', id, trip),
deleteEntry: (id) => ipcRenderer.invoke('pb:delete-entry', id),
fetchVaccines: () => ipcRenderer.invoke('pb:fetch-vaccines'),
},
/**