feature: Improve dashboard functionality
This commit is contained in:
@@ -1,11 +1,30 @@
|
||||
import { api } from './client'
|
||||
|
||||
export function fetchActiveEncounters(department) {
|
||||
const params = new URLSearchParams({ status: 'ACTIVE' })
|
||||
export function fetchActiveEncounters(department, { page = 1, pageSize = 20 } = {}) {
|
||||
const params = new URLSearchParams({
|
||||
status: 'ACTIVE',
|
||||
page: String(page),
|
||||
pageSize: String(pageSize),
|
||||
})
|
||||
if (department) params.set('department', department)
|
||||
return api.get(`/api/v1/encounters?${params}`)
|
||||
}
|
||||
|
||||
export async function fetchAllActiveEncounters(department) {
|
||||
const items = []
|
||||
let page = 1
|
||||
let totalCount = 0
|
||||
|
||||
do {
|
||||
const data = await fetchActiveEncounters(department, { page, pageSize: 100 })
|
||||
items.push(...(data.items ?? []))
|
||||
totalCount = data.totalCount ?? items.length
|
||||
page += 1
|
||||
} while (items.length < totalCount)
|
||||
|
||||
return items
|
||||
}
|
||||
|
||||
export function fetchEncounter(id) {
|
||||
return api.get(`/api/v1/encounters/${id}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user