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