增加admin管理帐号和项目的界面--初步实现
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { apiDelete, apiGet, apiPatch, apiPost } from "./axios";
|
||||
import type { StudyMember } from "../types/api";
|
||||
|
||||
export const listMembers = (studyId: string) =>
|
||||
apiGet<StudyMember[]>(`/api/v1/studies/${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}`);
|
||||
@@ -1,5 +1,11 @@
|
||||
import { apiGet } from "./axios";
|
||||
import type { ApiListResponse } from "../types/api";
|
||||
import { apiGet, apiPatch, apiPost } from "./axios";
|
||||
import type { ApiListResponse, Site } from "../types/api";
|
||||
|
||||
export const fetchSites = (studyId: string, params?: Record<string, any>) =>
|
||||
apiGet<ApiListResponse<any>>(`/api/v1/studies/${studyId}/sites/`, { params });
|
||||
apiGet<ApiListResponse<Site> | Site[]>(`/api/v1/studies/${studyId}/sites/`, { params });
|
||||
|
||||
export const createSite = (studyId: string, payload: Partial<Site> & { name: string }) =>
|
||||
apiPost<Site>(`/api/v1/studies/${studyId}/sites/`, payload);
|
||||
|
||||
export const updateSite = (studyId: string, siteId: string, payload: Partial<Site>) =>
|
||||
apiPatch<Site>(`/api/v1/studies/${studyId}/sites/${siteId}`, payload);
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
import { apiGet } from "./axios";
|
||||
import { apiGet, apiPatch, apiPost } from "./axios";
|
||||
import type { ApiListResponse, Study } from "../types/api";
|
||||
|
||||
// Backend expects trailing slash to avoid 307 redirect
|
||||
export const fetchStudies = () => apiGet<ApiListResponse<Study>>("/api/v1/studies/");
|
||||
|
||||
export const createStudy = (payload: Partial<Study> & { code: string; name: string }) =>
|
||||
apiPost<Study>("/api/v1/studies/", payload);
|
||||
|
||||
export const updateStudy = (studyId: string, payload: Partial<Study>) =>
|
||||
apiPatch<Study>(`/api/v1/studies/${studyId}`, payload);
|
||||
|
||||
export const fetchStudyDetail = (studyId: string) => apiGet<Study>(`/api/v1/studies/${studyId}`);
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { apiGet } from "./axios";
|
||||
import type { ApiListResponse } from "../types/api";
|
||||
import { apiGet, apiPatch, apiPost } from "./axios";
|
||||
import type { ApiListResponse, UserInfo } from "../types/api";
|
||||
|
||||
export const fetchUsers = (params?: Record<string, any>) =>
|
||||
apiGet<ApiListResponse<any>>("/api/v1/users", { params });
|
||||
apiGet<ApiListResponse<UserInfo>>("/api/v1/users", { params });
|
||||
|
||||
export const createUser = (payload: { username: string; password: string; role: string }) =>
|
||||
apiPost<UserInfo>("/api/v1/users", payload);
|
||||
|
||||
export const updateUser = (userId: string, payload: Partial<{ role: string; is_active: boolean; password: string }>) =>
|
||||
apiPatch<UserInfo>(`/api/v1/users/${userId}`, payload);
|
||||
|
||||
Reference in New Issue
Block a user