管理后台前后端逻辑、UI美化
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
import { apiGet, apiPatch, apiPost } from "./axios";
|
||||
import { apiDelete, apiGet, apiPatch, apiPost } from "./axios";
|
||||
import type { ApiListResponse, Site } from "../types/api";
|
||||
|
||||
export const fetchSites = (studyId: string, params?: Record<string, any>) =>
|
||||
apiGet<ApiListResponse<Site> | Site[]>(`/api/v1/studies/${studyId}/sites/`, { params });
|
||||
apiGet<ApiListResponse<Site> | Site[]>(`/api/v1/studies/${studyId}/sites/`, {
|
||||
params: { include_inactive: true, ...(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);
|
||||
|
||||
export const deleteSite = (studyId: string, siteId: string) =>
|
||||
apiDelete<void>(`/api/v1/studies/${studyId}/sites/${siteId}`);
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
import { apiGet, apiPatch, apiPost } from "./axios";
|
||||
import { apiGet, apiPatch, apiPost, apiDelete } 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 }) =>
|
||||
export const createStudy = (payload: Partial<Study> & { 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}`);
|
||||
|
||||
export const deleteStudy = (studyId: string) =>
|
||||
apiDelete(`/api/v1/studies/${studyId}`);
|
||||
|
||||
export const lockStudy = (studyId: string) =>
|
||||
apiPatch<Study>(`/api/v1/studies/${studyId}/lock`, {});
|
||||
|
||||
|
||||
@@ -20,5 +20,5 @@ export const updateUser = (
|
||||
) =>
|
||||
apiPatch<UserInfo>(`/api/v1/users/${userId}`, payload);
|
||||
|
||||
export const deleteUser = (userId: string, payload: { admin_password: string }) =>
|
||||
apiDelete<void>(`/api/v1/users/${userId}`, { data: payload });
|
||||
export const deleteUser = (userId: string) =>
|
||||
apiDelete<void>(`/api/v1/users/${userId}`);
|
||||
|
||||
Reference in New Issue
Block a user