From 7ab6cd2ef5181adc37547818769e63ba90652680 Mon Sep 17 00:00:00 2001 From: genTe <128919388+wdgWon@users.noreply.github.com> Date: Fri, 8 Mar 2024 11:03:07 +0900 Subject: [PATCH 01/58] =?UTF-8?q?[Feat=20=E2=9C=8F=EF=B8=8F]=20input?= =?UTF-8?q?=EC=9D=98=20=EA=B0=81=EC=A2=85=20=EC=83=81=ED=98=B8=EC=9E=91?= =?UTF-8?q?=EC=9A=A9=EC=9D=84=20=EB=8B=B4=EB=8B=B9=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InputController/InputController.tsx | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/components/InputController/InputController.tsx diff --git a/src/components/InputController/InputController.tsx b/src/components/InputController/InputController.tsx new file mode 100644 index 00000000..5c7075af --- /dev/null +++ b/src/components/InputController/InputController.tsx @@ -0,0 +1,50 @@ +import { ReactNode } from "react" +import { UseFormRegisterReturn } from "react-hook-form" + +import { + Flex, + FormControl, + FormErrorMessage, + FormLabel, + Input, + InputProps, + Spacer, +} from "@chakra-ui/react" + +interface InputControllerProps extends InputProps { + children?: ReactNode + label?: string + registerOptions: UseFormRegisterReturn + isInvalid?: boolean + errorMessage?: string +} + +const InputController = ({ + children, + isInvalid, + label, + registerOptions, + errorMessage, + ...props +}: InputControllerProps) => { + return ( + + + {label} + + {errorMessage} + + + + {children} + + + ) +} + +export default InputController From dabd0b73f2cb55a79ff05bd87b94313c14e7dfbd Mon Sep 17 00:00:00 2001 From: genTe <128919388+wdgWon@users.noreply.github.com> Date: Fri, 8 Mar 2024 11:06:18 +0900 Subject: [PATCH 02/58] =?UTF-8?q?[Refactoring=20=E2=9A=99=EF=B8=8F]=20api?= =?UTF-8?q?=20=EA=B2=BD=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 7d9d9d65..30f6d0f0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -24,7 +24,7 @@ "baseUrl": ".", "paths": { "@components/*": ["src/components/*"], - "@apis/*": ["src/apis/*"], + "@apis/*": ["src/api/*"], "@assets/*": ["src/assets/*"], "@hooks/*": ["src/hooks/*"], "@pages/*": ["src/pages/*"], From f1489ad237401aae5b81831a7ab83574b306a0a8 Mon Sep 17 00:00:00 2001 From: genTe <128919388+wdgWon@users.noreply.github.com> Date: Fri, 8 Mar 2024 11:07:17 +0900 Subject: [PATCH 03/58] =?UTF-8?q?[Refactoring=20=E2=9A=99=EF=B8=8F]=20?= =?UTF-8?q?=EC=9E=AC=EC=82=AC=EC=9A=A9=EC=9D=84=20=EC=9C=84=ED=95=B4=20?= =?UTF-8?q?=EA=B3=B5=ED=86=B5=20=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8?= =?UTF-8?q?=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LoginPage/components => components/BackButton}/BackButton.tsx | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{pages/LoginPage/components => components/BackButton}/BackButton.tsx (100%) diff --git a/src/pages/LoginPage/components/BackButton.tsx b/src/components/BackButton/BackButton.tsx similarity index 100% rename from src/pages/LoginPage/components/BackButton.tsx rename to src/components/BackButton/BackButton.tsx From e40f68b9cbea36f91dcb5890730a50629e6d8394 Mon Sep 17 00:00:00 2001 From: genTe <128919388+wdgWon@users.noreply.github.com> Date: Fri, 8 Mar 2024 11:08:31 +0900 Subject: [PATCH 04/58] =?UTF-8?q?[Refactoring=20=E2=9A=99=EF=B8=8F]=20Inpu?= =?UTF-8?q?tController=20=EC=9E=AC=EC=82=AC=EC=9A=A9=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/LoginPage/LoginPage.tsx | 2 +- .../components/LoginForm/LoginForm.tsx | 41 ++++++++++--------- .../LoginForm/components/LoginFormLabel.tsx | 33 --------------- src/pages/SignUpPage/components/LoginHref.tsx | 27 ++++++++++++ 4 files changed, 49 insertions(+), 54 deletions(-) delete mode 100644 src/pages/LoginPage/components/LoginForm/components/LoginFormLabel.tsx create mode 100644 src/pages/SignUpPage/components/LoginHref.tsx diff --git a/src/pages/LoginPage/LoginPage.tsx b/src/pages/LoginPage/LoginPage.tsx index 1d883247..55619cfa 100644 --- a/src/pages/LoginPage/LoginPage.tsx +++ b/src/pages/LoginPage/LoginPage.tsx @@ -1,8 +1,8 @@ import { Box, Center, Divider, Flex } from "@chakra-ui/react" +import BackButton from "@components/BackButton/BackButton" import LogoLink from "@components/LogoLink/LogoLink" -import BackButton from "./components/BackButton" import CreateAccount from "./components/CreateAccount" import LoginForm from "./components/LoginForm/LoginForm" import SocialLogin from "./components/SocialLogin" diff --git a/src/pages/LoginPage/components/LoginForm/LoginForm.tsx b/src/pages/LoginPage/components/LoginForm/LoginForm.tsx index 5cf63213..c5721eb1 100644 --- a/src/pages/LoginPage/components/LoginForm/LoginForm.tsx +++ b/src/pages/LoginPage/components/LoginForm/LoginForm.tsx @@ -1,9 +1,10 @@ import { SubmitHandler, useForm } from "react-hook-form" -import { Flex, FormControl, Input } from "@chakra-ui/react" +import { Flex } from "@chakra-ui/react" + +import InputController from "@components/InputController/InputController" import LoginButton from "./components/LoginButton" -import LoginFormLabel from "./components/LoginFormLabel" type FormType = { email: string @@ -30,25 +31,25 @@ const LoginForm = () => { alignItems="stretch"> {/* 로그인 입력 양식 */} {/* email */} - - 이메일 - - + {/* paasword */} - - 비밀번호 - - + diff --git a/src/pages/LoginPage/components/LoginForm/components/LoginFormLabel.tsx b/src/pages/LoginPage/components/LoginForm/components/LoginFormLabel.tsx deleted file mode 100644 index c4c9de17..00000000 --- a/src/pages/LoginPage/components/LoginForm/components/LoginFormLabel.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { PropsWithChildren } from "react" -import { FieldError } from "react-hook-form" - -import { - Flex, - FormErrorMessage, - FormLabel, - Spacer, - Text, -} from "@chakra-ui/react" - -interface LoginFormLabelProps extends PropsWithChildren { - error?: FieldError -} - -const LoginFormLabel = ({ children, error }: LoginFormLabelProps) => { - return ( - - - - {children} - - - {error && error.message} - - - ) -} - -export default LoginFormLabel diff --git a/src/pages/SignUpPage/components/LoginHref.tsx b/src/pages/SignUpPage/components/LoginHref.tsx new file mode 100644 index 00000000..cb263188 --- /dev/null +++ b/src/pages/SignUpPage/components/LoginHref.tsx @@ -0,0 +1,27 @@ +import { Link } from "react-router-dom" + +import { Box, Flex, Text } from "@chakra-ui/react" + +const LoginHref = () => { + return ( + + + 회원이신가요? + + + 로그인하기 + + + + + ) +} + +export default LoginHref From f8909d244139b1f6e954bdc6176439fde901c6a8 Mon Sep 17 00:00:00 2001 From: genTe <128919388+wdgWon@users.noreply.github.com> Date: Fri, 8 Mar 2024 11:10:16 +0900 Subject: [PATCH 05/58] =?UTF-8?q?[Feat=20=E2=9C=8F=EF=B8=8F]=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=ED=99=95=EC=9D=B8=20api=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=20=EB=B0=8F=20msw=20=ED=95=B8=EB=93=A4?= =?UTF-8?q?=EB=9F=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/user/postDoubleCheckEmail.ts | 15 +++++++++++++-- src/mocks/handlers.ts | 4 ++++ .../SignUpPage/mocks/postDoubleCheckEmail.mock.ts | 14 ++++++++++++++ .../mocks/postDoubleCheckNickname.mock.ts | 13 +++++++++++++ src/types/domain/apiDomain.d.ts | 4 ++++ 5 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 src/pages/SignUpPage/mocks/postDoubleCheckEmail.mock.ts create mode 100644 src/pages/SignUpPage/mocks/postDoubleCheckNickname.mock.ts diff --git a/src/api/user/postDoubleCheckEmail.ts b/src/api/user/postDoubleCheckEmail.ts index 527488b6..071b947a 100644 --- a/src/api/user/postDoubleCheckEmail.ts +++ b/src/api/user/postDoubleCheckEmail.ts @@ -1,4 +1,7 @@ -import { postDoubleCheckEmailPayload } from "api-models" +import { + postDoubleCheckEmailPayload, + postDoubleCheckEmailResponseType, +} from "api-models" import { AxiosRequestConfig } from "axios" import { ENDPOINTS } from "@constants/endPoints" @@ -9,5 +12,13 @@ export const postDoubleCheckEmail = async ( body: postDoubleCheckEmailPayload, config: AxiosRequestConfig = {}, ) => { - await baseInstance.post(ENDPOINTS.EMAIL_DOUBLE_CHECK, body, { ...config }) + const { data } = await baseInstance.post( + ENDPOINTS.EMAIL_DOUBLE_CHECK, + body, + { + ...config, + }, + ) + + return data } diff --git a/src/mocks/handlers.ts b/src/mocks/handlers.ts index 0ae77820..22456d71 100644 --- a/src/mocks/handlers.ts +++ b/src/mocks/handlers.ts @@ -5,6 +5,8 @@ import { searchHandlers } from "@components/Search/mocks" import allProjectHandlers from "@pages/HomePage/mocks" import { projectsHandlers, userInfoHandlers } from "@pages/ProfilePage/mocks" import { projectDetailHandlers } from "@pages/ProjectDetailPage/mocks" +import { postDoubleCheckEmail } from "@pages/SignUpPage/mocks/postDoubleCheckEmail.mock" +import { postDoubleCheckNickname } from "@pages/SignUpPage/mocks/postDoubleCheckNickname.mock" import { postEmailLogin } from "./auth/postEmailLogin.mock" import { postEmailRefresh } from "./auth/postEmailRefresh.mock" @@ -34,6 +36,8 @@ export const handlers = [ ...allProjectHandlers, postEmailRefresh, postEmailLogin, + postDoubleCheckEmail, + postDoubleCheckNickname, ...userInfoHandlers, ...projectsHandlers, ] diff --git a/src/pages/SignUpPage/mocks/postDoubleCheckEmail.mock.ts b/src/pages/SignUpPage/mocks/postDoubleCheckEmail.mock.ts new file mode 100644 index 00000000..33171fe0 --- /dev/null +++ b/src/pages/SignUpPage/mocks/postDoubleCheckEmail.mock.ts @@ -0,0 +1,14 @@ +import { postDoubleCheckEmailPayload } from "api-models" +import { rest } from "msw" + +import { ENDPOINTS } from "@constants/endPoints" + +export const postDoubleCheckEmail = rest.post( + ENDPOINTS.EMAIL_DOUBLE_CHECK, + async (req, res, ctx) => { + const payload: postDoubleCheckEmailPayload = await req.json() + const isDuplicated = payload.email === "admin@admin.com" + + return res(ctx.delay(1000), ctx.status(200), ctx.json({ isDuplicated })) + }, +) diff --git a/src/pages/SignUpPage/mocks/postDoubleCheckNickname.mock.ts b/src/pages/SignUpPage/mocks/postDoubleCheckNickname.mock.ts new file mode 100644 index 00000000..0cc32188 --- /dev/null +++ b/src/pages/SignUpPage/mocks/postDoubleCheckNickname.mock.ts @@ -0,0 +1,13 @@ +import { postDoubleCheckNicknamePayload } from "api-models" +import { rest } from "msw" + +import { ENDPOINTS } from "@constants/endPoints" + +export const postDoubleCheckNickname = rest.post( + ENDPOINTS.NICKNAME_DOUBLE_CHECK, + async (req, res, ctx) => { + const payload: postDoubleCheckNicknamePayload = await req.json() + const isDuplicated = payload.nickname === "sidepeek" + return res(ctx.status(isDuplicated ? 400 : 200)) + }, +) diff --git a/src/types/domain/apiDomain.d.ts b/src/types/domain/apiDomain.d.ts index 9f339b23..81557cd9 100644 --- a/src/types/domain/apiDomain.d.ts +++ b/src/types/domain/apiDomain.d.ts @@ -207,6 +207,10 @@ declare module "api-models" { email: string } + export type postDoubleCheckEmailResponseType = { + isDuplicated: boolean + } + export type postDoubleCheckNicknamePayload = { nickname: string } From 0ea84d1e206e015a3dc42f98dd960083ff98a472 Mon Sep 17 00:00:00 2001 From: genTe <128919388+wdgWon@users.noreply.github.com> Date: Sat, 9 Mar 2024 17:05:53 +0900 Subject: [PATCH 06/58] =?UTF-8?q?[Refactoring=20=E2=9A=99=EF=B8=8F]=20name?= =?UTF-8?q?=20=EC=86=8D=EC=84=B1=EC=9C=BC=EB=A1=9C=20validation=EC=9D=84?= =?UTF-8?q?=20=EC=88=98=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InputController/InputController.tsx | 22 +++++++++++-------- .../InputController/types/formKeys.ts | 1 + 2 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 src/components/InputController/types/formKeys.ts diff --git a/src/components/InputController/InputController.tsx b/src/components/InputController/InputController.tsx index 5c7075af..37f3b8d2 100644 --- a/src/components/InputController/InputController.tsx +++ b/src/components/InputController/InputController.tsx @@ -1,5 +1,5 @@ import { ReactNode } from "react" -import { UseFormRegisterReturn } from "react-hook-form" +import { RegisterOptions, useFormContext } from "react-hook-form" import { Flex, @@ -11,34 +11,38 @@ import { Spacer, } from "@chakra-ui/react" +import { FormKeys } from "./types/formKeys" + interface InputControllerProps extends InputProps { + name: FormKeys children?: ReactNode label?: string - registerOptions: UseFormRegisterReturn - isInvalid?: boolean - errorMessage?: string + registerOptions: RegisterOptions } const InputController = ({ children, - isInvalid, + name, label, registerOptions, - errorMessage, ...props }: InputControllerProps) => { + const { + register, + formState: { errors }, + } = useFormContext() return ( - + {label} - {errorMessage} + {errors[name]?.message as string} {children} diff --git a/src/components/InputController/types/formKeys.ts b/src/components/InputController/types/formKeys.ts new file mode 100644 index 00000000..245616ff --- /dev/null +++ b/src/components/InputController/types/formKeys.ts @@ -0,0 +1 @@ +export type FormKeys = "email" | "password" | "nickname" | "confirmNickname" From a8091a8fc2ec489761fcbbb81ab1e72f7013fd60 Mon Sep 17 00:00:00 2001 From: Whoknow77 Date: Wed, 13 Mar 2024 17:49:58 +0900 Subject: [PATCH 07/58] =?UTF-8?q?[Refactoring=20=E2=9A=99=EF=B8=8F]=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=EB=B2=84=ED=8A=BC=EA=B3=BC=20form=20?= =?UTF-8?q?=EC=A2=85=EC=86=8D=EC=84=B1=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Comments/CommentsItem/CommentsItem.tsx | 5 +- .../CommentsItem/components/CommentTitle.tsx | 48 +++++++++++++------ 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/pages/ProjectDetailPage/components/Comments/CommentsItem/CommentsItem.tsx b/src/pages/ProjectDetailPage/components/Comments/CommentsItem/CommentsItem.tsx index c0bef87f..12d3bada 100644 --- a/src/pages/ProjectDetailPage/components/Comments/CommentsItem/CommentsItem.tsx +++ b/src/pages/ProjectDetailPage/components/Comments/CommentsItem/CommentsItem.tsx @@ -52,10 +52,7 @@ const CommentsItem = ({ comment, register }: CommentsItemProps) => { w="100%" gap="1rem" align="flex-start"> - + { +const CommentTitle = ({ comment }: CommentTitleProps) => { + const { isEditing, editTargetCommentId } = useCommentContext() return ( - - {user ? user.nickname : "익명"} - - - {dateToTimeago(createdAt)} - + + + {comment.user ? comment.user.nickname : "익명"} + + + {dateToTimeago(comment.createdAt)} + + + + {comment.isOwner ? ( + editTargetCommentId === comment.id && isEditing ? ( + + ) : ( + + ) + ) : null} + ) } From 9969b6c6c87d84574bdb247239cfbb66b35fd12e Mon Sep 17 00:00:00 2001 From: Whoknow77 Date: Wed, 13 Mar 2024 17:51:14 +0900 Subject: [PATCH 08/58] =?UTF-8?q?[Refactoring=20=E2=9A=99=EF=B8=8F]=20trou?= =?UTF-8?q?bleshooting=20null=EA=B0=92=EC=97=90=20=EB=8C=80=ED=95=9C=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CommentsItem/components/CommentsEditFormText.tsx | 12 ------------ .../Content/Explanation/ExplanationItem.tsx | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/pages/ProjectDetailPage/components/Comments/CommentsItem/components/CommentsEditFormText.tsx b/src/pages/ProjectDetailPage/components/Comments/CommentsItem/components/CommentsEditFormText.tsx index 27fbfb6b..dba33433 100644 --- a/src/pages/ProjectDetailPage/components/Comments/CommentsItem/components/CommentsEditFormText.tsx +++ b/src/pages/ProjectDetailPage/components/Comments/CommentsItem/components/CommentsEditFormText.tsx @@ -6,9 +6,6 @@ import { Comment } from "api-models" import { useCommentContext } from "@pages/ProjectDetailPage/store/CommentContext" -import BeforeEditingButton from "./BeforeEditingButton" -import OnEditingButton from "./OnEditingButton" - interface CommentsEditFormTextProps { comment: Comment register: UseFormRegisterReturn @@ -48,15 +45,6 @@ const CommentsEditFormText = ({ {comment.content} )} - - {comment.isOwner ? ( - editTargetCommentId === comment.id && isEditing ? ( - - ) : ( - - ) - ) : null} - diff --git a/src/pages/ProjectDetailPage/components/Content/Explanation/ExplanationItem.tsx b/src/pages/ProjectDetailPage/components/Content/Explanation/ExplanationItem.tsx index 83c34f9b..91caa66b 100644 --- a/src/pages/ProjectDetailPage/components/Content/Explanation/ExplanationItem.tsx +++ b/src/pages/ProjectDetailPage/components/Content/Explanation/ExplanationItem.tsx @@ -13,7 +13,7 @@ interface ExplanationItemProps { } const ExplanationItem = ({ content }: ExplanationItemProps) => { - const processedText = content.replace(/\\n/g, "\n") + const processedText = content?.replace(/\\n/g, "\n") return ( Date: Wed, 13 Mar 2024 18:37:25 +0900 Subject: [PATCH 09/58] =?UTF-8?q?[Design=20=F0=9F=8E=A8]=20=EB=8C=93?= =?UTF-8?q?=EA=B8=80=20Time=20media=20query=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Comments/CommentsForm/CommentsForm.tsx | 10 +++++----- .../Comments/CommentsItem/CommentsItem.tsx | 18 +++++++++++++++++- .../CommentsItem/components/CommentTitle.tsx | 16 ++++++++++------ .../CommentsItem/components/ReplyComment.tsx | 2 +- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/pages/ProjectDetailPage/components/Comments/CommentsForm/CommentsForm.tsx b/src/pages/ProjectDetailPage/components/Comments/CommentsForm/CommentsForm.tsx index 0bd42567..2c69d1d3 100644 --- a/src/pages/ProjectDetailPage/components/Comments/CommentsForm/CommentsForm.tsx +++ b/src/pages/ProjectDetailPage/components/Comments/CommentsForm/CommentsForm.tsx @@ -43,14 +43,14 @@ const CommentsForm = ({