35 lines
1005 B
TypeScript
35 lines
1005 B
TypeScript
import axiosInstance, { ApiKeys, getApiUrl } from '@components/utlis/apiHelper';
|
|
import {
|
|
setTrainingMaterialData,
|
|
setTrainingMaterialLoading,
|
|
} from '@reducers/trainingMaterialSlice';
|
|
import { AppDispatch } from '@store';
|
|
|
|
export const getTrainingMaterialList = () => (dispatch: AppDispatch) => {
|
|
dispatch(setTrainingMaterialLoading(true));
|
|
const url = getApiUrl(ApiKeys.GET_TRAINING_MATERIAL_LIST);
|
|
axiosInstance
|
|
.get(url)
|
|
.then((res) => {
|
|
if (res.data) {
|
|
dispatch(setTrainingMaterialLoading(false));
|
|
if (res?.data) {
|
|
dispatch(setTrainingMaterialData(res.data));
|
|
}
|
|
}
|
|
})
|
|
.finally(() => {
|
|
dispatch(setTrainingMaterialLoading(false));
|
|
});
|
|
};
|
|
|
|
export const getTrainingMaterialDetails = async (docRefId: string) => {
|
|
try {
|
|
const url = getApiUrl(ApiKeys.GET_TRAINING_MATERIAL_DETAILS, { docRefId });
|
|
const response = await axiosInstance.get(url);
|
|
return response.data;
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
};
|