Ver código fonte

fix(patient-register): clear pending and selected position lists when exiting register process
close #42

sw 1 mês atrás
pai
commit
731dcb6faa

+ 8 - 0
src/API/patient/viewActions.ts

@@ -117,6 +117,14 @@ export const fetchViewDetail = async (id: string): Promise<View> => {
   return response.data.data;
 };
 
+export const fetchViewsByProcedureId = async (
+  procedure_id: string
+): Promise<View[]> => {
+  const response = await axiosInstance.get(
+    `/auth/protocol/procedure/${procedure_id}/view`
+  );
+  return response.data.data.views;
+};
 export const deleteBodyPosition = async (
   sop_instance_uid: string
 ): Promise<void> => {

+ 7 - 3
src/states/patient/viewSelection/index.ts

@@ -8,7 +8,11 @@ import {
 } from '@/states/patient/register/SelectionTypeSlice';
 import { setCurrentBodyPart } from '../../bodyPartSlice';
 import { fetchProcedures, Procedure } from '@/API/patient/procedureActions';
-import { fetchViews, View } from '@/API/patient/viewActions';
+import {
+  fetchViews,
+  View,
+  fetchViewsByProcedureId as fetchViewsByProcedureIdAction,
+} from '@/API/patient/viewActions';
 export type { Procedure, View };
 import { v4 as uuidv4 } from 'uuid';
 
@@ -76,8 +80,8 @@ export const fetchViewsByProcedureId = createAsyncThunk(
   'data/fetchViewsByProcedureId',
   async (procedureId: string, { rejectWithValue }) => {
     try {
-      const response = await fetchViews(null, null, true, procedureId);
-      return response.data.views;
+      const views = await fetchViewsByProcedureIdAction(procedureId);
+      return views;
     } catch (error) {
       return rejectWithValue(error.message);
     }