Commit 0dbfe927 authored by Janith Gamage's avatar Janith Gamage

fix: update

parent a87c7a22
...@@ -41,11 +41,17 @@ const slice = createSlice({ ...@@ -41,11 +41,17 @@ const slice = createSlice({
state.isLoading = false; state.isLoading = false;
}, },
// POST USER // POST marksCalculatorSuccess
marksCalculatorSuccess(state, action) { marksCalculatorSuccess(state, action) {
state.marksCalculator = action.payload.result; state.marksCalculator = action.payload.result;
state.success = "Marks Calculated Successfully." state.success = "Marks Calculated Successfully."
}, },
// POST default marksCalculatorSuccess
defaultMarksCalculatorSuccess(state, action) {
state.marksCalculator = action.payload.result;
state.success = "Marks Calculated Successfully."
},
} }
}); });
...@@ -77,7 +83,6 @@ export function CalculateMarks(curriculumIndex: number, tutorialIndex: number, i ...@@ -77,7 +83,6 @@ export function CalculateMarks(curriculumIndex: number, tutorialIndex: number, i
dispatch(slice.actions.startLoading()); dispatch(slice.actions.startLoading());
try { try {
// Construct the request body as needed (e.g., for formData)
const formData = new FormData(); const formData = new FormData();
formData.append('image', imageData); formData.append('image', imageData);
formData.append('class', targetClass); formData.append('class', targetClass);
...@@ -91,3 +96,29 @@ export function CalculateMarks(curriculumIndex: number, tutorialIndex: number, i ...@@ -91,3 +96,29 @@ export function CalculateMarks(curriculumIndex: number, tutorialIndex: number, i
} }
}; };
}; };
/**
* POST Default Marks Calculator
* @param original_image
* @param user_input_image
* @returns
*/
export function DefaultCalculateMarks(original_image: any, user_input_image: any) {
return async () => {
dispatch(slice.actions.startLoading());
try {
const formData = new FormData();
formData.append('original_image', original_image);
formData.append('user_input_image', user_input_image);
const response = await axiosServices.post(`/rest_node/marks-calculator/default`, formData);
dispatch(slice.actions.marksCalculatorSuccess(response.data));
} catch (error) {
dispatch(slice.actions.hasError(error));
} finally {
dispatch(slice.actions.finishLoading());
}
};
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment