Skip to content

Commit ecc89a5

Browse files
committed
Fixed CORS requirement for adding questions
1 parent 9c720be commit ecc89a5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

peerprep/api/gateway.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export async function addQuestion(body: QuestionFullBody): Promise<StatusBody> {
5252
`${process.env.NEXT_PUBLIC_QUESTION_SERVICE}/questions`,
5353
{
5454
method: "POST",
55-
body: JSON.stringify(body),
55+
body: JSON.stringify(body).replace(/(\"difficulty\":)\"([1-3])\"/, `$1$2`),
5656
headers: {
5757
"Content-type": "application/json; charset=UTF-8"
5858
}

peerprep/app/q/new/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function NewQuestion({}: Props) {
2020
description: "",
2121
});
2222

23-
const handleTextInput = (e: ChangeEvent<HTMLInputElement>) => setFormData({
23+
const handleTextInput = (e: ChangeEvent<HTMLInputElement|HTMLTextAreaElement>) => setFormData({
2424
...formData,
2525
[e.target.name]: e.target.value
2626
});
@@ -63,14 +63,14 @@ function NewQuestion({}: Props) {
6363
return (
6464
<div>
6565
<form style={{color: "black", padding: "5px"}} onSubmit={handleSubmission}>
66-
<input type="text" name="title" /><br/>
66+
<input type="text" name="title" value={formData.title} onChange={handleTextInput}/><br/>
6767
<input type="radio" id="easy" name="difficulty" value={1} onChange={handleTextInput} />
6868
<label htmlFor="easy">Easy</label><br/>
6969
<input type="radio" id="med" name="difficulty" value={2} onChange={handleTextInput} />
7070
<label htmlFor="med">Medium</label><br/>
7171
<input type="radio" id="hard" name="difficulty" value={3} onChange={handleTextInput} />
7272
<label htmlFor="hard">Hard</label><br/>
73-
<textarea name="description" /><br/>
73+
<textarea name="description" value={formData.description} onChange={handleTextInput}/><br/>
7474
{testCases.map((elem, idx) => (
7575
<>
7676
<input

0 commit comments

Comments
 (0)