import { apiDelete, apiGet, apiPatch, apiPost } from "./axios"; import type { StudyMember, UserInfo } from "../types/api"; export const listMembers = (studyId: string, params?: Record) => apiGet(`/api/v1/studies/${studyId}/members/`, { params, cache: { ttlMs: 5 * 60_000, tags: [`study:${studyId}`, `study:${studyId}:members`] }, }); export const listMemberCandidates = (studyId: string, params?: Record) => apiGet(`/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(`/api/v1/studies/${studyId}/members/`, payload); export const updateMember = ( studyId: string, memberId: string, payload: Partial<{ role_in_study: string; is_active: boolean }> ) => apiPatch(`/api/v1/studies/${studyId}/members/${memberId}`, payload); export const removeMember = (studyId: string, memberId: string) => apiDelete(`/api/v1/studies/${studyId}/members/${memberId}`);