Filter Workforce departments to the configured location
getAllDepartments() was pulling every department across all Workforce locations, not just this hotel's — mirrors the location_id filter wages' fetchAllDepartments() already uses.
This commit is contained in:
parent
ca0dc9b070
commit
d6542f4503
1 changed files with 4 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue