1
1
import { QueryClient , queryOptions , useSuspenseQuery } from '@tanstack/react-query' ;
2
2
import { useMemo } from 'react' ;
3
- import Markdown from 'react-markdown' ;
4
3
import { LoaderFunctionArgs , useLoaderData } from 'react-router-dom' ;
5
- import rehypeKatex from 'rehype-katex' ;
6
- import remarkGfm from 'remark-gfm' ;
7
- import remarkMath from 'remark-math' ;
8
4
9
5
import { WithNavBanner } from '@/components/blocks/authed/with-nav-banner' ;
10
- import { Badge } from '@/components/ui/badge' ;
11
- import { Card , CardContent , CardHeader , CardTitle } from '@/components/ui/card' ;
12
- import { ScrollArea } from '@/components/ui/scroll-area' ;
13
- import { Separator } from '@/components/ui/separator' ;
6
+ import { Card } from '@/components/ui/card' ;
14
7
15
8
import { useCrumbs } from '@/lib/hooks/use-crumbs' ;
16
9
import { usePageTitle } from '@/lib/hooks/use-page-title' ;
17
10
import { getQuestionDetails } from '@/services/question-service' ;
11
+ import { QuestionDetails } from '@/components/blocks/questions/details' ;
18
12
19
13
const questionDetailsQuery = ( id : number ) =>
20
14
queryOptions ( {
@@ -30,7 +24,7 @@ export const loader =
30
24
return { questionId } ;
31
25
} ;
32
26
33
- export const QuestionDetails = ( ) => {
27
+ export const QuestionDetailsPage = ( ) => {
34
28
const { questionId } = useLoaderData ( ) as Awaited < ReturnType < ReturnType < typeof loader > > > ;
35
29
const { data : details } = useSuspenseQuery ( questionDetailsQuery ( questionId ) ) ;
36
30
const questionDetails = useMemo ( ( ) => {
@@ -46,59 +40,7 @@ export const QuestionDetails = () => {
46
40
< WithNavBanner crumbs = { [ ...crumbs ] } >
47
41
< div className = 'flex flex-1 overflow-hidden' >
48
42
< Card className = 'border-border m-4 w-1/3 max-w-[500px] overflow-hidden p-4 md:w-2/5' >
49
- < ScrollArea className = 'h-full' >
50
- < CardHeader >
51
- < div className = 'flex flex-col gap-4' >
52
- < div className = 'flex w-full items-center gap-4' >
53
- < CardTitle className = 'text-2xl' >
54
- { questionDetails . id } . { questionDetails . title }
55
- </ CardTitle >
56
- </ div >
57
- < div className = 'flex flex-wrap items-center gap-1' >
58
- < Badge
59
- variant = { questionDetails . difficulty . toLowerCase ( ) as 'easy' | 'medium' | 'hard' }
60
- className = 'flex w-min grow-0'
61
- >
62
- { questionDetails . difficulty }
63
- </ Badge >
64
- < Separator orientation = 'vertical' className = 'mx-2 h-4' />
65
- < span className = 'text-sm font-medium' > Topics:</ span >
66
- { questionDetails . topic . map ( ( v , i ) => (
67
- < Badge
68
- variant = 'secondary'
69
- className = 'flex w-min grow-0 whitespace-nowrap'
70
- key = { i }
71
- >
72
- { v }
73
- </ Badge >
74
- ) ) }
75
- </ div >
76
- </ div >
77
- </ CardHeader >
78
- < CardContent >
79
- < Markdown
80
- rehypePlugins = { [ rehypeKatex ] }
81
- remarkPlugins = { [ remarkMath , remarkGfm ] }
82
- className = 'prose prose-neutral text-card-foreground prose-strong:text-card-foreground leading-normal'
83
- components = { {
84
- code : ( { children, className, ...rest } ) => {
85
- // const isCodeBlock = /language-(\w+)/.exec(className || '');
86
-
87
- return (
88
- < code
89
- { ...rest }
90
- className = 'bg-secondary text-secondary-foreground rounded px-1.5 py-1 font-mono'
91
- >
92
- { children }
93
- </ code >
94
- ) ;
95
- } ,
96
- } }
97
- >
98
- { questionDetails . description }
99
- </ Markdown >
100
- </ CardContent >
101
- </ ScrollArea >
43
+ < QuestionDetails questionDetails = { questionDetails } />
102
44
</ Card >
103
45
< div className = 'flex flex-1 flex-col' />
104
46
</ div >
0 commit comments