Skip to content

Commit e708b89

Browse files
committed
Change reference to question id
Change reference from question title to question id
1 parent bbd9022 commit e708b89

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

frontend/src/components/Questions/EditQuestionsTab.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const EditQuestionsTab: React.FC = () => {
2323

2424
try {
2525
await updateQuestion(editedQuestion.id, editedQuestion);
26-
console.log(`Question updated: ${editedQuestion.id}: ${editedQuestion.title}`);
26+
console.log(`Question ${editedQuestion.id} updated: ${editedQuestion.title}`);
2727
setEditQuestions(false);
2828
} catch (e) {
2929
if (e instanceof AxiosError && e.response) {
@@ -38,8 +38,8 @@ const EditQuestionsTab: React.FC = () => {
3838
console.log("Question to Delete: ", questionToDelete);
3939

4040
try {
41-
await deleteQuestion(questionToDelete.title);
42-
console.log("Question deleted: ",questionToDelete.title);
41+
await deleteQuestion(questionToDelete.id);
42+
console.log(`Question ${questionToDelete.id} deleted: ${questionToDelete.title}`);
4343
setEditQuestions(false);
4444
} catch (e) {
4545
if (e instanceof AxiosError && e.response) {

frontend/src/components/Questions/EditQuestionsTable.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ const EditQuestionsTable: React.FC<EditQuestionsTableProps> = ({onEdit, onDelete
5757
setCurrentPage(1);
5858
};
5959

60-
const handleExpandClick = (title: string) => {
61-
expandedQuestion === title ? setExpandedQuestion(false) : setExpandedQuestion(title);
60+
const handleExpandClick = (id: string) => {
61+
expandedQuestion === id ? setExpandedQuestion(false) : setExpandedQuestion(id);
6262
}
6363

6464
const indexOfLastQuestion = currentPage * itemsPerPage;
@@ -79,30 +79,30 @@ const EditQuestionsTable: React.FC<EditQuestionsTableProps> = ({onEdit, onDelete
7979
</TableHead>
8080
<TableBody>
8181
{currentQuestions.map((question:Question) => (
82-
<React.Fragment key={question.title}>
82+
<React.Fragment key={question.id}>
8383
<TableRow
8484
sx={{ '& > *': { borderBottom: 'unset' }}}
8585
hover
86-
onClick={() => handleExpandClick(question.title)}
87-
selected={expandedQuestion === question.title}
86+
onClick={() => handleExpandClick(question.id)}
87+
selected={expandedQuestion === question.id}
8888
>
8989
<TableCell>
9090
<IconButton
9191
aria-label="expand row"
9292
size="small"
93-
onClick={() => handleExpandClick(question.title)}
93+
onClick={() => handleExpandClick(question.id)}
9494
>
95-
{expandedQuestion === question.title ?
95+
{expandedQuestion === question.id ?
9696
<Typography></Typography> : <Typography></Typography>}
9797
</IconButton>
9898
</TableCell>
9999
<TableCell component="th">{question.title}</TableCell>
100100
<TableCell>{question.categories.join(', ')}</TableCell>
101101
<TableCell>{question.difficulty}</TableCell>
102102
</TableRow>
103-
<TableRow key={question.title + "_details"}>
103+
<TableRow key={question.id + "_details"}>
104104
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={4}>
105-
<Collapse in={question.title === expandedQuestion} timeout="auto" unmountOnExit>
105+
<Collapse in={question.id === expandedQuestion} timeout="auto" unmountOnExit>
106106
<EditQuestionTab question={question} onEdit={onEdit} onDelete={onDelete} />
107107
</Collapse>
108108
</TableCell>

0 commit comments

Comments
 (0)