Files
ctms/frontend/src/api/members.ts
T
Cheng Zhou 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
release(main): 同步 dev 最新候选改动
2026-07-16 17:15:50 +08:00

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}`);