Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
survey
Commits
bf1fbd5f
Commit
bf1fbd5f
authored
Jul 08, 2022
by
Jiwon Yoon
Browse files
questionApi : createQuestion
parent
72abe1cb
Changes
3
Hide whitespace changes
Inline
Side-by-side
frontend/src/CreateSurveyForm/question.context.tsx
View file @
bf1fbd5f
...
@@ -7,6 +7,7 @@ import React, {
...
@@ -7,6 +7,7 @@ import React, {
}
from
"
react
"
;
}
from
"
react
"
;
import
axios
from
"
axios
"
;
import
axios
from
"
axios
"
;
import
{
BasicQuestionType
}
from
"
../types
"
;
import
{
BasicQuestionType
}
from
"
../types
"
;
import
{
questionApi
}
from
"
../apis
"
;
interface
IQuestionContext
{
interface
IQuestionContext
{
questionListChange
:
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
void
;
questionListChange
:
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
void
;
...
@@ -38,17 +39,10 @@ export const QuestionProvider: FC<{ children: ReactNode }> = ({ children }) => {
...
@@ -38,17 +39,10 @@ export const QuestionProvider: FC<{ children: ReactNode }> = ({ children }) => {
setQuestionList
(
newList
);
setQuestionList
(
newList
);
}
}
async
function
addQuestion
(
e
:
React
.
MouseEvent
<
HTMLButtonElement
>
)
{
async
function
addQuestion
()
{
try
{
try
{
const
res
=
await
axios
.
post
(
"
/api/questions/create
"
,
{
const
newQ
:
BasicQuestionType
=
await
questionApi
.
createQuestion
();
type
:
"
essay
"
,
setQuestionList
([...
questionList
,
newQ
]);
title
:
"
Question Title
"
,
isRequired
:
false
,
comment
:
"
질문에 대한 설명을 입력해주세요
"
,
content
:
null
,
});
console
.
log
(
res
.
data
);
setQuestionList
([...
questionList
,
res
.
data
]);
// setSuccess(true);
// setSuccess(true);
// setError("");
// setError("");
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
frontend/src/apis/index.ts
View file @
bf1fbd5f
import
axios
from
"
axios
"
;
import
axios
from
"
axios
"
;
export
*
as
authApi
from
"
./auth.api
"
;
export
*
as
authApi
from
"
./auth.api
"
;
export
*
as
questionApi
from
"
./question.api
"
frontend/src/apis/question.api.ts
View file @
bf1fbd5f
import
axios
from
"
axios
"
;
import
{
}
from
"
../types
"
;
import
baseUrl
from
"
./baseUrl
"
;
export
const
createQuestion
=
async
()
=>
{
const
{
data
}
=
await
axios
.
post
(
`
${
baseUrl
}
/questions/create`
,
{
type
:
"
essay
"
,
title
:
"
Question Title
"
,
isRequired
:
false
,
comment
:
"
질문에 대한 설명을 입력해주세요
"
,
content
:
null
,
});
return
data
;
};
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment