Initial commit: HK Planner app

Housekeeping workload and hours planning app — port of the WP hotel
housekeeping hours calculator plugin. 7-day occupancy planner with
Newbook PMS integration, staff rota, time requirements, and pickup tracking.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-02 09:24:14 +00:00
commit 4abae5eda1
28 changed files with 2475 additions and 0 deletions

26
backend/src/db.js Normal file
View file

@ -0,0 +1,26 @@
import pg from 'pg'
const { Pool } = pg
export const pool = new Pool({ connectionString: process.env.DATABASE_URL })
export async function initDb() {
await pool.query(`
CREATE TABLE IF NOT EXISTS hk_config (
key TEXT PRIMARY KEY,
value JSONB NOT NULL DEFAULT 'null'::jsonb
)
`)
}
export async function getConfig(key, defaultVal = null) {
const { rows } = await pool.query('SELECT value FROM hk_config WHERE key = $1', [key])
return rows.length ? rows[0].value : defaultVal
}
export async function setConfig(key, value) {
await pool.query(
`INSERT INTO hk_config (key, value) VALUES ($1, $2::jsonb)
ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value`,
[key, JSON.stringify(value)]
)
}