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

fix: update

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