Commit 3e2be733 authored by Jiwon Yoon's avatar Jiwon Yoon
Browse files

Merge branch 'DH1' into develop

parents 7cfe38be 9f2502d8
...@@ -2,6 +2,7 @@ import React from "react"; ...@@ -2,6 +2,7 @@ import React from "react";
import { CheckboxType } from "../types"; import { CheckboxType } from "../types";
import { useQuestion } from "./question.context"; import { useQuestion } from "./question.context";
import { Edit } from "./Edit"; import { Edit } from "./Edit";
import { TypeChange } from "./typeDD";
type Props = { type Props = {
element: CheckboxType; element: CheckboxType;
...@@ -21,22 +22,7 @@ export const QCheckbox = ({ element }: Props) => { ...@@ -21,22 +22,7 @@ export const QCheckbox = ({ element }: Props) => {
placeholder={element.title} placeholder={element.title}
onChange={questionListChange} onChange={questionListChange}
></input> ></input>
<select <TypeChange tt="checkbox" />
id="Questions"
className="w-36 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-themeColor w-full mr-3 p-2.5"
>
<option>질문종류</option>
<option value="essay">주관식</option>
<option value="radio">객관식</option>
<option value="dropdown">드롭다운(객관식)</option>
<option value="checkbox" selected>
체크박스(객관식)
</option>
<option value="file">파일업로드</option>
<option value="rating">선형</option>
<option value="grid">그리드</option>
<option value="date">날짜</option>
</select>
</div> </div>
<div className="flex w-full justify-center"> <div className="flex w-full justify-center">
<input <input
......
import React from "react"; import React from "react";
import { DropdownType } from "../types"; import { DropdownType } from "../types";
import { useQuestion } from "./question.context"; import { useQuestion } from "./question.context";
import { TypeChange } from "./typeDD";
type Props = { type Props = {
element: DropdownType; element: DropdownType;
...@@ -19,22 +20,7 @@ export const QDropdown = ({ element }: Props) => { ...@@ -19,22 +20,7 @@ export const QDropdown = ({ element }: Props) => {
placeholder={element.title} placeholder={element.title}
onChange={questionListChange} onChange={questionListChange}
></input> ></input>
<select <TypeChange tt="dropdown" />
id="Questions"
className="w-36 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-themeColor w-full mr-3 p-2.5"
>
<option>질문종류</option>
<option value="essay">주관식</option>
<option value="radio">객관식</option>
<option value="dropdown" selected>
드롭다운(객관식)
</option>
<option value="checkbox">체크박스(객관식)</option>
<option value="file">파일업로드</option>
<option value="rating">선형</option>
<option value="grid">그리드</option>
<option value="date">날짜</option>
</select>
</div> </div>
<div className="flex w-full justify-center"> <div className="flex w-full justify-center">
<input <input
......
...@@ -2,6 +2,7 @@ import React, { useState } from "react"; ...@@ -2,6 +2,7 @@ import React, { useState } from "react";
import { EssayType } from "../types"; import { EssayType } from "../types";
import { useQuestion } from "./question.context"; import { useQuestion } from "./question.context";
import { Edit } from "./Edit"; import { Edit } from "./Edit";
import { TypeChange } from "./typeDD";
type Props = { type Props = {
element: EssayType; element: EssayType;
...@@ -21,22 +22,8 @@ export const QEssay = ({ element }: Props) => { ...@@ -21,22 +22,8 @@ export const QEssay = ({ element }: Props) => {
placeholder={element.title} placeholder={element.title}
onChange={questionListChange} onChange={questionListChange}
></input> ></input>
<select {/* <TypeChange tt={"essay"} id={element._id} /> */}
id="Questions" <TypeChange tt={"essay"} />
className="w-36 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-themeColor w-full mr-3 p-2.5"
>
<option>질문종류</option>
<option value="essay" selected>
주관식
</option>
<option value="radio">객관식</option>
<option value="dropdown">드롭다운(객관식)</option>
<option value="checkbox">체크박스(객관식)</option>
<option value="file">파일업로드</option>
<option value="rating">선형</option>
<option value="grid">그리드</option>
<option value="date">날짜</option>
</select>
</div> </div>
<div className="flex w-full justify-center"> <div className="flex w-full justify-center">
<input <input
......
import React, { useState } from "react"; import React, { useState } from "react";
import { FileType } from "../types"; import { FileType } from "../types";
import { useQuestion } from "./question.context"; import { useQuestion } from "./question.context";
import { TypeChange } from "./typeDD";
type Props = { type Props = {
element: FileType; element: FileType;
...@@ -20,22 +21,7 @@ export const QFile = ({ element }: Props) => { ...@@ -20,22 +21,7 @@ export const QFile = ({ element }: Props) => {
placeholder={element.title} placeholder={element.title}
onChange={questionListChange} onChange={questionListChange}
></input> ></input>
<select <TypeChange tt="file" />
id="Questions"
className="w-36 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-themeColor w-full mr-3 p-2.5"
>
<option>질문종류</option>
<option value="essay">주관식</option>
<option value="radio">객관식</option>
<option value="dropdown">드롭다운(객관식)</option>
<option value="checkbox">체크박스(객관식)</option>
<option value="file" selected>
파일업로드
</option>
<option value="rating">선형</option>
<option value="grid">그리드</option>
<option value="date">날짜</option>
</select>
</div> </div>
<div className="flex w-full justify-center"> <div className="flex w-full justify-center">
<input <input
......
import React from "react"; import React from "react";
import { RadioType } from "../types"; import { RadioType } from "../types";
import { useQuestion } from "./question.context"; import { useQuestion } from "./question.context";
import { TypeChange } from "./typeDD";
type Props = { type Props = {
element: RadioType; element: RadioType;
...@@ -19,21 +20,7 @@ export const QRadio = ({ element }: Props) => { ...@@ -19,21 +20,7 @@ export const QRadio = ({ element }: Props) => {
placeholder={element.title} placeholder={element.title}
onChange={questionListChange} onChange={questionListChange}
></input> ></input>
<select <TypeChange tt="radio" />
id="Questions"
className="w-36 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-themeColor focus:themeColor block w-full mr-3 p-2.5"
>
<option>질문종류</option>
<option value="Essay">주관식</option>
<option value="MultipleChoice" selected>
객관식
</option>
<option value="Dropdown">드롭다운(객관식)</option>
<option value="CheckBox">체크박스(객관식)</option>
<option value="Rating">선형</option>
<option value="Grid">그리드</option>
<option value="Date">날짜</option>
</select>
</div> </div>
<div className="flex w-full justify-center"> <div className="flex w-full justify-center">
<input <input
......
import React from "react"; import React from "react";
import { RatingType } from "../types"; import { RatingType } from "../types";
import { useQuestion } from "./question.context"; import { useQuestion } from "./question.context";
import { TypeChange } from "./typeDD";
type Props = { type Props = {
element: RatingType; element: RatingType;
...@@ -21,22 +22,7 @@ export const QRating = ({ element }: Props) => { ...@@ -21,22 +22,7 @@ export const QRating = ({ element }: Props) => {
placeholder={element.title} placeholder={element.title}
onChange={questionListChange} onChange={questionListChange}
></input> ></input>
<select <TypeChange tt="rating" />
id={element._id}
className="w-36 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-themeColor w-full mr-3 p-2.5"
>
<option>질문종류</option>
<option value="essay">주관식</option>
<option value="radio">객관식</option>
<option value="dropdown">드롭다운(객관식)</option>
<option value="checkbox">체크박스(객관식)</option>
<option value="file">파일업로드</option>
<option value="rating" selected>
선형
</option>
<option value="grid">그리드</option>
<option value="date">날짜</option>
</select>
</div> </div>
<div className="flex w-full justify-center"> <div className="flex w-full justify-center">
<input <input
......
...@@ -17,6 +17,7 @@ interface IQuestionContext { ...@@ -17,6 +17,7 @@ interface IQuestionContext {
editCompleteClick: (e: React.MouseEvent<HTMLButtonElement>) => void; editCompleteClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
currentId: string; currentId: string;
addQuestion: (e: React.MouseEvent<HTMLButtonElement>) => Promise<void>; addQuestion: (e: React.MouseEvent<HTMLButtonElement>) => Promise<void>;
questionTypeChange: (e: React.ChangeEvent<HTMLSelectElement>) => void;
} }
const QuestionContext = createContext<IQuestionContext>({ const QuestionContext = createContext<IQuestionContext>({
...@@ -28,6 +29,7 @@ const QuestionContext = createContext<IQuestionContext>({ ...@@ -28,6 +29,7 @@ const QuestionContext = createContext<IQuestionContext>({
editCompleteClick: () => {}, editCompleteClick: () => {},
currentId: "", currentId: "",
addQuestion: async () => {}, addQuestion: async () => {},
questionTypeChange: () => {},
}); });
export const QuestionProvider: FC<{ children: ReactNode }> = ({ children }) => { export const QuestionProvider: FC<{ children: ReactNode }> = ({ children }) => {
...@@ -73,6 +75,13 @@ export const QuestionProvider: FC<{ children: ReactNode }> = ({ children }) => { ...@@ -73,6 +75,13 @@ export const QuestionProvider: FC<{ children: ReactNode }> = ({ children }) => {
obj[targetKey] = e.target.value; obj[targetKey] = e.target.value;
setQuestionList(newList); setQuestionList(newList);
} }
function questionTypeChange(e: React.ChangeEvent<HTMLSelectElement>): void {
const newType: BasicQuestionType[] = [...questionList];
const objType: any = newType.find((t) => t._id === e.target.id);
const targetType: string = e.target.name;
objType[targetType] = e.target.value;
setQuestionList(newType);
}
async function addQuestion() { async function addQuestion() {
try { try {
...@@ -106,6 +115,7 @@ export const QuestionProvider: FC<{ children: ReactNode }> = ({ children }) => { ...@@ -106,6 +115,7 @@ export const QuestionProvider: FC<{ children: ReactNode }> = ({ children }) => {
editClick, editClick,
editCompleteClick, editCompleteClick,
currentId, currentId,
questionTypeChange,
}} }}
> >
{children} {children}
......
import React, { ChangeEvent, useState } from "react";
import { useQuestion } from "./question.context";
type typeChangeProps = {
tt: string;
};
export function TypeChange({ tt }: typeChangeProps) {
const { questionTypeChange } = useQuestion();
const typeDD = new Map([
["essay", "주관식"],
["radio", "객관식"],
["dropdown", "드롭다운(객관식)"],
["checkbox", "체크박스"],
["file", "파일"],
["rating", "선형"],
["grid", "그리드"],
["date", "날짜"],
]);
function changeDD(e: React.ChangeEvent<HTMLSelectElement>) {
const tt = e.target.value;
// questionTypeChange(e);
console.log(tt);
//if문으로 type별로 content 바뀌게 해보기
}
return (
<select
id="Questions"
name="type"
className="w-36 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-themeColor w-full mr-3 p-2.5"
defaultValue={tt}
onChange={changeDD}
>
{Array.from(typeDD.entries()).map(([k, v]) => (
<option value={k}>{v}</option>
))}
</select>
);
}
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