Commit 8ee0496c authored by janithgamage1.ed's avatar janithgamage1.ed

fix: update

Desc : update project
parent 2d1af9bb
...@@ -157,7 +157,7 @@ const application: NavItemType = { ...@@ -157,7 +157,7 @@ const application: NavItemType = {
id: 'learning-curriculums-subscribed-tutorial', id: 'learning-curriculums-subscribed-tutorial',
title: <FormattedMessage id="learning-curriculums-subscribed-tutorial" />, title: <FormattedMessage id="learning-curriculums-subscribed-tutorial" />,
type: 'item', type: 'item',
url: '/learning-management/curriculums-subscribed-tutorial', url: '/learning-management/curriculums-subscribed-tutorial/0/0',
}, },
{ {
id: 'learning-lead-board', id: 'learning-lead-board',
......
...@@ -261,7 +261,7 @@ const List = () => { ...@@ -261,7 +261,7 @@ const List = () => {
</Stack> </Stack>
</AccordionSummary> </AccordionSummary>
<AccordionDetails> <AccordionDetails>
<CurriculumSection curriculum={curriculum} /> <CurriculumSection curriculum={curriculum} curriculumIndex={index} />
</AccordionDetails> </AccordionDetails>
</Accordion> </Accordion>
</Box> </Box>
......
...@@ -19,6 +19,7 @@ import ReportCard from "components/cards/statistics/ReportCard"; ...@@ -19,6 +19,7 @@ import ReportCard from "components/cards/statistics/ReportCard";
import { itemResultProps, selectedCommonDataProps, selectedItemContentProps } from "./types/types"; import { itemResultProps, selectedCommonDataProps, selectedItemContentProps } from "./types/types";
import CircularWithPath from "components/@extended/progress/CircularWithPath"; import CircularWithPath from "components/@extended/progress/CircularWithPath";
import { useParams } from "react-router";
import Webcam from 'react-webcam'; import Webcam from 'react-webcam';
import { useDispatch, useSelector } from "store"; import { useDispatch, useSelector } from "store";
import { CalculateMarks, toInitialState } from "store/reducers/marksCalculator"; import { CalculateMarks, toInitialState } from "store/reducers/marksCalculator";
...@@ -49,6 +50,7 @@ const Tutorial = () => { ...@@ -49,6 +50,7 @@ const Tutorial = () => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const { marksCalculator, error, success, isLoading } = useSelector(state => state.marksCalculator); const { marksCalculator, error, success, isLoading } = useSelector(state => state.marksCalculator);
const { userProgress } = useSelector(state => state.userProgress); const { userProgress } = useSelector(state => state.userProgress);
const { curriculumIndex, tutorialIndex } = useParams();
const [data, setData] = useState<tutorialTypeUserProgress>() const [data, setData] = useState<tutorialTypeUserProgress>()
const [selectedItem, setSelectedItem] = useState<{ selectedCommonData: selectedCommonDataProps | null, backgroundColor: any | null }>({ const [selectedItem, setSelectedItem] = useState<{ selectedCommonData: selectedCommonDataProps | null, backgroundColor: any | null }>({
...@@ -70,10 +72,11 @@ const Tutorial = () => { ...@@ -70,10 +72,11 @@ const Tutorial = () => {
}) })
useEffect(() => { useEffect(() => {
if (!curriculumIndex || !tutorialIndex) return
if (userProgress) { if (userProgress) {
const firstTutorial = userProgress?.curriculums?.[0]?.tutorials?.[0]; const selectedTutorial = userProgress?.curriculums?.[parseInt(curriculumIndex)]?.tutorials?.[parseInt(tutorialIndex)];
if (firstTutorial) { if (selectedTutorial) {
setData(firstTutorial); setData(selectedTutorial);
} }
} }
}, [userProgress]); }, [userProgress]);
......
...@@ -148,7 +148,17 @@ const MainRoutes = { ...@@ -148,7 +148,17 @@ const MainRoutes = {
}, },
{ {
path: 'curriculums-subscribed-tutorial', path: 'curriculums-subscribed-tutorial',
children: [
{
path: ':curriculumIndex', // Parameter for curriculum index
children: [
{
path: ':tutorialIndex', // Parameter for tutorial index
element: <LearningCurriculumsSubscribedTutorial /> element: <LearningCurriculumsSubscribedTutorial />
}
]
}
]
}, },
{ {
path: 'lead-board', path: 'lead-board',
......
...@@ -25,7 +25,7 @@ import ReportCard from 'components/cards/statistics/ReportCard'; ...@@ -25,7 +25,7 @@ import ReportCard from 'components/cards/statistics/ReportCard';
// ==============================|| Curriculum - Section ||============================== // // ==============================|| Curriculum - Section ||============================== //
const CurriculumSection = ({ curriculum }: { curriculum: curriculumTypeUserProgress }) => { const CurriculumSection = ({ curriculum, curriculumIndex }: { curriculum: curriculumTypeUserProgress, curriculumIndex: number }) => {
const theme = useTheme(); const theme = useTheme();
return ( return (
...@@ -85,7 +85,7 @@ const CurriculumSection = ({ curriculum }: { curriculum: curriculumTypeUserProgr ...@@ -85,7 +85,7 @@ const CurriculumSection = ({ curriculum }: { curriculum: curriculumTypeUserProgr
<MainCard title="Tutorials"> <MainCard title="Tutorials">
<Grid container spacing={2}> <Grid container spacing={2}>
{curriculum.tutorials && curriculum.tutorials?.map((tutorial, index) => { {curriculum.tutorials && curriculum.tutorials?.map((tutorial, index) => {
return (<TutorialSection tutorial={tutorial!} />) return (<TutorialSection tutorial={tutorial!} curriculumIndex={curriculumIndex} tutorialIndex={index} />)
})} })}
</Grid> </Grid>
</MainCard> </MainCard>
......
...@@ -25,7 +25,7 @@ import MainCard from 'components/MainCard'; ...@@ -25,7 +25,7 @@ import MainCard from 'components/MainCard';
// ==============================|| Tutorial - Section ||============================== // // ==============================|| Tutorial - Section ||============================== //
const TutorialSection = ({ tutorial }: { tutorial: tutorialTypeUserProgress }) => { const TutorialSection = ({ tutorial, tutorialIndex, curriculumIndex }: { tutorial: tutorialTypeUserProgress, curriculumIndex: number, tutorialIndex: number }) => {
let navigation = useNavigate() let navigation = useNavigate()
const [desc, setDesc] = useState(tutorial.tutorialDescription?.slice(0, 100)) const [desc, setDesc] = useState(tutorial.tutorialDescription?.slice(0, 100))
...@@ -70,7 +70,7 @@ const TutorialSection = ({ tutorial }: { tutorial: tutorialTypeUserProgress }) = ...@@ -70,7 +70,7 @@ const TutorialSection = ({ tutorial }: { tutorial: tutorialTypeUserProgress }) =
variant="outlined" variant="outlined"
endIcon={<PlaySquareOutlined />} endIcon={<PlaySquareOutlined />}
sx={{ my: 2 }} sx={{ my: 2 }}
onClick={() => { navigation(`/learning-management/curriculums-subscribed-tutorial`) }} onClick={() => { navigation(`/learning-management/curriculums-subscribed-tutorial/${curriculumIndex}/${tutorialIndex}`) }}
> >
Start Tutorial Start Tutorial
</Button> </Button>
......
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