15 lines
462 B
TypeScript
15 lines
462 B
TypeScript
import { z } from "zod";
|
|
import type { KyInstance } from "ky";
|
|
import { StaffSchema, type Staff } from "./types.js";
|
|
|
|
export async function fetchStaffs(
|
|
client: KyInstance,
|
|
external: boolean = false
|
|
): Promise<Staff[]> {
|
|
const response = await client.get("api/easo/common/staffs", {
|
|
searchParams: { external: String(external) },
|
|
});
|
|
const json = (await response.json()) as { data: unknown };
|
|
return z.array(StaffSchema).parse(json.data ?? []);
|
|
}
|