32 lines
881 B
TypeScript
32 lines
881 B
TypeScript
import { apiFetch, type ApiSettings } from "@govoplan/core-webui";
|
|
|
|
export type ActingContext = {
|
|
assignment_id: string;
|
|
acting_for_account_id: string;
|
|
function_id: string;
|
|
organization_unit_id: string;
|
|
valid_from?: string | null;
|
|
valid_until?: string | null;
|
|
};
|
|
|
|
export type ActingContextList = {
|
|
contexts: ActingContext[];
|
|
active_assignment_id?: string | null;
|
|
};
|
|
|
|
export function fetchActingContexts(settings: ApiSettings): Promise<ActingContextList> {
|
|
return apiFetch<ActingContextList>(settings, "/api/v1/auth/acting-contexts", {
|
|
cache: "no-store"
|
|
});
|
|
}
|
|
|
|
export function switchActingContext(
|
|
settings: ApiSettings,
|
|
assignmentId: string | null
|
|
): Promise<ActingContextList> {
|
|
return apiFetch<ActingContextList>(settings, "/api/v1/auth/switch-acting-context", {
|
|
method: "POST",
|
|
body: JSON.stringify({ assignment_id: assignmentId })
|
|
});
|
|
}
|