From d6542f4503adf7b24d098793647a0bc8be3e851f Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Sun, 26 Jul 2026 09:05:04 +0000 Subject: [PATCH] Filter Workforce departments to the configured location MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit getAllDepartments() was pulling every department across all Workforce locations, not just this hotel's — mirrors the location_id filter wages' fetchAllDepartments() already uses. --- backend/src/lib/workforce.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/lib/workforce.js b/backend/src/lib/workforce.js index 0a41e99..d46aa41 100644 --- a/backend/src/lib/workforce.js +++ b/backend/src/lib/workforce.js @@ -58,7 +58,10 @@ export async function findEmployeeByEmail(email) { export async function getAllDepartments() { if (_deptsCache && Date.now() < _deptsCache.expires_at) return _deptsCache.depts - const depts = await wfFetchPaged('/api/v2/departments') + const creds = await getWorkforceCreds() + const locationId = creds.location_id ? String(creds.location_id) : null + const all = await wfFetchPaged('/api/v2/departments') + const depts = locationId ? all.filter(d => String(d.location_id) === locationId) : all _deptsCache = { depts, expires_at: Date.now() + 5 * 60_000 } return depts }