Commit 036ec8c6 authored by Yoon, Daeki's avatar Yoon, Daeki 😅
Browse files

타입 정리

parent b75f6008
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) => {
......
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;
......
......@@ -3,7 +3,6 @@ import { DropdownType, AnswerProps } from "../types";
interface Props extends AnswerProps {
element: DropdownType;
answerQuestion: any | undefined;
}
export const ADropdownForm = ({ element, answerQuestion }: Props) => {
......
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>) => {
......
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;
}
......
import React from "react";
import { BasicQuestionType, AnswersType, SurveyType } from "../types";
import { BasicQuestionType, AnswerQuestionType } 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) => {
......
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) => {
......
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) => {
......
......@@ -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("제출한 설문조사입니다");
......
......@@ -7,6 +7,7 @@ import { MySurveyCard } from "./MySurveyCard";
export const Profile = () => {
const navigate = useNavigate();
const [survey, setSurvey] = useState<SurveyType>({
_id: "",
user: {},
title: "",
comment: "",
......
......@@ -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: "",
......
......@@ -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;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment