Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Recent Questions Title, Add Action Column #80

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions frontend/components/QuestionHistoryCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ import {
Th,
Td,
TableContainer,
Flex,
Tooltip,
Icon,
Text,
} from "@chakra-ui/react";
import useAuth from "@/hooks/useAuth";
import { getQuestionHistory } from "@/services/historyService";
import { QuestionHistory } from "@/types/History";
import { QuestionComplexity } from "@/types/Question";
import { difficultyText } from "@/app/utils";
import { useRouter } from "next/navigation";
import { RxOpenInNewWindow } from "react-icons/rx";

export const QuestionHistoryCard = () => {
const [history, setHistory] = useState<QuestionHistory[]>([]);
Expand All @@ -31,14 +36,17 @@ export const QuestionHistoryCard = () => {
});
}, [userId]);

const headers = ["Question", "Difficulty", "Collaborator", "Date"];
const headers = ["Question", "Difficulty", "Collaborator", "Date", "Action"];

const handleClick = (item: QuestionHistory) => {
router.push(`/attempts/${item.roomId}`);
};

return (
<Card backgroundColor={"#FFFFFF"}>
<Flex justifyContent="center" padding="4">
<Text fontWeight="bold">Recent Sessions</Text>
</Flex>
<TableContainer>
<Table variant="simple">
<Thead>
Expand All @@ -50,7 +58,7 @@ export const QuestionHistoryCard = () => {
</Thead>
<Tbody>
{history.map((item, index) => (
<Tr key={index} onClick={() => handleClick(item)}>
<Tr key={index}>
<Td>{item.questionTitle}</Td>
<Td>
{difficultyText(
Expand All @@ -59,6 +67,20 @@ export const QuestionHistoryCard = () => {
</Td>
<Td>{item.collaboratorId}</Td>
<Td>{item.timeAttempted.toLocaleDateString()}</Td>
<Td>
<Flex className="justify-center">
<Tooltip content="See Details" aria-label="See Details">
<Icon
onClick={() => handleClick(item)}
fontSize="20px"
color="gray"
cursor="pointer"
>
<RxOpenInNewWindow />
</Icon>
</Tooltip>
</Flex>
</Td>
</Tr>
))}
</Tbody>
Expand Down