@@ -12,30 +12,26 @@ import { Input } from "@/components/ui/input";
1212import { Label } from "@/components/ui/label" ;
1313import { Textarea } from "@/components/ui/textarea" ;
1414import { useMutation , useQueryClient } from "@tanstack/react-query" ;
15- import dynamic from "next/dynamic" ;
1615
1716import { type ApiError } from "next/dist/server/api-utils" ;
1817import { useForm } from "react-hook-form" ;
1918import toast from "react-hot-toast" ;
2019
21- const Editor = dynamic ( ( ) => import ( "../editor" ) , { ssr : false } ) ;
2220import { useRouter } from "next/navigation" ;
2321import { useEffect , useState } from "react" ;
24- import { changeData } from "../editor " ;
22+ import Markdown from "react-markdown " ;
2523
2624const CreateButton = ( ) => {
2725 const params = useParams < { qid : string } > ( ) ;
2826
2927 const router = useRouter ( ) ;
3028 const [ question , setQuestion ] = useState < QuestionResponse > ( ) ;
29+ const [ description , setDescription ] = useState < string > ( "teri-mummy" ) ;
3130 const queryClient = useQueryClient ( ) ;
3231 useEffect ( ( ) => {
3332 void toast . promise (
3433 GetQuestionById ( params . qid ) . then ( async ( q ) => {
3534 setQuestion ( q ) ;
36-
37-
38- void changeData ( q )
3935 } ) ,
4036 {
4137 loading : "Getting Question" ,
@@ -44,18 +40,13 @@ const CreateButton = () => {
4440 } ,
4541 ) ;
4642 } , [ params . qid ] ) ;
47- const {
48- register,
49- handleSubmit,
50- reset,
51- } = useForm < UpdateQuestionParams > ( ) ;
43+ const { register, handleSubmit, reset } = useForm < UpdateQuestionParams > ( ) ;
5244 const createQuestion = useMutation ( {
5345 mutationFn : ( data : UpdateQuestionParams ) => {
5446 data . id = params . qid ;
5547 data . input_format = data . input_format ?. [ 0 ] ?. split ( "\n" ) ?? [ ] ;
5648 data . points = + data . points ;
5749 data . round = + data . round ;
58-
5950 data . constraints = data . constraints ?. [ 0 ] ?. split ( "\n" ) ?? [ ] ;
6051 data . output_format = data . output_format ?. [ 0 ] ?. split ( "\n" ) ?? [ ] ;
6152 data . sample_test_input = data . sample_test_input ?. [ 0 ] ?. split ( "\n" ) ?? [ ] ;
@@ -88,7 +79,7 @@ const CreateButton = () => {
8879 < div className = "grid grid-cols-4 items-center gap-4" >
8980 < Label
9081 htmlFor = "title"
91- className = "text-right text-lg font-bold text-primary "
82+ className = "text-right text-lg font-bold text-white "
9283 >
9384 Title
9485 </ Label >
@@ -103,16 +94,29 @@ const CreateButton = () => {
10394 < div className = "grid grid-cols-4 items-center gap-4" >
10495 < Label
10596 htmlFor = "description"
106- className = "col-span-1 text-right text-lg font-bold text-primary "
97+ className = "col-span-1 text-right text-lg font-bold text-white "
10798 >
10899 Description
109100 </ Label >
110- < Editor />
101+ < div className = "col-span-3 flex gap-2" >
102+ { /* <Editor /> */ }
103+ < Textarea
104+ id = "description"
105+ defaultValue = { description }
106+ className = "w-full"
107+ { ...register ( "description" ) }
108+ onChange = { ( e ) => setDescription ( e . target . value ) }
109+ rows = { 10 }
110+ > </ Textarea >
111+ < Markdown className = "markdown w-full border p-2" >
112+ { description }
113+ </ Markdown >
114+ </ div >
111115 </ div >
112116 < div className = "grid grid-cols-4 items-center gap-4" >
113117 < Label
114118 htmlFor = "input_format"
115- className = "text-right text-lg font-bold text-primary "
119+ className = "text-right text-lg font-bold text-white "
116120 >
117121 Input Format
118122 </ Label >
@@ -127,7 +131,7 @@ const CreateButton = () => {
127131 < div className = "grid grid-cols-4 items-center gap-4" >
128132 < Label
129133 htmlFor = "points"
130- className = "text-right text-lg font-bold text-primary "
134+ className = "text-right text-lg font-bold text-white "
131135 >
132136 Points
133137 </ Label >
@@ -143,7 +147,7 @@ const CreateButton = () => {
143147 < div className = "grid grid-cols-4 items-center gap-4" >
144148 < Label
145149 htmlFor = "round"
146- className = "text-right text-lg font-bold text-primary "
150+ className = "text-right text-lg font-bold text-white "
147151 >
148152 Round
149153 </ Label >
@@ -161,7 +165,7 @@ const CreateButton = () => {
161165 < div className = "grid grid-cols-4 items-center gap-4" >
162166 < Label
163167 htmlFor = "constraints"
164- className = "text-right text-lg font-bold text-primary "
168+ className = "text-right text-lg font-bold text-white "
165169 >
166170 Constraints
167171 </ Label >
@@ -176,7 +180,7 @@ const CreateButton = () => {
176180 < div className = "grid grid-cols-4 items-center gap-4" >
177181 < Label
178182 htmlFor = "output_format"
179- className = "text-right text-lg font-bold text-primary "
183+ className = "text-right text-lg font-bold text-white "
180184 >
181185 Output Format
182186 </ Label >
@@ -191,7 +195,7 @@ const CreateButton = () => {
191195 < div className = "grid grid-cols-4 items-center gap-4" >
192196 < Label
193197 htmlFor = "sample_test_input"
194- className = "text-right text-lg font-bold text-primary "
198+ className = "text-right text-lg font-bold text-white "
195199 >
196200 Sample Test Input
197201 </ Label >
@@ -206,7 +210,7 @@ const CreateButton = () => {
206210 < div className = "grid grid-cols-4 items-center gap-4" >
207211 < Label
208212 htmlFor = "sample_test_output"
209- className = "text-right text-lg font-bold text-primary "
213+ className = "text-right text-lg font-bold text-white "
210214 >
211215 Sample Test Output
212216 </ Label >
@@ -221,7 +225,7 @@ const CreateButton = () => {
221225 < div className = "grid grid-cols-4 items-center gap-4" >
222226 < Label
223227 htmlFor = "explanation"
224- className = "text-right text-lg font-bold text-primary "
228+ className = "text-right text-lg font-bold text-white "
225229 >
226230 Explanation
227231 </ Label >
0 commit comments