Browse Source

优化代码,清理bodyPart patientType 这两个api不再使用的参数

dengdx 2 months ago
parent
commit
048156cf14

+ 1 - 9
src/API/bodyPart.ts

@@ -21,15 +21,7 @@ export interface BodyPart {
 }
 }
 
 
 export async function fetchBodyParts(
 export async function fetchBodyParts(
-  params: BodyPartParams,
-
-  token: string,
-  // eslint-disable-next-line
-  language = 'en',
-  // eslint-disable-next-line
-  product = 'DROS',
-  // eslint-disable-next-line
-  source = 'Electron'
+  params: BodyPartParams
 ): Promise<BodyPart[]> {
 ): Promise<BodyPart[]> {
   const response = await axiosInstance.get('/auth/protocol/body_part', {
   const response = await axiosInstance.get('/auth/protocol/body_part', {
     params,
     params,

+ 2 - 14
src/API/patientType.ts

@@ -25,20 +25,8 @@ export interface PatientTypeResponse {
   };
   };
 }
 }
 
 
-export async function fetchPatientTypes(
-  params: PatientTypeParams,
-
-  token: string,
-  // eslint-disable-next-line
-  language = 'en',
-  // eslint-disable-next-line
-  product = 'DROS',
-  // eslint-disable-next-line
-  source = 'Electron'
-): Promise<PatientType[]> {
-  const response = await axiosInstance.get('/auth/protocol/patient_type', {
-    params,
-  });
+export async function fetchPatientTypes(): Promise<PatientType[]> {
+  const response = await axiosInstance.get('/auth/protocol/patient_type');
   // 兼容接口返回结构
   // 兼容接口返回结构
   if (
   if (
     response.data &&
     response.data &&

+ 1 - 2
src/pages/demo/AppInitializer.tsx

@@ -15,11 +15,10 @@ const AppInitializer: React.FC<AppInitializerProps> = ({ onInitialized }) => {
   useEffect(() => {
   useEffect(() => {
     const fetchData = async () => {
     const fetchData = async () => {
       if (userInfo && userInfo.token) {
       if (userInfo && userInfo.token) {
-        await dispatch(getPatientTypes({ params: {}, token: userInfo.token }));
+        await dispatch(getPatientTypes());
         await dispatch(
         await dispatch(
           getBodyParts({
           getBodyParts({
             params: {},
             params: {},
-            token: userInfo.token,
           })
           })
         );
         );
       }
       }

+ 2 - 5
src/states/bodyPartSlice.ts

@@ -21,12 +21,9 @@ const initialState: BodyPartState = {
 
 
 export const getBodyParts = createAsyncThunk(
 export const getBodyParts = createAsyncThunk(
   'bodyPart/getBodyParts',
   'bodyPart/getBodyParts',
-  async (
-    { params, token }: { params: BodyPartParams; token: string },
-    { rejectWithValue }
-  ) => {
+  async ({ params }: { params: BodyPartParams }, { rejectWithValue }) => {
     try {
     try {
-      const data = await fetchBodyParts(params, token);
+      const data = await fetchBodyParts(params);
       return data;
       return data;
     } catch (err: unknown) {
     } catch (err: unknown) {
       let errorMessage = 'Failed to fetch body parts';
       let errorMessage = 'Failed to fetch body parts';

+ 3 - 11
src/states/patientTypeSlice.ts

@@ -4,11 +4,7 @@ import {
   createAction,
   createAction,
   PayloadAction,
   PayloadAction,
 } from '@reduxjs/toolkit';
 } from '@reduxjs/toolkit';
-import {
-  fetchPatientTypes,
-  PatientType,
-  PatientTypeParams,
-} from '../API/patientType';
+import { fetchPatientTypes, PatientType } from '../API/patientType';
 import { AxiosError } from 'axios';
 import { AxiosError } from 'axios';
 
 
 interface PatientTypeState {
 interface PatientTypeState {
@@ -35,14 +31,10 @@ export const patientTypeChanged = createAction<PatientType | null>(
 
 
 export const getPatientTypes = createAsyncThunk(
 export const getPatientTypes = createAsyncThunk(
   'patientType/getPatientTypes',
   'patientType/getPatientTypes',
-  async (
-    { params, token }: { params: PatientTypeParams; token: string },
-    { rejectWithValue }
-  ) => {
+  async (_, { rejectWithValue }) => {
     try {
     try {
       console.log('Fetching patient types with params:');
       console.log('Fetching patient types with params:');
-
-      const data = await fetchPatientTypes(params, token);
+      const data = await fetchPatientTypes();
       return data;
       return data;
     } catch (err: unknown) {
     } catch (err: unknown) {
       let errorMessage = 'Failed to fetch patient types';
       let errorMessage = 'Failed to fetch patient types';