@@ -8,7 +8,7 @@ import { historyUseCases } from "domain/usecases/HistoryUseCases";
8
8
import { ReactMarkdown } from "./common/ReactMarkdown" ;
9
9
import TabPane from "antd/es/tabs/TabPane" ;
10
10
import { useNavigate } from "react-router-dom" ;
11
- import { EyeOutlined , TeamOutlined } from "@ant-design/icons" ; // Importing additional icons
11
+ import { EyeOutlined , TeamOutlined } from "@ant-design/icons" ;
12
12
13
13
const formatDate = ( dateString : string ) : string => {
14
14
const options : Intl . DateTimeFormatOptions = {
@@ -42,7 +42,7 @@ const calculateDuration = (start: string, end: string): string => {
42
42
} ;
43
43
44
44
export const RecentAttemptsTable : React . FC = ( ) => {
45
- const navigate = useNavigate ( ) ; // Initialized navigate
45
+ const navigate = useNavigate ( ) ;
46
46
47
47
// State Definitions
48
48
const [ recentAttemptsData , setRecentAttemptsData ] = useState < HistoryEntry [ ] > ( [ ] ) ;
@@ -53,6 +53,10 @@ export const RecentAttemptsTable: React.FC = () => {
53
53
const [ isModalVisible , setIsModalVisible ] = useState < boolean > ( false ) ;
54
54
const [ currentCodes , setCurrentCodes ] = useState < string [ ] > ( [ ] ) ;
55
55
56
+ // Modal State for Viewing Description
57
+ const [ isDescriptionModalVisible , setIsDescriptionModalVisible ] = useState < boolean > ( false ) ;
58
+ const [ currentDescription , setCurrentDescription ] = useState < string > ( '' ) ;
59
+
56
60
// Fetch Recent Attempts on Component Mount
57
61
useEffect ( ( ) => {
58
62
fetchRecentAttempts ( ) ;
@@ -130,6 +134,18 @@ export const RecentAttemptsTable: React.FC = () => {
130
134
setCurrentCodes ( [ ] ) ;
131
135
} ;
132
136
137
+ // Function to Show Description Modal
138
+ const showDescriptionModal = ( description : string ) => {
139
+ setCurrentDescription ( description ) ;
140
+ setIsDescriptionModalVisible ( true ) ;
141
+ } ;
142
+
143
+ // Function to Close Description Modal
144
+ const handleDescriptionModalClose = ( ) => {
145
+ setIsDescriptionModalVisible ( false ) ;
146
+ setCurrentDescription ( '' ) ;
147
+ } ;
148
+
133
149
// Define Columns for the Table
134
150
const columns : ColumnsType < HistoryEntry > = [
135
151
{
@@ -169,7 +185,11 @@ export const RecentAttemptsTable: React.FC = () => {
169
185
title : 'Title' ,
170
186
dataIndex : 'title' ,
171
187
key : 'title' ,
172
- render : ( text : string ) => < Typography . Text > { text } </ Typography . Text > ,
188
+ render : ( text : string , record : HistoryEntry ) => (
189
+ < Typography . Link onClick = { ( ) => showDescriptionModal ( record . description ) } >
190
+ { text }
191
+ </ Typography . Link >
192
+ ) ,
173
193
} ,
174
194
{
175
195
title : 'Difficulty' ,
@@ -306,6 +326,18 @@ export const RecentAttemptsTable: React.FC = () => {
306
326
< Empty description = "No code available" />
307
327
) }
308
328
</ Modal >
329
+
330
+ < Modal
331
+ title = "Question Description"
332
+ open = { isDescriptionModalVisible }
333
+ onCancel = { handleDescriptionModalClose }
334
+ footer = { null }
335
+ width = { 800 }
336
+ >
337
+ < div style = { { height : '100%' , overflow : 'auto' , padding : '16px' } } >
338
+ < ReactMarkdown isReadOnly value = { currentDescription } />
339
+ </ div >
340
+ </ Modal >
309
341
</ div >
310
342
) ;
311
343
} ;
0 commit comments