diff --git a/backend/question-service/controllers/historyController.ts b/backend/question-service/controllers/historyController.ts index adc529af47..948f030158 100644 --- a/backend/question-service/controllers/historyController.ts +++ b/backend/question-service/controllers/historyController.ts @@ -27,6 +27,7 @@ export const getUserHistoryEntries = async (req: any, res: Response) => { title: entry.question.title, difficulty: entry.question.difficulty, topics: entry.question.categories.map((cat: any) => cat.name), + description: entry.question.description, attemptCodes: entry.attemptCodes.filter((attemptCode) => attemptCode && attemptCode !== ""), }; }); diff --git a/frontend/src/domain/entities/HistoryEntry.ts b/frontend/src/domain/entities/HistoryEntry.ts index 83320b2a41..c103498618 100644 --- a/frontend/src/domain/entities/HistoryEntry.ts +++ b/frontend/src/domain/entities/HistoryEntry.ts @@ -7,5 +7,6 @@ export interface HistoryEntry { title: string; difficulty: 'Easy' | 'Medium' | 'Hard'; topics: string[]; + description: string; attemptCodes: string[]; } \ No newline at end of file diff --git a/frontend/src/presentation/components/RecentAttemptsTable.tsx b/frontend/src/presentation/components/RecentAttemptsTable.tsx index 07ea1252da..e6900bae18 100644 --- a/frontend/src/presentation/components/RecentAttemptsTable.tsx +++ b/frontend/src/presentation/components/RecentAttemptsTable.tsx @@ -8,7 +8,7 @@ import { historyUseCases } from "domain/usecases/HistoryUseCases"; import { ReactMarkdown } from "./common/ReactMarkdown"; import TabPane from "antd/es/tabs/TabPane"; import { useNavigate } from "react-router-dom"; -import { EyeOutlined, TeamOutlined } from "@ant-design/icons"; // Importing additional icons +import { EyeOutlined, TeamOutlined } from "@ant-design/icons"; const formatDate = (dateString: string): string => { const options: Intl.DateTimeFormatOptions = { @@ -42,7 +42,7 @@ const calculateDuration = (start: string, end: string): string => { }; export const RecentAttemptsTable: React.FC = () => { - const navigate = useNavigate(); // Initialized navigate + const navigate = useNavigate(); // State Definitions const [recentAttemptsData, setRecentAttemptsData] = useState([]); @@ -53,6 +53,10 @@ export const RecentAttemptsTable: React.FC = () => { const [isModalVisible, setIsModalVisible] = useState(false); const [currentCodes, setCurrentCodes] = useState([]); + // Modal State for Viewing Description + const [isDescriptionModalVisible, setIsDescriptionModalVisible] = useState(false); + const [currentDescription, setCurrentDescription] = useState(''); + // Fetch Recent Attempts on Component Mount useEffect(() => { fetchRecentAttempts(); @@ -130,6 +134,18 @@ export const RecentAttemptsTable: React.FC = () => { setCurrentCodes([]); }; + // Function to Show Description Modal + const showDescriptionModal = (description: string) => { + setCurrentDescription(description); + setIsDescriptionModalVisible(true); + }; + + // Function to Close Description Modal + const handleDescriptionModalClose = () => { + setIsDescriptionModalVisible(false); + setCurrentDescription(''); + }; + // Define Columns for the Table const columns: ColumnsType = [ { @@ -169,7 +185,11 @@ export const RecentAttemptsTable: React.FC = () => { title: 'Title', dataIndex: 'title', key: 'title', - render: (text: string) => {text}, + render: (text: string, record: HistoryEntry) => ( + showDescriptionModal(record.description)}> + {text} + + ), }, { title: 'Difficulty', @@ -306,6 +326,18 @@ export const RecentAttemptsTable: React.FC = () => { )} + + +
+ +
+
); };