Commit 2d00907a authored by janithgamage1.ed's avatar janithgamage1.ed

fix: update

desc : update project
parent e3c48555
import { exec } from "child_process"; import { exec } from "child_process";
import multer from "multer"
export const marksCalculator = async (req, res) => { export const marksCalculator = async (req, res) => {
const imageData = req.file.buffer.toString('base64'); const imageData = req.file.buffer.toString('base64');
......
...@@ -10,6 +10,7 @@ import chat from './chat'; ...@@ -10,6 +10,7 @@ import chat from './chat';
import ingredient from './ingredient'; import ingredient from './ingredient';
import invoice from './invoice'; import invoice from './invoice';
import kanban from './kanban'; import kanban from './kanban';
import marksCalculator from './marksCalculator';
import menu from './menu'; import menu from './menu';
import nutrition from './nutrition'; import nutrition from './nutrition';
import productReducer from './product'; import productReducer from './product';
...@@ -37,7 +38,8 @@ const reducers = combineReducers({ ...@@ -37,7 +38,8 @@ const reducers = combineReducers({
invoice, invoice,
nutrition, nutrition,
ingredient, ingredient,
subscription subscription,
marksCalculator
}); });
export default reducers; export default reducers;
// third-party
import { createSlice } from '@reduxjs/toolkit';
// project imports
import { axiosServices } from 'utils/axios';
import { dispatch } from '../index';
// types
import { DefaultRootStateProps } from 'types/marksCalculator';
// ----------------------------------------------------------------------
const initialState: DefaultRootStateProps['marksCalculator'] = {
error: null,
success: null,
marksCalculator: null,
isLoading: false
};
const slice = createSlice({
name: 'marksCalculator',
initialState,
reducers: {
// TO INITIAL STATE
hasInitialState(state) {
state.error = null;
state.success = null;
state.isLoading = false;
},
// HAS ERROR
hasError(state, action) {
state.error = action.payload;
},
startLoading(state) {
state.isLoading = true;
},
finishLoading(state) {
state.isLoading = false;
},
// POST USER
marksCalculatorSuccess(state, action) {
state.marksCalculator = action.payload.result;
state.success = "Marks Calculated Successfully."
},
}
});
// Reducer
export default slice.reducer;
// ----------------------------------------------------------------------
/**
* TO INITIAL STATE
* @returns
*/
export function toInitialState() {
return async () => {
dispatch(slice.actions.hasInitialState())
}
}
/**
* POST Marks Calculator
* @param curriculumIndex
* @param tutorialIndex
* @param imageData
* @param targetClass
* @returns
*/
export function marksCalculator(curriculumIndex: number, tutorialIndex: number, imageData: any, targetClass: string) {
return async () => {
dispatch(slice.actions.startLoading());
try {
// Construct the request body as needed (e.g., for formData)
const formData = new FormData();
formData.append('image', imageData);
formData.append('class', targetClass);
const response = await axiosServices.post(`/marks-calculator/curriculum/${curriculumIndex}/tutorial/${tutorialIndex}`, formData);
dispatch(slice.actions.marksCalculatorSuccess(response.data));
} catch (error) {
dispatch(slice.actions.hasError(error));
} finally {
dispatch(slice.actions.finishLoading());
}
};
};
// Marks Calculator Type
export type MarksCalculator = {
predicted_class_name: string,
confidence: string,
status: string
};
export interface MarksCalculatorProps {
marksCalculator: MarksCalculator | null;
error: object | string | null;
success: object | string | null;
isLoading: boolean
}
export interface DefaultRootStateProps {
marksCalculator: MarksCalculatorProps;
}
\ No newline at end of file
# Project ID: 2023-029 # Project ID: 2023-029
### test
# Project Name: “Sign Language Translation with emotional base multi model,3D Avatar and Adaptive Learning.” # Project Name: “Sign Language Translation with emotional base multi model,3D Avatar and Adaptive Learning.”
## Main Objective ## Main Objective
......
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