1
1
"use client" ;
2
2
import React from "react" ;
3
- import { Question , Difficulty } from "@/api/structs" ;
3
+ import { Difficulty , Question } from "@/api/structs" ;
4
4
import Chip from "@/components/shared/Chip" ;
5
5
import PeerprepButton from "@/components/shared/PeerprepButton" ;
6
6
import styles from "@/style/question.module.css" ;
7
7
import { useRouter } from "next/navigation" ;
8
8
import { deleteQuestion } from "@/app/api/internal/questions/helper" ;
9
9
import CollabEditor from "@/components/questionpage/CollabEditor" ;
10
- import DOMPurify from 'dompurify' ;
11
-
10
+ import DOMPurify from "dompurify" ;
12
11
13
12
interface Props {
14
13
question : Question ;
@@ -31,18 +30,16 @@ function DifficultyChip({ diff }: DifficultyChipProps) {
31
30
function QuestionBlock ( { question } : Props ) {
32
31
const router = useRouter ( ) ;
33
32
34
-
35
-
36
33
const handleDelete = async ( ) => {
37
34
if (
38
35
confirm (
39
- `Are you sure you want to delete ${ question . title } ? (ID: ${ question . id } ) `
36
+ `Are you sure you want to delete ${ question . title } ? (ID: ${ question . id } ) ` ,
40
37
)
41
38
) {
42
39
const status = await deleteQuestion ( question . id ) ;
43
40
if ( status . error ) {
44
41
alert (
45
- `Failed to delete question. Code ${ status . status } : ${ status . error } `
42
+ `Failed to delete question. Code ${ status . status } : ${ status . error } ` ,
46
43
) ;
47
44
return ;
48
45
}
@@ -75,16 +72,25 @@ function QuestionBlock({ question }: Props) {
75
72
{ question . topicTags . length == 0 ? (
76
73
< p > No topics listed.</ p >
77
74
) : (
78
- question . topicTags . map ( ( elem , idx ) => < p key = { idx } > { elem } </ p > )
75
+ question . topicTags . map ( ( elem , idx ) => (
76
+ < p key = { idx } className = { styles . label_shadow } >
77
+ { elem }
78
+ </ p >
79
+ ) )
79
80
) }
80
81
</ div >
81
- { < div dangerouslySetInnerHTML = { { __html : DOMPurify . sanitize ( question . content ) } } /> }
82
+ {
83
+ < div
84
+ className = { styles . editorHTML }
85
+ dangerouslySetInnerHTML = { {
86
+ __html : DOMPurify . sanitize ( question . content ) ,
87
+ } }
88
+ />
89
+ }
82
90
< br />
83
91
</ div >
84
92
< div className = { styles . editor_container } >
85
- < CollabEditor
86
- question = { question }
87
- />
93
+ < CollabEditor question = { question } />
88
94
</ div >
89
95
</ >
90
96
) ;
0 commit comments