@@ -14,16 +14,21 @@ import "./subtopics_card.scss"
14
14
import ExpandLessIcon from '@mui/icons-material/ExpandLess' ;
15
15
import ArrowForwardIosIcon from "@mui/icons-material/ArrowForwardIos" ;
16
16
import QuestionMarkIcon from '@mui/icons-material/QuestionMark' ;
17
- import { useNavigate , useParams } from "react-router-dom" ;
18
17
import CheckIcon from '@mui/icons-material/Check' ;
19
18
import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank' ;
20
19
import { ISubtopicCardProps } from "../../../../types/types" ;
21
20
import { contentRenderFunction } from "../../../../utils/utils" ;
22
- import { styled } from "@mui/material/styles" ;
23
21
import CloseIcon from '@mui/icons-material/Close' ;
24
22
25
23
26
- const SubtopicCard = ( { content, title, subArticleIndex, done} : ISubtopicCardProps ) => {
24
+ const SubtopicCard = ( {
25
+ content,
26
+ title,
27
+ subArticleIndex,
28
+ done,
29
+ handleGoToSubTestNow,
30
+ selectedArticleNumber
31
+ } : ISubtopicCardProps ) => {
27
32
28
33
const [ expanded , setExpanded ] = React . useState ( false ) ;
29
34
const [ openModalAdditional , setOpenModalAdditional ] = React . useState ( false ) ;
@@ -32,20 +37,7 @@ const SubtopicCard = ({content, title, subArticleIndex, done}: ISubtopicCardProp
32
37
setOpenModalAdditional ( false ) ;
33
38
} ;
34
39
35
- const handleExpandClick = ( ) => {
36
- setExpanded ( ! expanded ) ;
37
- } ;
38
-
39
- const { selectedArticle} = useParams ( ) ;
40
- const navigate = useNavigate ( ) ;
41
-
42
- // Your logic to extract subtopics from historyList based on selectedArticle
43
40
44
- const handleGoToTest = ( ) => {
45
- // Navigate to the test page with the selectedArticle parameter
46
-
47
- navigate ( `/test/${ selectedArticle } /${ subArticleIndex } ` ) ;
48
- } ;
49
41
return (
50
42
< React . Fragment >
51
43
< Card elevation = { done ? 6 : 0 } className = { "subtopics_card" } >
@@ -77,7 +69,9 @@ const SubtopicCard = ({content, title, subArticleIndex, done}: ISubtopicCardProp
77
69
</ CardActions > }
78
70
79
71
{ ! done ? < CardActions disableSpacing >
80
- < Button onClick = { handleGoToTest } endIcon = { < ArrowForwardIosIcon /> } color = { "secondary" }
72
+ < Button
73
+ onClick = { ( ) => handleGoToSubTestNow ( selectedArticleNumber , subArticleIndex ) }
74
+ endIcon = { < ArrowForwardIosIcon /> } color = { "secondary" }
81
75
size = { "small" }
82
76
fullWidth
83
77
variant = { "outlined" }
@@ -100,7 +94,7 @@ const SubtopicCard = ({content, title, subArticleIndex, done}: ISubtopicCardProp
100
94
101
95
{ expanded && < CardActions disableSpacing >
102
96
103
- < Button onClick = { ( ) => setOpenModalAdditional ( true ) }
97
+ < Button onClick = { ( ) => setOpenModalAdditional ( true ) }
104
98
endIcon = { < ExpandLessIcon /> }
105
99
color = { "secondary" }
106
100
aria-expanded = { expanded } size = { "small" } fullWidth variant = { "contained" }
@@ -132,7 +126,7 @@ const SubtopicCard = ({content, title, subArticleIndex, done}: ISubtopicCardProp
132
126
< DialogActions >
133
127
< Grid container spacing = { 2 } justifyContent = { "end" } >
134
128
< Grid item xs = { "auto" } >
135
- < Button onClick = { handleGoToTest } endIcon = { < ArrowForwardIosIcon /> } color = { "primary" }
129
+ < Button onClick = { ( ) => handleGoToSubTestNow ( selectedArticleNumber , subArticleIndex ) } endIcon = { < ArrowForwardIosIcon /> } color = { "primary" }
136
130
size = { "medium" }
137
131
138
132
variant = { "contained" }
0 commit comments