From 0d40cb4f45ae59773ff6cb9ae7dd03013c919e7a Mon Sep 17 00:00:00 2001 From: Leo <51093294+algo2000@users.noreply.github.com> Date: Fri, 12 Nov 2021 23:37:17 +0900 Subject: [PATCH] =?UTF-8?q?post=20API=20Res/Req=20=EC=B6=94=EA=B0=80,=20?= =?UTF-8?q?=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=88=98=EC=A0=95,=20k8?= =?UTF-8?q?s=20=EC=88=98=EC=A0=95=20(#84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add (todo 추가) api Req/Res 추가 * 기본설정 * add new course API Res/Req 추가 * up hooks * up course Color 선택 컴포넌트로 뺌 * fix 리펙토링 과정 에러 픽스 * add tag 선택 체인지 훅 추기 * up tag선택 시 선택된 tag 리스트 가져오기 * up 코스 추가 기능(데이터 Validation X) * up coursePinList 최근 순으로 나오게 변경 * add hooks 코스 변경, 반복 요일 변경 * up 타입 수정 * up 코스 변경, 반복 요일 변경 훅 추가 * up (할일 추가) 추가 * package version up * up 요일 반복 기능 아직 추가안함 * up 수정된 API Spec 수정 * ci/cd k8s 스캐줄 개선 * rollback: 이전 배포 형식으로 복구 * up: 배포 다시 롤백 * test: k8s 배포테스트틀 위함 * test: k8s 배포테스트틀 위함 Co-authored-by: 박경은 --- domain/Course/CoursePinList/index.tsx | 2 +- domain/Course/CreateCourse/index.tsx | 89 ++++++++++++----------- domain/Course/CreateCourse/style.ts | 15 +--- domain/Course/SelectCourseColor/index.tsx | 45 ++++++++++++ domain/Course/SelectCourseColor/style.ts | 16 ++++ domain/Tag/TagInput/index.tsx | 12 ++- domain/Todo/CreateTodo/index.tsx | 66 +++++++++++------ domain/Todo/SelectCourse/index.tsx | 10 ++- domain/Todo/SelectDayOfWeek/index.tsx | 10 ++- hooks/useCourseOnChange.ts | 12 +++ hooks/useDayOfWeekOnChange.ts | 11 +++ hooks/useGetString.ts | 2 +- hooks/useOnChange.ts | 12 +++ hooks/useTagOnChange.ts | 12 +++ k8s/prod.yaml | 6 +- k8s/qa.yaml | 6 +- libs/course/index.ts | 4 +- libs/todo/index.ts | 4 + next-env.d.ts | 3 + package-lock.json | 2 +- package.json | 2 +- pages/[userId]/index.tsx | 2 +- types/components-type/todo/index.ts | 3 +- 23 files changed, 250 insertions(+), 96 deletions(-) create mode 100644 domain/Course/SelectCourseColor/index.tsx create mode 100644 domain/Course/SelectCourseColor/style.ts create mode 100644 hooks/useCourseOnChange.ts create mode 100644 hooks/useDayOfWeekOnChange.ts create mode 100644 hooks/useOnChange.ts create mode 100644 hooks/useTagOnChange.ts diff --git a/domain/Course/CoursePinList/index.tsx b/domain/Course/CoursePinList/index.tsx index 678a809..f910ce1 100644 --- a/domain/Course/CoursePinList/index.tsx +++ b/domain/Course/CoursePinList/index.tsx @@ -14,7 +14,7 @@ export default function CoursePinList(): JSX.Element { useEffect(() => { (async () => { const res = await getCourses(); - setCourseItems(res.slice(0, 4)); + setCourseItems(res.reverse().slice(0, 4)); })(); return () => setCourseItems([]); }, []); diff --git a/domain/Course/CreateCourse/index.tsx b/domain/Course/CreateCourse/index.tsx index 9d0b643..f9cd9cd 100644 --- a/domain/Course/CreateCourse/index.tsx +++ b/domain/Course/CreateCourse/index.tsx @@ -1,25 +1,34 @@ -import React, { FormEvent, useEffect, useState } from "react"; +import React from "react"; + +import { useRouter } from "next/router"; import * as S from "./style"; -import { getColors } from "../../../libs/colors"; +import useGetString from "../../../hooks/useGetString"; +import useOnChange from "../../../hooks/useOnChange"; +import useTagOnChange from "../../../hooks/useTagOnChange"; -import TagInput from "../../Tag/TagInput"; import Button from "../../../components/Button"; +import SelectCourseColor from "../SelectCourseColor"; +import TagInput from "../../Tag/TagInput"; +import { postNewCourse } from "../../../libs/course"; export default function CreateCourse(): JSX.Element { - const [courseColors, setCourseColors] = useState([]); - - useEffect(() => { - (async () => { - const res = await getColors(); - setCourseColors(res); - })(); - return () => setCourseColors([]); - }, []); - - const handleSubmit = async (event: FormEvent) => { - event.preventDefault(); + const router = useRouter(); + + const [color, setColor] = useGetString(); + const [title, setTitle] = useOnChange(); + const [explanation, setExplanation] = useOnChange(); + const [tags, setTags] = useTagOnChange(); + + const addCourse = async () => { + await postNewCourse({ + title: title, + explanation: explanation, + color: color, + tags: tags, + }); + router.back(); }; return ( @@ -27,33 +36,29 @@ export default function CreateCourse(): JSX.Element { 새로운 코스 추가 -
- - - 코스 색상 선택 - - - {courseColors.map((color, index) => { - return ; - })} - - - 코스 제목 - - - - 설명 - - - - 태그 - - - -