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
036ec8c6
Commit
036ec8c6
authored
Jul 23, 2022
by
Yoon, Daeki
😅
Browse files
타입 정리
parent
b75f6008
Changes
12
Hide whitespace changes
Inline
Side-by-side
frontend/src/answers/ACheckboxForm.tsx
View file @
036ec8c6
import
React
,
{
useState
}
from
"
react
"
;
import
{
CheckboxType
,
AnswersType
,
AnswerProps
}
from
"
../types
"
;
import
{
CheckboxType
,
AnswerProps
}
from
"
../types
"
;
interface
Props
extends
AnswerProps
{
element
:
CheckboxType
;
answerQuestion
:
any
|
undefined
;
}
export
const
ACheckboxForm
=
({
element
,
answerQuestion
}:
Props
)
=>
{
...
...
frontend/src/answers/ADateForm.tsx
View file @
036ec8c6
import
React
,
{
useState
}
from
"
react
"
;
import
{
DateType
,
AnswersType
}
from
"
../types
"
;
type
Props
=
{
element
:
DateType
;
answerQuestion
:
any
|
undefined
;
};
export
const
ADateForm
=
({
element
,
answerQuestion
}:
Props
)
=>
{
import
{
AnswerProps
}
from
"
../types
"
;
export
const
ADateForm
=
({
element
,
answerQuestion
}:
AnswerProps
)
=>
{
const
[
answer
,
setAnswer
]
=
useState
(
""
);
const
handleChange
=
(
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
{
value
}
=
event
.
currentTarget
;
...
...
frontend/src/answers/ADropdownForm.tsx
View file @
036ec8c6
...
...
@@ -3,7 +3,6 @@ import { DropdownType, AnswerProps } from "../types";
interface
Props
extends
AnswerProps
{
element
:
DropdownType
;
answerQuestion
:
any
|
undefined
;
}
export
const
ADropdownForm
=
({
element
,
answerQuestion
}:
Props
)
=>
{
...
...
frontend/src/answers/AEssayForm.tsx
View file @
036ec8c6
import
React
,
{
useState
}
from
"
react
"
;
import
{
AnswerProps
,
EssayType
}
from
"
../types
"
;
import
{
AnswerProps
,
AnswerQuestionType
,
EssayType
}
from
"
../types
"
;
type
Props
=
{
element
:
EssayType
;
answerQuestion
:
any
|
undefined
;
};
export
const
AEssayForm
=
({
element
,
answerQuestion
}:
Props
)
=>
{
export
const
AEssayForm
=
({
element
,
answerQuestion
}:
AnswerProps
)
=>
{
const
[
answer
,
setAnswer
]
=
useState
(
""
);
const
handleChange
=
(
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
...
...
frontend/src/answers/AFileForm.tsx
View file @
036ec8c6
import
React
,
{
useState
}
from
"
react
"
;
import
{
FileType
,
AnswersType
,
AnswerProps
}
from
"
../types
"
;
import
{
AnswerProps
}
from
"
../types
"
;
interface
Props
extends
AnswerProps
{
element
:
FileType
;
answerQuestion
:
any
|
undefined
;
addFiles
:
(
oneFile
:
{
questionId
:
string
;
file
:
File
})
=>
void
;
}
...
...
frontend/src/answers/AQuestion.tsx
View file @
036ec8c6
import
React
from
"
react
"
;
import
{
BasicQuestionType
,
Answer
sType
,
Survey
Type
}
from
"
../types
"
;
import
{
BasicQuestionType
,
Answer
Question
Type
}
from
"
../types
"
;
import
{
ACheckboxForm
}
from
"
./ACheckboxForm
"
;
import
{
ADateForm
}
from
"
./ADateForm
"
;
import
{
ADropdownForm
}
from
"
./ADropdownForm
"
;
...
...
@@ -10,7 +10,7 @@ import { ARatingForm } from "./ARatingForm";
type
Props
=
{
question
:
BasicQuestionType
;
answerQuestion
:
any
|
undefined
;
answerQuestion
:
AnswerQuestionType
;
addFiles
:
(
oneFile
:
{
questionId
:
string
;
file
:
File
})
=>
void
;
};
export
const
AQuestion
=
({
question
,
answerQuestion
,
addFiles
}:
Props
)
=>
{
...
...
frontend/src/answers/ARadioForm.tsx
View file @
036ec8c6
import
React
,
{
useState
}
from
"
react
"
;
import
{
RadioType
,
AnswersType
,
AnswerProps
}
from
"
../types
"
;
import
{
RadioType
,
AnswerProps
}
from
"
../types
"
;
interface
Props
extends
AnswerProps
{
element
:
RadioType
;
answerQuestion
:
any
|
undefined
;
}
export
const
ARadioForm
=
({
element
,
answerQuestion
}:
Props
)
=>
{
...
...
frontend/src/answers/ARatingForm.tsx
View file @
036ec8c6
import
React
,
{
useState
}
from
"
react
"
;
import
{
RatingType
,
AnswersType
,
AnswerProps
}
from
"
../types
"
;
import
{
RatingType
,
AnswerProps
}
from
"
../types
"
;
interface
Props
extends
AnswerProps
{
element
:
RatingType
;
answerQuestion
:
any
|
undefined
;
}
export
const
ARatingForm
=
({
element
,
answerQuestion
}:
Props
)
=>
{
...
...
frontend/src/answers/AnswerSurveyForm.tsx
View file @
036ec8c6
...
...
@@ -4,7 +4,7 @@ import { useParams } from "react-router-dom";
import
{
surveyApi
,
answerApi
}
from
"
../apis
"
;
import
{
catchErrors
}
from
"
../helpers
"
;
import
{
Question
}
from
"
../questions
"
;
import
{
AnswerType
,
SurveyType
}
from
"
../types
"
;
import
{
AnswerSurveyType
,
AnswerType
,
SurveyType
}
from
"
../types
"
;
import
{
AQuestion
}
from
"
./AQuestion
"
;
export
const
AnswerSurveyForm
=
()
=>
{
...
...
@@ -16,14 +16,14 @@ export const AnswerSurveyForm = () => {
const
[
success
,
setSuccess
]
=
useState
(
false
);
const
navigate
=
useNavigate
();
const
[
survey
,
setSurvey
]
=
useState
<
SurveyType
>
({
_id
:
surveyId
,
_id
:
surveyId
||
""
,
user
:
{},
title
:
""
,
comment
:
""
,
questions
:
[],
});
const
answerSurvey
=
useRef
<
any
>
({
const
answerSurvey
=
useRef
<
AnswerSurveyType
>
({
_id
:
"
surveyId
"
,
user
:
{},
title
:
""
,
...
...
@@ -34,7 +34,9 @@ export const AnswerSurveyForm = () => {
useEffect
(()
=>
{
ansSurvey
();
},
[
surveyId
]);
const
isSurvey
=
localStorage
.
getItem
(
`survey_
${
surveyId
}
`
);
if
(
isSurvey
)
{
console
.
log
(
"
object
"
,
isSurvey
);
alert
(
"
제출한 설문조사입니다
"
);
...
...
frontend/src/profile/Profile.tsx
View file @
036ec8c6
...
...
@@ -7,6 +7,7 @@ import { MySurveyCard } from "./MySurveyCard";
export
const
Profile
=
()
=>
{
const
navigate
=
useNavigate
();
const
[
survey
,
setSurvey
]
=
useState
<
SurveyType
>
({
_id
:
""
,
user
:
{},
title
:
""
,
comment
:
""
,
...
...
frontend/src/survey/EditSurvey.tsx
View file @
036ec8c6
...
...
@@ -22,7 +22,7 @@ export const EditSurvey = () => {
const
[
success
,
setSuccess
]
=
useState
(
false
);
const
navigate
=
useNavigate
();
const
[
survey
,
setSurvey
]
=
useState
<
SurveyType
>
({
_id
:
surveyId
,
_id
:
surveyId
||
""
,
user
:
{},
title
:
""
,
comment
:
""
,
...
...
frontend/src/types/index.ts
View file @
036ec8c6
...
...
@@ -11,7 +11,7 @@ export interface SignupUser {
}
export
interface
SurveyType
{
_id
?
:
string
;
_id
:
string
;
user
:
any
;
title
:
string
;
comment
:
string
;
...
...
@@ -30,9 +30,17 @@ export interface BasicQuestionType {
[
key
:
string
]:
string
|
number
|
boolean
|
any
;
}
export
interface
AnswerQuestionType
extends
BasicQuestionType
{
requiredCheck
:
boolean
;
answer
:
any
;
}
export
interface
AnswerSurveyType
extends
SurveyType
{
questions
:
AnswerQuestionType
[];
}
export
interface
EssayType
extends
BasicQuestionType
{}
export
interface
DateType
extends
BasicQuestionType
{}
export
interface
RadioType
extends
BasicQuestionType
{
content
:
{
choices
:
{
...
...
@@ -95,6 +103,7 @@ export interface AnswerType {
export
interface
AnswerProps
{
element
:
BasicQuestionType
;
answerQuestion
:
AnswerQuestionType
;
// answers: AnswersType | undefined;
// handleAnswer: () => void;
}
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