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

fix: update

Desc : update project
parent 6d4db559
...@@ -21,13 +21,15 @@ import { ...@@ -21,13 +21,15 @@ import {
import usePagination from 'hooks/usePagination'; import usePagination from 'hooks/usePagination';
import CurriculumCard from 'sections/learning-management/learning-curriculums/CurriculumCard'; import CurriculumCard from 'sections/learning-management/learning-curriculums/CurriculumCard';
import EmptyCurriculumCard from 'sections/learning-management/learning-curriculums/skeleton/EmptyCurriculumCard'; 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 { curriculumType } from 'types/curriculum';
import { GlobalFilter } from 'utils/react-table'; import { GlobalFilter } from 'utils/react-table';
// types // types
// assets // assets
import { curriculums } from 'data/curriculums';
// ==============================|| List ||============================== // // ==============================|| List ||============================== //
...@@ -43,6 +45,9 @@ const allColumns = [ ...@@ -43,6 +45,9 @@ const allColumns = [
]; ];
const List = () => { const List = () => {
const dispatch = useDispatch();
const { curriculums, error, success, isLoading } = useSelector(state => state.curriculum);
const [data, setData] = useState<curriculumType[]>([]) const [data, setData] = useState<curriculumType[]>([])
const matchDownSM = useMediaQuery((theme: Theme) => theme.breakpoints.down('sm')); const matchDownSM = useMediaQuery((theme: Theme) => theme.breakpoints.down('sm'));
...@@ -79,9 +84,59 @@ const List = () => { ...@@ -79,9 +84,59 @@ const List = () => {
_DATA.jump(p); _DATA.jump(p);
}; };
/**
* API Config
* Curriculum API
*/
useEffect(() => {
dispatch(fetchCurriculums());
}, [dispatch]);
useEffect(() => {
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(() => { useEffect(() => {
setData(curriculums) 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 ( return (
<> <>
......
...@@ -300,8 +300,8 @@ const List = () => { ...@@ -300,8 +300,8 @@ const List = () => {
//alert model //alert model
const [openAlert, setOpenAlert] = useState(false); const [openAlert, setOpenAlert] = useState(false);
const [curriculumId, setCurriculumId] = useState< string | undefined>(undefined) const [curriculumId, setCurriculumId] = useState<string | undefined>(undefined)
const [curriculumTitle, setCurriculumTitle] = useState< string | undefined>(undefined) const [curriculumTitle, setCurriculumTitle] = useState<string | undefined>(undefined)
const handleAlertClose = () => { const handleAlertClose = () => {
setOpenAlert(!openAlert); setOpenAlert(!openAlert);
...@@ -309,7 +309,7 @@ const List = () => { ...@@ -309,7 +309,7 @@ const List = () => {
/** /**
* API Config * API Config
* Tutorial API * Curriculum API
*/ */
useEffect(() => { useEffect(() => {
dispatch(fetchCurriculums()); dispatch(fetchCurriculums());
......
...@@ -296,12 +296,12 @@ const AddEditTutorial = ({ tutorial, onCancel }: Props) => { ...@@ -296,12 +296,12 @@ const AddEditTutorial = ({ tutorial, onCancel }: Props) => {
placeholder="Enter Task Title" placeholder="Enter Task Title"
{...getFieldProps(`taskItems.${index}.title`)} {...getFieldProps(`taskItems.${index}.title`)}
error={Boolean( error={Boolean(
touched.taskItems && touched.taskItems[index].title && touched.taskItems && touched.taskItems[index] &&
//@ts-ignore //@ts-ignore
errors.taskItems && errors.taskItems[index] && errors.taskItems[index].title errors.taskItems && errors.taskItems[index] && errors.taskItems[index].title
)} )}
helperText={ helperText={
touched.taskItems && touched.taskItems[index].title && touched.taskItems && touched.taskItems[index] &&
//@ts-ignore //@ts-ignore
errors.taskItems && errors.taskItems[index] && errors.taskItems[index].title errors.taskItems && errors.taskItems[index] && errors.taskItems[index].title
} }
...@@ -317,12 +317,12 @@ const AddEditTutorial = ({ tutorial, onCancel }: Props) => { ...@@ -317,12 +317,12 @@ const AddEditTutorial = ({ tutorial, onCancel }: Props) => {
placeholder="Enter Task Mark" placeholder="Enter Task Mark"
{...getFieldProps(`taskItems.${index}.taskItemMark`)} {...getFieldProps(`taskItems.${index}.taskItemMark`)}
error={Boolean( error={Boolean(
touched.taskItems && touched.taskItems[index].taskItemMark && touched.taskItems && touched.taskItems[index] &&
//@ts-ignore //@ts-ignore
errors.taskItems && errors.taskItems[index] && errors.taskItems[index].taskItemMark errors.taskItems && errors.taskItems[index] && errors.taskItems[index].taskItemMark
)} )}
helperText={ helperText={
touched.taskItems && touched.taskItems[index].taskItemMark && touched.taskItems && touched.taskItems[index] &&
//@ts-ignore //@ts-ignore
errors.taskItems && errors.taskItems[index] && errors.taskItems[index].taskItemMark errors.taskItems && errors.taskItems[index] && errors.taskItems[index].taskItemMark
} }
...@@ -338,12 +338,12 @@ const AddEditTutorial = ({ tutorial, onCancel }: Props) => { ...@@ -338,12 +338,12 @@ const AddEditTutorial = ({ tutorial, onCancel }: Props) => {
placeholder="Enter Task Reference Image" placeholder="Enter Task Reference Image"
{...getFieldProps(`taskItems.${index}.referenceImage`)} {...getFieldProps(`taskItems.${index}.referenceImage`)}
error={Boolean( error={Boolean(
touched.taskItems && touched.taskItems[index].referenceImage && touched.taskItems && touched.taskItems[index] &&
//@ts-ignore //@ts-ignore
errors.taskItems && errors.taskItems[index] && errors.taskItems[index].referenceImage errors.taskItems && errors.taskItems[index] && errors.taskItems[index].referenceImage
)} )}
helperText={ helperText={
touched.taskItems && touched.taskItems[index].referenceImage && touched.taskItems && touched.taskItems[index] &&
//@ts-ignore //@ts-ignore
errors.taskItems && errors.taskItems[index] && errors.taskItems[index].referenceImage errors.taskItems && errors.taskItems[index] && errors.taskItems[index].referenceImage
} }
...@@ -359,12 +359,12 @@ const AddEditTutorial = ({ tutorial, onCancel }: Props) => { ...@@ -359,12 +359,12 @@ const AddEditTutorial = ({ tutorial, onCancel }: Props) => {
placeholder="Enter Task Reference Video" placeholder="Enter Task Reference Video"
{...getFieldProps(`taskItems.${index}.referenceVideo`)} {...getFieldProps(`taskItems.${index}.referenceVideo`)}
error={Boolean( error={Boolean(
touched.taskItems && touched.taskItems[index].referenceVideo && touched.taskItems && touched.taskItems[index] &&
//@ts-ignore //@ts-ignore
errors.taskItems && errors.taskItems[index] && errors.taskItems[index].referenceVideo errors.taskItems && errors.taskItems[index] && errors.taskItems[index].referenceVideo
)} )}
helperText={ helperText={
touched.taskItems && touched.taskItems[index].referenceVideo && touched.taskItems && touched.taskItems[index] &&
//@ts-ignore //@ts-ignore
errors.taskItems && errors.taskItems[index] && errors.taskItems[index].referenceVideo errors.taskItems && errors.taskItems[index] && errors.taskItems[index].referenceVideo
} }
...@@ -380,12 +380,12 @@ const AddEditTutorial = ({ tutorial, onCancel }: Props) => { ...@@ -380,12 +380,12 @@ const AddEditTutorial = ({ tutorial, onCancel }: Props) => {
placeholder="Enter Task Description" placeholder="Enter Task Description"
{...getFieldProps(`taskItems.${index}.description`)} {...getFieldProps(`taskItems.${index}.description`)}
error={Boolean( error={Boolean(
touched.taskItems && touched.taskItems[index].description && touched.taskItems && touched.taskItems[index] &&
//@ts-ignore //@ts-ignore
errors.taskItems && errors.taskItems[index] && errors.taskItems[index].description errors.taskItems && errors.taskItems[index] && errors.taskItems[index].description
)} )}
helperText={ helperText={
touched.taskItems && touched.taskItems[index].description && touched.taskItems && touched.taskItems[index] &&
//@ts-ignore //@ts-ignore
errors.taskItems && errors.taskItems[index] && errors.taskItems[index].description errors.taskItems && errors.taskItems[index] && errors.taskItems[index].description
} }
...@@ -401,12 +401,12 @@ const AddEditTutorial = ({ tutorial, onCancel }: Props) => { ...@@ -401,12 +401,12 @@ const AddEditTutorial = ({ tutorial, onCancel }: Props) => {
placeholder="Enter Task How To Do" placeholder="Enter Task How To Do"
{...getFieldProps(`taskItems.${index}.howToDo`)} {...getFieldProps(`taskItems.${index}.howToDo`)}
error={Boolean( error={Boolean(
touched.taskItems && touched.taskItems[index].howToDo && touched.taskItems && touched.taskItems[index] &&
//@ts-ignore //@ts-ignore
errors.taskItems && errors.taskItems[index] && errors.taskItems[index].howToDo errors.taskItems && errors.taskItems[index] && errors.taskItems[index].howToDo
)} )}
helperText={ helperText={
touched.taskItems && touched.taskItems[index].howToDo && touched.taskItems && touched.taskItems[index] &&
//@ts-ignore //@ts-ignore
errors.taskItems && errors.taskItems[index] && errors.taskItems[index].howToDo errors.taskItems && errors.taskItems[index] && errors.taskItems[index].howToDo
} }
......
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