d5279b124f
Storage Persistence Guard / storage-persistence-audit (push) Has been cancelled
Client Quality Gates / Shared client and Web (push) Has been cancelled
Client Quality Gates / macOS Desktop (push) Has been cancelled
Client Quality Gates / Shared client and Web (pull_request) Has been cancelled
Client Quality Gates / macOS Desktop (pull_request) Has been cancelled
Storage Persistence Guard / storage-persistence-audit (pull_request) Has been cancelled
28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
import { apiDelete, apiGet, apiPatch, apiPost } from "./axios";
|
|
import type { StudyMember, UserInfo } from "../types/api";
|
|
|
|
export const listMembers = (studyId: string, params?: Record<string, any>) =>
|
|
apiGet<StudyMember[] | { items: StudyMember[] }>(`/api/v1/studies/${studyId}/members/`, {
|
|
params,
|
|
cache: { ttlMs: 5 * 60_000, tags: [`study:${studyId}`, `study:${studyId}:members`] },
|
|
});
|
|
|
|
export const listMemberCandidates = (studyId: string, params?: Record<string, any>) =>
|
|
apiGet<UserInfo[]>(`/api/v1/studies/${studyId}/members/candidates`, {
|
|
params,
|
|
suppressErrorMessage: true,
|
|
cache: { ttlMs: 60_000, tags: [`study:${studyId}`, `study:${studyId}:members`] },
|
|
});
|
|
|
|
export const addMember = (studyId: string, payload: { user_id: string; role_in_study: string; is_active?: boolean }) =>
|
|
apiPost<StudyMember>(`/api/v1/studies/${studyId}/members/`, payload);
|
|
|
|
export const updateMember = (
|
|
studyId: string,
|
|
memberId: string,
|
|
payload: Partial<{ role_in_study: string; is_active: boolean }>
|
|
) => apiPatch<StudyMember>(`/api/v1/studies/${studyId}/members/${memberId}`, payload);
|
|
|
|
export const removeMember = (studyId: string, memberId: string) =>
|
|
apiDelete<StudyMember>(`/api/v1/studies/${studyId}/members/${memberId}`);
|