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 }