Commit 9fe76f9e authored by janithgamage1.ed's avatar janithgamage1.ed

fix: update

Desc : update project
parent 6d4db559
......@@ -21,13 +21,15 @@ import {
import usePagination from 'hooks/usePagination';
import CurriculumCard from 'sections/learning-management/learning-curriculums/CurriculumCard';
import EmptyCurriculumCard from 'sections/learning-management/learning-curriculums/skeleton/EmptyCurriculumCard';
import { useDispatch, useSelector } from 'store';
import { fetchCurriculums, toInitialState } from 'store/reducers/curriculum';
import { openSnackbar } from 'store/reducers/snackbar';
import { curriculumType } from 'types/curriculum';
import { GlobalFilter } from 'utils/react-table';
// types
// assets
import { curriculums } from 'data/curriculums';
// assets
// ==============================|| List ||============================== //
......@@ -43,6 +45,9 @@ const allColumns = [
];
const List = () => {
const dispatch = useDispatch();
const { curriculums, error, success, isLoading } = useSelector(state => state.curriculum);
const [data, setData] = useState<curriculumType[]>([])
const matchDownSM = useMediaQuery((theme: Theme) => theme.breakpoints.down('sm'));
......@@ -78,10 +83,60 @@ const List = () => {
setPage(p);
_DATA.jump(p);
};
/**
* API Config
* Curriculum API
*/
useEffect(() => {
dispatch(fetchCurriculums());
}, [dispatch]);
useEffect(() => {
setData(curriculums)
}, [])
setData(curriculums);
}, [curriculums])
// handel error
useEffect(() => {
if (error != null) {
dispatch(
openSnackbar({
open: true,
//@ts-ignore
message: error ? error.Message : "Something went wrong ...",
variant: 'alert',
alert: {
color: 'error'
},
close: true
})
);
dispatch(toInitialState())
}
}, [error])
// handel success
useEffect(() => {
if (success != null) {
dispatch(
openSnackbar({
open: true,
message: success,
variant: 'alert',
alert: {
color: 'success'
},
close: true
})
);
dispatch(toInitialState())
}
}, [success])
if (isLoading) {
return <div>Loading...</div>;
}
return (
<>
......
......@@ -300,8 +300,8 @@ const List = () => {
//alert model
const [openAlert, setOpenAlert] = useState(false);
const [curriculumId, setCurriculumId] = useState< string | undefined>(undefined)
const [curriculumTitle, setCurriculumTitle] = useState< string | undefined>(undefined)
const [curriculumId, setCurriculumId] = useState<string | undefined>(undefined)
const [curriculumTitle, setCurriculumTitle] = useState<string | undefined>(undefined)
const handleAlertClose = () => {
setOpenAlert(!openAlert);
......@@ -309,7 +309,7 @@ const List = () => {
/**
* API Config
* Tutorial API
* Curriculum API
*/
useEffect(() => {
dispatch(fetchCurriculums());
......
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