add + remove users from organisation

This commit is contained in:
Oliver Bryan
2026-01-01 10:46:54 +00:00
parent 8511c6472c
commit 63fef4a0e9
20 changed files with 560 additions and 32 deletions

View File

@@ -0,0 +1,32 @@
import { getAuthHeaders, getServerURL } from "@/lib/utils";
import type { ServerQueryInput } from "..";
export async function addMember({
organisationId,
userId,
role = "member",
onSuccess,
onError,
}: {
organisationId: number;
userId: number;
role?: string;
} & ServerQueryInput) {
const url = new URL(`${getServerURL()}/organisation/add-member`);
url.searchParams.set("organisationId", `${organisationId}`);
url.searchParams.set("userId", `${userId}`);
url.searchParams.set("role", role);
const res = await fetch(url.toString(), {
method: "POST",
headers: getAuthHeaders(),
});
if (!res.ok) {
const error = await res.text();
onError?.(error || `failed to add member (${res.status})`);
} else {
const data = await res.json();
onSuccess?.(data, res);
}
}