-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
post API Res/Req 추가, 컴포넌트 수정, k8s 수정 (#84)
* 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: 박경은 <[email protected]>
- Loading branch information
Showing
23 changed files
with
250 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,64 @@ | ||
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<string[]>([]); | ||
|
||
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 ( | ||
<> | ||
<S.TitleBox> | ||
<S.Title>새로운 코스 추가</S.Title> | ||
</S.TitleBox> | ||
<form onSubmit={handleSubmit}> | ||
<S.Contents> | ||
<S.SubTitleBox> | ||
<S.SubTitle>코스 색상 선택</S.SubTitle> | ||
</S.SubTitleBox> | ||
<S.RadioColorsBox> | ||
{courseColors.map((color, index) => { | ||
return <S.ColorInput type="radio" color={color} value={color} name="color" key={index} defaultChecked={index === 0 ? true : false} />; | ||
})} | ||
</S.RadioColorsBox> | ||
<S.SubTitleBox> | ||
<S.SubTitle>코스 제목</S.SubTitle> | ||
</S.SubTitleBox> | ||
<S.DefaultInput type="text" placeholder="입력해주세요" name="title" /> | ||
<S.SubTitleBox> | ||
<S.SubTitle>설명</S.SubTitle> | ||
</S.SubTitleBox> | ||
<S.DefaultTextArea placeholder="입력해주세요 (200자)" name="explanation" rows={6} maxLength={200} /> | ||
<S.SubTitleBox> | ||
<S.SubTitle>태그</S.SubTitle> | ||
</S.SubTitleBox> | ||
<TagInput /> | ||
<S.SubmitButtonBox> | ||
<Button type={"submit"} text={"코스 생성"} /> | ||
</S.SubmitButtonBox> | ||
</S.Contents> | ||
</form> | ||
<S.Contents> | ||
<S.SubTitleBox> | ||
<S.SubTitle>코스 색상 선택</S.SubTitle> | ||
</S.SubTitleBox> | ||
<S.RadioColorsBox> | ||
<SelectCourseColor colorOnChange={setColor} /> | ||
</S.RadioColorsBox> | ||
<S.SubTitleBox> | ||
<S.SubTitle>코스 제목</S.SubTitle> | ||
</S.SubTitleBox> | ||
<S.DefaultInput type="text" placeholder="입력해주세요" name="title" onChange={setTitle} /> | ||
<S.SubTitleBox> | ||
<S.SubTitle>설명</S.SubTitle> | ||
</S.SubTitleBox> | ||
<S.DefaultTextArea placeholder="입력해주세요 (200자)" name="explanation" rows={6} maxLength={200} onChange={setExplanation} /> | ||
<S.SubTitleBox> | ||
<S.SubTitle>태그</S.SubTitle> | ||
</S.SubTitleBox> | ||
<TagInput tagsOnChange={setTags} /> | ||
<S.SubmitButtonBox onClick={addCourse}> | ||
<Button type={"submit"} text={"코스 생성"} /> | ||
</S.SubmitButtonBox> | ||
</S.Contents> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
import * as S from "./style"; | ||
|
||
import { getColors } from "../../../libs/colors"; | ||
|
||
type props = { | ||
colorOnChange: (value: string) => void; | ||
}; | ||
|
||
export default function SelectCourseColor({ colorOnChange }: props): JSX.Element { | ||
const [courseColors, setCourseColors] = useState<string[]>([]); | ||
const [currentColor, setCurrentColor] = useState<string>(""); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
const res = await getColors(); | ||
setCourseColors(res); | ||
setCurrentColor(res[0]); | ||
})(); | ||
return () => setCourseColors([]); | ||
}, []); | ||
|
||
useEffect(() => { | ||
colorOnChange(currentColor); | ||
}, [currentColor]); | ||
|
||
return ( | ||
<> | ||
{courseColors.map((color, index) => { | ||
return ( | ||
<S.ColorInput | ||
type="radio" | ||
color={color} | ||
value={color} | ||
name="color" | ||
key={index} | ||
checked={currentColor == color} | ||
onChange={() => setCurrentColor(color)} | ||
/> | ||
); | ||
})} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import styled from "styled-components"; | ||
|
||
const ColorInput = styled.input.attrs({ type: "radio" })<{ color: string }>` | ||
background-color: ${(props) => props.color}; | ||
appearance: none; | ||
border: none; | ||
width: 32px; | ||
height: 32px; | ||
border-radius: 100%; | ||
cursor: pointer; | ||
:checked { | ||
border: 4px solid ${({ theme }) => theme.fontColor.sub2}; | ||
} | ||
`; | ||
|
||
export { ColorInput }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,62 @@ | ||
import React, { FormEvent } from "react"; | ||
import React from "react"; | ||
|
||
import { useRouter } from "next/router"; | ||
|
||
import * as S from "./style"; | ||
|
||
import { postNewTodo } from "../../../libs/todo"; | ||
|
||
import Button from "../../../components/Button"; | ||
import SelectCourse from "../SelectCourse"; | ||
import SelectDayOfWeek from "../SelectDayOfWeek"; | ||
|
||
import useOnChange from "../../../hooks/useOnChange"; | ||
import useCourseOnChange from "../../../hooks/useCourseOnChange"; | ||
|
||
export default function CreateTodo(): JSX.Element { | ||
const handleSubmit = async (event: FormEvent) => { | ||
event.preventDefault(); | ||
const router = useRouter(); | ||
|
||
const [title, setTitle] = useOnChange(); | ||
const [explanation, setExplanation] = useOnChange(); | ||
const [course, setCourse] = useCourseOnChange(); | ||
|
||
const addTodo = async () => { | ||
await postNewTodo({ | ||
courseId: course.id, | ||
title: title, | ||
explanation: explanation, | ||
recurringCycleDate: 1, | ||
repeatedDaysOfTheWeek: [], | ||
}); | ||
router.back(); | ||
}; | ||
|
||
return ( | ||
<> | ||
<S.TitleBox> | ||
<S.Title>새로운 할일 추가</S.Title> | ||
</S.TitleBox> | ||
<form onSubmit={handleSubmit}> | ||
<S.Contents> | ||
<S.SubTitleBox> | ||
<S.SubTitle>할일 제목</S.SubTitle> | ||
</S.SubTitleBox> | ||
<S.DefaultInput type="text" placeholder="입력해주세요" name="title" /> | ||
<S.SubTitleBox> | ||
<S.SubTitle>코스 선택</S.SubTitle> | ||
</S.SubTitleBox> | ||
<SelectCourse /> | ||
<S.SubTitleBox> | ||
<S.SubTitle>옵션</S.SubTitle> | ||
</S.SubTitleBox> | ||
<SelectDayOfWeek /> | ||
<S.SubmitButtonBox> | ||
<Button type={"submit"} text={"할일 생성"} /> | ||
</S.SubmitButtonBox> | ||
</S.Contents> | ||
</form> | ||
<S.Contents> | ||
<S.SubTitleBox> | ||
<S.SubTitle>할일 제목</S.SubTitle> | ||
</S.SubTitleBox> | ||
<S.DefaultInput type="text" placeholder="입력해주세요" name="title" onChange={setTitle} /> | ||
<S.SubTitleBox> | ||
<S.SubTitle>설명</S.SubTitle> | ||
</S.SubTitleBox> | ||
<S.DefaultTextArea placeholder="입력해주세요 (200자)" name="explanation" rows={6} maxLength={200} onChange={setExplanation} /> | ||
<S.SubTitleBox> | ||
<S.SubTitle>코스 선택</S.SubTitle> | ||
</S.SubTitleBox> | ||
<SelectCourse courseOnChange={setCourse} /> | ||
<S.SubTitleBox> | ||
<S.SubTitle>옵션</S.SubTitle> | ||
</S.SubTitleBox> | ||
<SelectDayOfWeek /> | ||
<S.SubmitButtonBox onClick={addTodo}> | ||
<Button type={"submit"} text={"할일 생성"} /> | ||
</S.SubmitButtonBox> | ||
</S.Contents> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { useState } from "react"; | ||
import { CourseItem } from "../types/components-type/course"; | ||
|
||
export default function useCourseOnChange(): [CourseItem, (value: CourseItem) => void] { | ||
const [value, setValue] = useState<CourseItem>(); | ||
|
||
function handleOnChange(value: CourseItem): void { | ||
setValue(value); | ||
} | ||
|
||
return [value, handleOnChange]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useState } from "react"; | ||
|
||
export default function useDayOfWeekOnChange(): [boolean[], (value: boolean[]) => void] { | ||
const [value, setValue] = useState<boolean[]>(); | ||
|
||
function handleOnChange(value: boolean[]): void { | ||
setValue(value); | ||
} | ||
|
||
return [value, handleOnChange]; | ||
} |
Oops, something went wrong.