Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function Header() {

function logout() {
axios.get(`${baseURL}/api/auth/logout`).then((res) => {
console.log(res);
// console.log(res);
if (res.data.statusCode === 200) {
localStorage.clear();
setLogin(false);
Expand Down
27 changes: 26 additions & 1 deletion frontend/src/components/atoms/buttons/LargeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,27 @@ import styled from "@emotion/styled";

interface Props {
label: string;
type?: string;
onClick: () => void;
}

const Div = styled.div`
.half {
width: 47vw;
}

.red {
background-color: #ef7474;
width: 47vw;
&:hover {
background-color: #cc6e6e;
}
}

.full {
}
`;

const Button = styled.button`
margin-top: 10px;
font-family: "DungGeunMo";
Expand All @@ -26,5 +45,11 @@ const Button = styled.button`
* @returns
*/
export default function LargeButton(props: Props) {
return <Button>{props.label}</Button>;
return (
<Div>
<Button onClick={props.onClick} className={props.type}>
{props.label}
</Button>
</Div>
);
}
28 changes: 20 additions & 8 deletions frontend/src/components/atoms/etc/Multiple.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import styled from "@emotion/styled";

interface Props {
num: number;
num: string;
selected: string;
func: (e: React.MouseEvent<HTMLButtonElement>) => void;
}

const Div = styled.div`
.selected {
background-color: #d6e7e2;
color: #5bb8a1;
}
`;

const Button = styled.button`
font-family: "Press Start 2P";
border-radius: 10px;
Expand All @@ -14,10 +23,7 @@ const Button = styled.button`
border: none;
color: white;
margin: 5px 10px 5px 0px;
&:focus {
background-color: #d6e7e2;
color: #5bb8a1;
}

&:hover {
cursor: pointer;
background-color: #25b097;
Expand All @@ -31,8 +37,14 @@ const Button = styled.button`
*/
export default function Multiple(props: Props) {
return (
<Button onClick={props.func} value={props.num}>
{props.num}
</Button>
<Div>
<Button
className={props.selected === props.num ? "selected" : ""}
onClick={props.func}
value={props.num}
>
{props.num}
</Button>
</Div>
);
}
11 changes: 9 additions & 2 deletions frontend/src/components/atoms/inputs/LargeInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import styled from "@emotion/styled";
import { ChangeEvent } from "react";

interface Props {
value: string;
onChange: any;
// onChange: (event: ChangeEvent<HTMLInputElement>) => void;
}

const Textarea = styled.textarea`
border-radius: 10px;
Expand All @@ -18,6 +25,6 @@ const Textarea = styled.textarea`
}
`;

export default function LargeInput() {
return <Textarea />;
export default function LargeInput({ value, onChange }: Props) {
return <Textarea value={value} onChange={onChange} />;
}
9 changes: 7 additions & 2 deletions frontend/src/components/atoms/inputs/SmallInput.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import styled from "@emotion/styled";
import { ChangeEvent } from "react";

interface Props {
value: string;
onChange: (event: ChangeEvent<HTMLInputElement>, index?: number) => void;
}
const Input = styled.input`
border-radius: 10px;
width: 100%;
Expand All @@ -18,6 +23,6 @@ const Input = styled.input`
}
`;

export default function SmallInput() {
return <Input />;
export default function SmallInput({ value, onChange }: Props) {
return <Input value={value} onChange={onChange} />;
}
17 changes: 8 additions & 9 deletions frontend/src/components/molecules/CreateQuizCategory.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import typeState from "@/recoil/type";
import categoryState from "@/recoil/category";
import styled from "@emotion/styled";
import { useRecoilState } from "recoil";
import Dropdown from "../atoms/etc/Dropdown";
import newQuizState from "@/recoil/newquiz";

const Container = styled.div`
font-family: "DungGeunMo";
Expand All @@ -26,9 +25,9 @@ const Text2 = styled.div`
*/
export default function CreateQuizCategory() {
const types = [
{ value: "multiple", name: "๊ฐ๊ด€์‹" },
{ value: "short-answer", name: "์ฃผ๊ด€์‹" },
{ value: "essay", name: "์„œ์ˆ ํ˜•" },
{ value: "๊ฐ๊ด€์‹", name: "๊ฐ๊ด€์‹" },
{ value: "์ฃผ๊ด€์‹", name: "์ฃผ๊ด€์‹" },
{ value: "์„œ์ˆ ํ˜•", name: "์„œ์ˆ ํ˜•" },
];
const categories = [
{ value: "๋„คํŠธ์›Œํฌ", name: "๋„คํŠธ์›Œํฌ" },
Expand All @@ -38,14 +37,14 @@ export default function CreateQuizCategory() {
{ value: "์•ฑ", name: "์•ฑ" },
];

const [type, setType] = useRecoilState(typeState);
const [newQuiz, setNewQuiz] = useRecoilState(newQuizState);

const handleType = (e: React.ChangeEvent<HTMLSelectElement>) => {
setType(e.target.value);
setNewQuiz((prev) => ({ ...prev, type: e.target.value }));
};

const [category, setCategory] = useRecoilState(categoryState);
const handleCategory = (e: React.ChangeEvent<HTMLSelectElement>) => {
setCategory(e.target.value);
setNewQuiz((prev) => ({ ...prev, category: e.target.value }));
};

return (
Expand Down
69 changes: 56 additions & 13 deletions frontend/src/components/organisms/createquiz/CreateMultiple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Multiple from "@/components/atoms/etc/Multiple";
import LargeInput from "@/components/atoms/inputs/LargeInput";
import SmallInput from "@/components/atoms/inputs/SmallInput";
import multipleAnswerState from "@/recoil/multipleanswer";
import newQuizState from "@/recoil/newquiz";
import styled from "@emotion/styled";
import { useRecoilState } from "recoil";

Expand All @@ -28,47 +29,89 @@ const Title = styled.div`
* @returns
*/
export default function CreateMultiple() {
const [answer, setAnswer] = useRecoilState(multipleAnswerState);
const [newQuiz, setNewQuiz] = useRecoilState(newQuizState);
// console.log("curr: ", newQuiz);
const handleAnswer = (e: any) => {
setAnswer(e.target.value);
setNewQuiz((prev) => ({ ...prev, answer: e.target.value }));
};

const handleTitle = (e: any) => {
setNewQuiz((prev) => ({ ...prev, title: e.target.value }));
};

const handleQuestion = (e: any) => {
setNewQuiz((prev) => ({ ...prev, question: e.target.value }));
};

const handleOption = (v: any, index: number) => {
setNewQuiz((prevData) => {
return {
...prevData,
options: [...prevData.options.slice(0, index), v, ...prevData.options.slice(index + 1)],
};
});
};

const handleDescription = (e: any) => {
setNewQuiz((prev) => ({ ...prev, description: e.target.value }));
};

return (
<Container>
<Row>
<Title>์ œ๋ชฉ</Title>
<SmallInput />
<SmallInput value={newQuiz.title} onChange={handleTitle} />
</Row>
<Row>
<Title>๋ฌธ์ œ</Title>
<SmallInput />
<SmallInput value={newQuiz.question} onChange={handleQuestion} />
</Row>
<Row>
<Title>1</Title>
<SmallInput />
<SmallInput
value={newQuiz.options[0]}
onChange={(e) => {
handleOption(e.target.value, 0);
}}
/>
</Row>
<Row>
<Title>2</Title>
<SmallInput />
<SmallInput
value={newQuiz.options[1]}
onChange={(e) => {
handleOption(e.target.value, 1);
}}
/>
</Row>
<Row>
<Title>3</Title>
<SmallInput />
<SmallInput
value={newQuiz.options[2]}
onChange={(e) => {
handleOption(e.target.value, 2);
}}
/>
</Row>
<Row>
<Title>4</Title>
<SmallInput />
<SmallInput
value={newQuiz.options[3]}
onChange={(e) => {
handleOption(e.target.value, 3);
}}
/>
</Row>
<Row>
<Title>์ •๋‹ต&nbsp;</Title>
<Multiple num={1} func={handleAnswer} />
<Multiple num={2} func={handleAnswer} />
<Multiple num={3} func={handleAnswer} />
<Multiple num={4} func={handleAnswer} />
<Multiple selected={newQuiz.answer} num={"1"} func={handleAnswer} />
<Multiple selected={newQuiz.answer} num={"2"} func={handleAnswer} />
<Multiple selected={newQuiz.answer} num={"3"} func={handleAnswer} />
<Multiple selected={newQuiz.answer} num={"4"} func={handleAnswer} />
</Row>
<Row>
<Title>ํ•ด์„ค</Title>
<LargeInput />
<LargeInput value={newQuiz.description} onChange={handleDescription} />
</Row>
</Container>
);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/template/auth/SignUpBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default function SignUpBody() {
axios
.post(`${baseURL}/api/auth/signup`, data)
.then((res) => {
console.log(res);
// console.log(res);
if (res.data.statusCode === 201) {
swal("ํšŒ์›๊ฐ€์ž…์ด ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค", {
icon: "success",
Expand Down
33 changes: 25 additions & 8 deletions frontend/src/components/template/common/CreateModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import styled from "@emotion/styled";
import router from "next/router";
import { useEffect } from "react";
import api from "@/interceptor";
import newQuizState from "@/recoil/newquiz";
import { useRecoilState } from "recoil";

// ๋ชจ๋‹ฌ ์ฐฝ ๋’ท๋ฐฐ๊ฒฝ
export const SearchModalBox = styled.div`
Expand Down Expand Up @@ -42,7 +45,11 @@ export const SearchModalContent = styled.div`
font-size: 1.7em;
}
> div:nth-of-type(4) {
margin-top: 10px;
margin-top: 15px;
font-size: 1em;
}
> div:nth-of-type(5) {
margin-top: 5px;
font-size: 1em;
}
> div {
Expand All @@ -53,7 +60,7 @@ export const SearchModalContent = styled.div`
border: none;
width: 180px;
margin-top: 20px;
padding: 0.4rem 0.6rem;
padding: 0.2rem 0.6rem;
font-size: 0.9rem;
margin-right: 10px;
border-radius: 5px;
Expand Down Expand Up @@ -88,19 +95,29 @@ export default function CreateModal(props: Props) {
};
}, []);

const onSubmit = () => {
router.push("/");
};
const [newQuiz, setNewQuiz] = useRecoilState(newQuizState);

const baseURL = process.env.NEXT_PUBLIC_API_BASE_URL;

function onSubmit() {
api
.post(`${baseURL}/api/problem/pending`, newQuiz)
.then((res) => {
console.log(res);
})
.catch((e) => {
console.log(e);
});
}

return (
<SearchModalBox onClick={props.clickModal}>
<SearchModalContent onClick={(e) => e.stopPropagation()}>
<div onClick={props.clickModal}>X</div>
<div>์•Œ๋ฆผ!</div>
<div>์ œ์ถœํ•œ ๋ฌธ์ œ๋Š” ๊ด€๋ฆฌ์ž ์Šน์ธ ์ดํ›„ ๋“ฑ๋ก๋ฉ๋‹ˆ๋‹ค.</div>
<div>
๊ณผ์ • ์ค‘ ์ˆ˜์ •์‚ฌํ•ญ์ด ๋ฐœ๊ฒฌ๋  ๊ฒฝ์šฐ, ๋ฌธ์ œ ๋‚ด์šฉ์ด ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
</div>
<div>๋ฌธ์ œ ๋‚ด์šฉ๊ณผ ์นดํ…Œ๊ณ ๋ฆฌ๊ฐ€ ์ •ํ™•ํžˆ ๋“ฑ๋ก๋˜์—ˆ๋Š”์ง€ ๋‹ค์‹œ ํ•œ ๋ฒˆ ํ™•์ธํ•ด์ฃผ์„ธ์š”.</div>
<div>๊ณผ์ • ์ค‘ ์ˆ˜์ •์‚ฌํ•ญ์ด ๋ฐœ๊ฒฌ๋  ๊ฒฝ์šฐ, ๋ฌธ์ œ ๋‚ด์šฉ์ด ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.</div>
<div>
<button onClick={onSubmit}>๊ณ„์†ํ•˜๊ธฐ</button>
<button onClick={props.clickModal}>์ทจ์†Œํ•˜๊ธฐ</button>
Expand Down
Loading