From 03eb809a763e5ae97e0a8c281de33d14ac4c495d Mon Sep 17 00:00:00 2001 From: Whoknow77 Date: Sun, 17 Mar 2024 14:58:09 +0900 Subject: [PATCH 01/16] =?UTF-8?q?[Design=20=F0=9F=8E=A8]=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EC=A0=9D=ED=8A=B8=20=EC=83=81=EC=84=B8=EC=A0=95?= =?UTF-8?q?=EB=B4=87=20=EC=84=B9=EC=85=98=20=ED=8F=B0=ED=8A=B8=20=ED=81=AC?= =?UTF-8?q?=EA=B8=B0=20=EC=A6=9D=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Content/TechStacks/TechStacks.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ProjectDetailPage/components/Content/TechStacks/TechStacks.tsx b/src/pages/ProjectDetailPage/components/Content/TechStacks/TechStacks.tsx index fd8d365f..74854574 100644 --- a/src/pages/ProjectDetailPage/components/Content/TechStacks/TechStacks.tsx +++ b/src/pages/ProjectDetailPage/components/Content/TechStacks/TechStacks.tsx @@ -17,7 +17,7 @@ const TechStacks = ({ techStacks }: TechStacksProps) => { direction="column" gap="3rem"> 기술 스택 From 43cba3ad77cec20d2a73661ae5d7975d6aa7909b Mon Sep 17 00:00:00 2001 From: Whoknow77 Date: Sun, 17 Mar 2024 15:05:24 +0900 Subject: [PATCH 02/16] =?UTF-8?q?[Refactoring=20=E2=9A=99=EF=B8=8F]=20over?= =?UTF-8?q?imageUrl=EC=9D=B4=20=EC=97=86=EC=9D=84=EB=95=8C=20=EA=B8=B0?= =?UTF-8?q?=EB=B3=B8=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EB=B3=B4=EC=97=AC?= =?UTF-8?q?=EC=A3=BC=EB=8F=84=EB=A1=9D=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Summary/SummaryContent/SummaryRight.tsx | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/pages/ProjectDetailPage/components/Summary/SummaryContent/SummaryRight.tsx b/src/pages/ProjectDetailPage/components/Summary/SummaryContent/SummaryRight.tsx index 820cc499..fbeeed64 100644 --- a/src/pages/ProjectDetailPage/components/Summary/SummaryContent/SummaryRight.tsx +++ b/src/pages/ProjectDetailPage/components/Summary/SummaryContent/SummaryRight.tsx @@ -35,20 +35,29 @@ const SummaryRight = ({ overviewImageUrl }: SummaryRightProps) => { - (swiperRef.current = swiper)}> - {overviewImageUrl?.map((overviewImg) => ( - - - - ))} - - {isLargerThan1200 && ( + {overviewImageUrl.length > 0 ? ( + (swiperRef.current = swiper)}> + {overviewImageUrl?.map((overviewImg) => ( + + + + ))} + + ) : ( + + )} + + {isLargerThan1200 && overviewImageUrl.length > 0 && ( <> Date: Sun, 17 Mar 2024 15:59:19 +0900 Subject: [PATCH 03/16] =?UTF-8?q?[Design=20=F0=9F=8E=A8]=20Summary=20?= =?UTF-8?q?=EB=B0=98=EC=9D=91=ED=98=95=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/ProjectDetailPage/components/Summary/Summary.tsx | 2 +- .../components/Summary/SummaryContent/SummaryLeft.tsx | 1 + .../components/Summary/SummaryContent/SummaryOverview.tsx | 7 ++++++- .../components/Summary/SummaryContent/SummaryRight.tsx | 2 +- .../components/Summary/SummaryTitle/SummaryTitle.tsx | 6 +++--- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/pages/ProjectDetailPage/components/Summary/Summary.tsx b/src/pages/ProjectDetailPage/components/Summary/Summary.tsx index 908b850c..6122c371 100644 --- a/src/pages/ProjectDetailPage/components/Summary/Summary.tsx +++ b/src/pages/ProjectDetailPage/components/Summary/Summary.tsx @@ -24,7 +24,7 @@ const Summary = ({ projectDetailInfo }: getProjectDetailResponseType) => { maxW="128rem" flexDirection="column" m="0 auto" - p="2rem"> + p="2rem 4rem"> { diff --git a/src/pages/ProjectDetailPage/components/Summary/SummaryContent/SummaryOverview.tsx b/src/pages/ProjectDetailPage/components/Summary/SummaryContent/SummaryOverview.tsx index 8b4c2923..f7014d39 100644 --- a/src/pages/ProjectDetailPage/components/Summary/SummaryContent/SummaryOverview.tsx +++ b/src/pages/ProjectDetailPage/components/Summary/SummaryContent/SummaryOverview.tsx @@ -4,11 +4,16 @@ interface SummaryOverviewProps { overview: string } const SummaryOverview = ({ overview }: SummaryOverviewProps) => { + const [isLargerThan768] = useMediaQuery(["(min-width: 768px)"]) const [isLargerThan1200] = useMediaQuery(["(min-width: 1200px)"]) return ( - {overview} + + {overview} + ) } diff --git a/src/pages/ProjectDetailPage/components/Summary/SummaryContent/SummaryRight.tsx b/src/pages/ProjectDetailPage/components/Summary/SummaryContent/SummaryRight.tsx index fbeeed64..9baa788e 100644 --- a/src/pages/ProjectDetailPage/components/Summary/SummaryContent/SummaryRight.tsx +++ b/src/pages/ProjectDetailPage/components/Summary/SummaryContent/SummaryRight.tsx @@ -33,7 +33,7 @@ const SummaryRight = ({ overviewImageUrl }: SummaryRightProps) => { return ( {overviewImageUrl.length > 0 ? ( { - const [isLargerThan1200] = useMediaQuery(["(min-width: 1200px)"]) + const [isLargerThan768] = useMediaQuery(["(min-width: 768px)"]) return ( {name} {subName} From fdff068d18bbdc4ef2641158ff53d367a98e420e Mon Sep 17 00:00:00 2001 From: Whoknow77 Date: Sun, 17 Mar 2024 16:30:00 +0900 Subject: [PATCH 04/16] =?UTF-8?q?[Feat=20=E2=9C=8F=EF=B8=8F]=20=EB=8C=93?= =?UTF-8?q?=EA=B8=80=EC=9D=B4=20=EB=B9=84=EC=96=B4=EC=9E=88=EC=9D=84?= =?UTF-8?q?=EB=95=8C=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Comments/CommentsList/CommentsList.tsx | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/pages/ProjectDetailPage/components/Comments/CommentsList/CommentsList.tsx b/src/pages/ProjectDetailPage/components/Comments/CommentsList/CommentsList.tsx index 81eb3d59..3d267538 100644 --- a/src/pages/ProjectDetailPage/components/Comments/CommentsList/CommentsList.tsx +++ b/src/pages/ProjectDetailPage/components/Comments/CommentsList/CommentsList.tsx @@ -1,4 +1,4 @@ -import { Stack } from "@chakra-ui/react" +import { Center, Stack, Text } from "@chakra-ui/react" import { Comment } from "api-models" import { useCommentContext } from "@pages/ProjectDetailPage/store/CommentContext" @@ -20,17 +20,27 @@ const CommentsList = ({ comments }: CommentsListProps) => { w="100%" gap="4rem" p="2rem"> - {comments.map((comment) => { - return ( - - ) - })} + {comments.length > 0 ? ( + comments.map((comment) => { + return ( + + ) + }) + ) : ( +
+ + 댓글을 남겨보세요 + +
+ )} ) } From 8ca72c75537ea32615a1c24e5ece2fa011dd79a9 Mon Sep 17 00:00:00 2001 From: Whoknow77 Date: Sun, 17 Mar 2024 16:34:23 +0900 Subject: [PATCH 05/16] =?UTF-8?q?[Refactoring=20=E2=9A=99=EF=B8=8F]=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5/=ED=8A=B8=EB=9F=AC=EB=B8=94=20=EC=8A=88?= =?UTF-8?q?=ED=8C=85=20=EC=97=86=EC=9D=84=EB=95=8C=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Content/Explanation/ExplanationItem.tsx | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/pages/ProjectDetailPage/components/Content/Explanation/ExplanationItem.tsx b/src/pages/ProjectDetailPage/components/Content/Explanation/ExplanationItem.tsx index 8f2435b4..4d9a93c8 100644 --- a/src/pages/ProjectDetailPage/components/Content/Explanation/ExplanationItem.tsx +++ b/src/pages/ProjectDetailPage/components/Content/Explanation/ExplanationItem.tsx @@ -1,7 +1,7 @@ import { Box } from "@chakra-ui/react" import MDEditor from "@uiw/react-md-editor" -const ViewStyleParams = { +const ViewOptions = { whiteSpace: "pre-wrap", padding: "2rem", lineHeight: "1.5", @@ -9,18 +9,32 @@ const ViewStyleParams = { fontSize: "1rem", } +const ViewNotContentOptions = { + fontSize: "2rem", + color: "#7a7a7a", +} + interface ExplanationItemProps { content: string } +const notContentText = "내용이 존재하지 않습니다." + const ExplanationItem = ({ content }: ExplanationItemProps) => { const processedText = content?.replace(/\\n/g, "\n") return ( - + {processedText ? ( + + ) : ( + + )} ) } From 5b78b42c497240aa38beb1dfaa3a49ef0640eec3 Mon Sep 17 00:00:00 2001 From: Whoknow77 Date: Sun, 17 Mar 2024 16:37:40 +0900 Subject: [PATCH 06/16] =?UTF-8?q?[Feat=20=E2=9C=8F=EF=B8=8F]=20=EA=B8=B0?= =?UTF-8?q?=EC=88=A0=EC=8A=A4=ED=83=9D=EC=9D=B4=20=EC=97=86=EC=9D=84?= =?UTF-8?q?=EB=95=8C=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Content/TechStacks/TechStacks.tsx | 78 ++++++++++--------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/src/pages/ProjectDetailPage/components/Content/TechStacks/TechStacks.tsx b/src/pages/ProjectDetailPage/components/Content/TechStacks/TechStacks.tsx index 74854574..92b8df06 100644 --- a/src/pages/ProjectDetailPage/components/Content/TechStacks/TechStacks.tsx +++ b/src/pages/ProjectDetailPage/components/Content/TechStacks/TechStacks.tsx @@ -21,41 +21,49 @@ const TechStacks = ({ techStacks }: TechStacksProps) => { fontFamily="SCDream_Bold"> 기술 스택 - - {groupedByCategory.map(([category, stacks]) => ( - - - {category} - - - {stacks.map((stack) => ( - - } - label={stack.skill.name} - key={stack.skill.id} - fontSize="lg" - /> - ))} - - - ))} - + {techStacks.length > 0 ? ( + + {groupedByCategory.map(([category, stacks]) => ( + + + {category} + + + {stacks.map((stack) => ( + + } + label={stack.skill.name} + key={stack.skill.id} + fontSize="lg" + /> + ))} + + + ))} + + ) : ( + + 등록된 기술 스택이 존재하지 않습니다. + + )}
) } From a8c447f6c55cb5b8d1ca478b707fba3bc1148227 Mon Sep 17 00:00:00 2001 From: Whoknow77 Date: Sun, 17 Mar 2024 16:50:48 +0900 Subject: [PATCH 07/16] =?UTF-8?q?[Design=20=F0=9F=8E=A8]=20=EC=9A=94?= =?UTF-8?q?=EC=86=8C=EA=B0=80=20=EC=97=86=EC=9D=84=EB=95=8C=EB=8A=94=20?= =?UTF-8?q?=EA=B0=80=EB=A1=9C=EB=A1=9C=20=EC=97=86=EB=8B=A4=EA=B3=A0=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Content/Date/Date.tsx | 14 +- .../Content/TechStacks/TechStacks.tsx | 23 ++- src/pages/ProjectDetailPage/mocks/mockData.ts | 134 +++++++++--------- 3 files changed, 88 insertions(+), 83 deletions(-) diff --git a/src/pages/ProjectDetailPage/components/Content/Date/Date.tsx b/src/pages/ProjectDetailPage/components/Content/Date/Date.tsx index 15f7b6d8..cc41d019 100644 --- a/src/pages/ProjectDetailPage/components/Content/Date/Date.tsx +++ b/src/pages/ProjectDetailPage/components/Content/Date/Date.tsx @@ -9,15 +9,21 @@ interface DateProps { const Date = ({ startDate, endDate }: DateProps) => { return ( - + 프로젝트 기간 - {changeDateForm(startDate, endDate)} + {startDate && endDate ? ( + {changeDateForm(startDate, endDate)} + ) : ( + + 등록된 프로젝트 기간이 존재하지 않습니다. + + )} ) } diff --git a/src/pages/ProjectDetailPage/components/Content/TechStacks/TechStacks.tsx b/src/pages/ProjectDetailPage/components/Content/TechStacks/TechStacks.tsx index 92b8df06..9dd8996e 100644 --- a/src/pages/ProjectDetailPage/components/Content/TechStacks/TechStacks.tsx +++ b/src/pages/ProjectDetailPage/components/Content/TechStacks/TechStacks.tsx @@ -1,4 +1,4 @@ -import { Flex, HStack, Image, Text, useMediaQuery } from "@chakra-ui/react" +import { HStack, Image, Stack, Text, useMediaQuery } from "@chakra-ui/react" import { TechStack } from "api-models" import CommonTag from "@components/Tag/components/CommonTag" @@ -13,23 +13,22 @@ const TechStacks = ({ techStacks }: TechStacksProps) => { const [isLargerThan768] = useMediaQuery(["(min-width: 768px)"]) return ( - + 0 ? "flex-start" : "center"} + direction={techStacks.length ? "column" : "row"}> 기술 스택 {techStacks.length > 0 ? ( - + {groupedByCategory.map(([category, stacks]) => ( - + spacing="2rem"> { /> ))} -
+ ))} - + ) : ( { 등록된 기술 스택이 존재하지 않습니다. )} - + ) } diff --git a/src/pages/ProjectDetailPage/mocks/mockData.ts b/src/pages/ProjectDetailPage/mocks/mockData.ts index be1c6e01..fd569ebb 100644 --- a/src/pages/ProjectDetailPage/mocks/mockData.ts +++ b/src/pages/ProjectDetailPage/mocks/mockData.ts @@ -282,75 +282,75 @@ export const DUMMY_PROJECT_DETAIL = { }, }, ], - startDate: "2024-01", - endDate: "2024-03", + startDate: "", + endDate: "", ownerId: 1, members: [ - { - id: 1, - role: "PO", - userSummary: { - id: 1, - nickname: "의진", - profileImageUrl: - "https://i.namu.wiki/i/N6_MwKL2hvhgbTGJR_rGAxby09eVQJdnx33clAyVNGcbZI83kXZSNg6OoGQeqTQ0iNWO-CZFZheouxGdEkCLvw.webp", - }, - }, - { - id: 2, - role: "프론트", - userSummary: { - id: 2, - nickname: "동건", - profileImageUrl: - "https://user-images.githubusercontent.com/donggun.png", - }, - }, - { - id: 3, - role: "오락부짱", - userSummary: { - id: null, - nickname: "민호", - profileImageUrl: null, - }, - }, - { - id: 4, - role: "PO", - userSummary: { - id: null, - nickname: "육개", - profileImageUrl: null, - }, - }, - { - id: 5, - role: "PO", - userSummary: { - id: null, - nickname: "육개데", - profileImageUrl: null, - }, - }, - { - id: 6, - role: "프론트", - userSummary: { - id: null, - nickname: "훈오오", - profileImageUrl: null, - }, - }, - { - id: 7, - role: "오락부짱", - userSummary: { - id: null, - nickname: "짱짱맨", - profileImageUrl: null, - }, - }, + // { + // id: 1, + // role: "PO", + // userSummary: { + // id: 1, + // nickname: "의진", + // profileImageUrl: + // "https://i.namu.wiki/i/N6_MwKL2hvhgbTGJR_rGAxby09eVQJdnx33clAyVNGcbZI83kXZSNg6OoGQeqTQ0iNWO-CZFZheouxGdEkCLvw.webp", + // }, + // }, + // { + // id: 2, + // role: "프론트", + // userSummary: { + // id: 2, + // nickname: "동건", + // profileImageUrl: + // "https://user-images.githubusercontent.com/donggun.png", + // }, + // }, + // { + // id: 3, + // role: "오락부짱", + // userSummary: { + // id: null, + // nickname: "민호", + // profileImageUrl: null, + // }, + // }, + // { + // id: 4, + // role: "PO", + // userSummary: { + // id: null, + // nickname: "육개", + // profileImageUrl: null, + // }, + // }, + // { + // id: 5, + // role: "PO", + // userSummary: { + // id: null, + // nickname: "육개데", + // profileImageUrl: null, + // }, + // }, + // { + // id: 6, + // role: "프론트", + // userSummary: { + // id: null, + // nickname: "훈오오", + // profileImageUrl: null, + // }, + // }, + // { + // id: 7, + // role: "오락부짱", + // userSummary: { + // id: null, + // nickname: "짱짱맨", + // profileImageUrl: null, + // }, + // }, ], description: "## 이미지가 잘오나?\\n\\n![image](https://velog.velcdn.com/images/gnsdh8616/post/c30b08c8-4221-44b5-bb68-3a66d1917de6/image.gif)\\n\\n## gg", From 3b819323c0879e0fc0e0be68c34254d06b8d62bc Mon Sep 17 00:00:00 2001 From: Whoknow77 Date: Sun, 17 Mar 2024 16:57:28 +0900 Subject: [PATCH 08/16] =?UTF-8?q?[Feat=20=E2=9C=8F=EF=B8=8F]=20=EB=A9=A4?= =?UTF-8?q?=EB=B2=84=EA=B0=80=20=EC=97=86=EC=9D=84=EB=95=8C=20=EB=AC=B8?= =?UTF-8?q?=EA=B5=AC=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Content/Content.tsx | 2 +- .../Content/MemberInfo/MemberInfo.tsx | 38 +++-- src/pages/ProjectDetailPage/mocks/mockData.ts | 134 +++++++++--------- 3 files changed, 91 insertions(+), 83 deletions(-) diff --git a/src/pages/ProjectDetailPage/components/Content/Content.tsx b/src/pages/ProjectDetailPage/components/Content/Content.tsx index 0f618eac..022e2d53 100644 --- a/src/pages/ProjectDetailPage/components/Content/Content.tsx +++ b/src/pages/ProjectDetailPage/components/Content/Content.tsx @@ -13,7 +13,7 @@ const Content = ({ projectDetailInfo }: getProjectDetailResponseType) => { } - spacing={10} + spacing={30} w="100%" margin="0 auto"> diff --git a/src/pages/ProjectDetailPage/components/Content/MemberInfo/MemberInfo.tsx b/src/pages/ProjectDetailPage/components/Content/MemberInfo/MemberInfo.tsx index a75f03e1..287874c5 100644 --- a/src/pages/ProjectDetailPage/components/Content/MemberInfo/MemberInfo.tsx +++ b/src/pages/ProjectDetailPage/components/Content/MemberInfo/MemberInfo.tsx @@ -1,4 +1,4 @@ -import { Flex, Text } from "@chakra-ui/react" +import { HStack, Stack, Text } from "@chakra-ui/react" import { Member } from "api-models" import membersCategory from "@pages/ProjectDetailPage/utils/membersCategory" @@ -12,26 +12,34 @@ interface MemberInfoProps { const MemberInfo = ({ members }: MemberInfoProps) => { const groupedByCategory = membersCategory(members) return ( - + 0 ? "column" : "row"} + spacing="2rem"> 팀원 - - {groupedByCategory.map(([category, members]) => ( - - ))} - - + {groupedByCategory.length > 0 ? ( + groupedByCategory.map(([category, members]) => ( + + )) + ) : ( + + 등록된 멤버가 존재하지 않습니다. + + )} + + ) } diff --git a/src/pages/ProjectDetailPage/mocks/mockData.ts b/src/pages/ProjectDetailPage/mocks/mockData.ts index fd569ebb..be1c6e01 100644 --- a/src/pages/ProjectDetailPage/mocks/mockData.ts +++ b/src/pages/ProjectDetailPage/mocks/mockData.ts @@ -282,75 +282,75 @@ export const DUMMY_PROJECT_DETAIL = { }, }, ], - startDate: "", - endDate: "", + startDate: "2024-01", + endDate: "2024-03", ownerId: 1, members: [ - // { - // id: 1, - // role: "PO", - // userSummary: { - // id: 1, - // nickname: "의진", - // profileImageUrl: - // "https://i.namu.wiki/i/N6_MwKL2hvhgbTGJR_rGAxby09eVQJdnx33clAyVNGcbZI83kXZSNg6OoGQeqTQ0iNWO-CZFZheouxGdEkCLvw.webp", - // }, - // }, - // { - // id: 2, - // role: "프론트", - // userSummary: { - // id: 2, - // nickname: "동건", - // profileImageUrl: - // "https://user-images.githubusercontent.com/donggun.png", - // }, - // }, - // { - // id: 3, - // role: "오락부짱", - // userSummary: { - // id: null, - // nickname: "민호", - // profileImageUrl: null, - // }, - // }, - // { - // id: 4, - // role: "PO", - // userSummary: { - // id: null, - // nickname: "육개", - // profileImageUrl: null, - // }, - // }, - // { - // id: 5, - // role: "PO", - // userSummary: { - // id: null, - // nickname: "육개데", - // profileImageUrl: null, - // }, - // }, - // { - // id: 6, - // role: "프론트", - // userSummary: { - // id: null, - // nickname: "훈오오", - // profileImageUrl: null, - // }, - // }, - // { - // id: 7, - // role: "오락부짱", - // userSummary: { - // id: null, - // nickname: "짱짱맨", - // profileImageUrl: null, - // }, - // }, + { + id: 1, + role: "PO", + userSummary: { + id: 1, + nickname: "의진", + profileImageUrl: + "https://i.namu.wiki/i/N6_MwKL2hvhgbTGJR_rGAxby09eVQJdnx33clAyVNGcbZI83kXZSNg6OoGQeqTQ0iNWO-CZFZheouxGdEkCLvw.webp", + }, + }, + { + id: 2, + role: "프론트", + userSummary: { + id: 2, + nickname: "동건", + profileImageUrl: + "https://user-images.githubusercontent.com/donggun.png", + }, + }, + { + id: 3, + role: "오락부짱", + userSummary: { + id: null, + nickname: "민호", + profileImageUrl: null, + }, + }, + { + id: 4, + role: "PO", + userSummary: { + id: null, + nickname: "육개", + profileImageUrl: null, + }, + }, + { + id: 5, + role: "PO", + userSummary: { + id: null, + nickname: "육개데", + profileImageUrl: null, + }, + }, + { + id: 6, + role: "프론트", + userSummary: { + id: null, + nickname: "훈오오", + profileImageUrl: null, + }, + }, + { + id: 7, + role: "오락부짱", + userSummary: { + id: null, + nickname: "짱짱맨", + profileImageUrl: null, + }, + }, ], description: "## 이미지가 잘오나?\\n\\n![image](https://velog.velcdn.com/images/gnsdh8616/post/c30b08c8-4221-44b5-bb68-3a66d1917de6/image.gif)\\n\\n## gg", From b9b9c06d3db5e430202170862bafc1e4223ffc1d Mon Sep 17 00:00:00 2001 From: Whoknow77 Date: Sun, 17 Mar 2024 21:39:37 +0900 Subject: [PATCH 09/16] =?UTF-8?q?[Feat=20=E2=9C=8F=EF=B8=8F]=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EC=A0=9D=ED=8A=B8=20=EC=A0=95=EB=B3=B4=EB=A5=BC=20?= =?UTF-8?q?=EB=B0=9B=EC=95=84=EC=98=AC=EB=95=8C=EC=9D=98=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=EC=B2=98=EB=A6=AC=20=EA=B5=AC=ED=98=84(=ED=86=A0?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8))?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectDetailPage/ProjectDetailPage.tsx | 6 ++- .../constants/toastMessage.ts | 17 +++++++++ .../mutations/useDeleteCommentMutation.ts | 11 ++++++ .../hooks/queries/useProjectDetailQuery.ts | 37 ++++++++++++++++++- 4 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 src/pages/ProjectDetailPage/constants/toastMessage.ts diff --git a/src/pages/ProjectDetailPage/ProjectDetailPage.tsx b/src/pages/ProjectDetailPage/ProjectDetailPage.tsx index f2b3f7d9..cea198cc 100644 --- a/src/pages/ProjectDetailPage/ProjectDetailPage.tsx +++ b/src/pages/ProjectDetailPage/ProjectDetailPage.tsx @@ -1,4 +1,6 @@ -import { Box, Center, Flex, useMediaQuery } from "@chakra-ui/react" +import { Box, Flex, useMediaQuery } from "@chakra-ui/react" + +import FullScreenSpinner from "@components/LoadingComponents/FullScreenSpinner" import Comments from "./components/Comments/Comments" import { withProjectId } from "./components/Comments/Hoc/withProjectId" @@ -12,7 +14,7 @@ const ProjectDetailPage = ({ projectId }: ProjectIdProps) => { const [isLargerThan768] = useMediaQuery(["(min-width: 768px)"]) if (!projectDetailInfo) { - return
Loading...
+ return } return ( diff --git a/src/pages/ProjectDetailPage/constants/toastMessage.ts b/src/pages/ProjectDetailPage/constants/toastMessage.ts new file mode 100644 index 00000000..2ea15623 --- /dev/null +++ b/src/pages/ProjectDetailPage/constants/toastMessage.ts @@ -0,0 +1,17 @@ +export const GET_PROJECT_MESSAGES = { + ERROR: { + SERVER: "서버 오류", // 500 + FAIL: "프로젝트 정보를 불러 오는데 실패했습니다", // 404 + UNCAUGHT: "일시적인 오류로 프로젝트 정보를 불러올 수 없습니다.", + }, +} + +export const COMMENT_MESSAGES = { + SUCCESS: "댓글이 등록되었습니다", + ERROR: { + 500: "서버 오류", //500 + 400: "댓글 생성 정보가 유효하지 않습니다.", // 400 + 403: "비회원은 댓글을 작성할 수 없습니다.", // 403 + 404: "존재하지 않는 댓글입니다.", // 404 + }, +} diff --git a/src/pages/ProjectDetailPage/hooks/mutations/useDeleteCommentMutation.ts b/src/pages/ProjectDetailPage/hooks/mutations/useDeleteCommentMutation.ts index d0cc5791..11d4a01d 100644 --- a/src/pages/ProjectDetailPage/hooks/mutations/useDeleteCommentMutation.ts +++ b/src/pages/ProjectDetailPage/hooks/mutations/useDeleteCommentMutation.ts @@ -1,13 +1,19 @@ +import { useToast } from "@chakra-ui/react" + import { useMutation, useQueryClient } from "@tanstack/react-query" import { deleteComment } from "@apis/comment/deleteComment" +import { COMMENT_MESSAGES } from "@pages/ProjectDetailPage/constants/toastMessage" +import { toastOptions } from "@pages/SignUpPage/constants/toastOptions" + import { QUERY_KEY_GET_PROJECT_DETAIL } from "../queries/useProjectDetailQuery" const QUERY_KEY_DELETE_COMMENT = "DELETE_COMMENT_234893204832" export const useDeleteCommentMutation = () => { const queryClient = useQueryClient() + const toast = useToast(toastOptions) const deleteCommentMutation = useMutation({ mutationKey: [QUERY_KEY_DELETE_COMMENT], @@ -16,6 +22,11 @@ export const useDeleteCommentMutation = () => { queryClient.invalidateQueries({ queryKey: [QUERY_KEY_GET_PROJECT_DETAIL], }) + + toast({ + status: "success", + title: COMMENT_MESSAGES.SUCCESS, + }) }, }) diff --git a/src/pages/ProjectDetailPage/hooks/queries/useProjectDetailQuery.ts b/src/pages/ProjectDetailPage/hooks/queries/useProjectDetailQuery.ts index edef6bbd..13818fe0 100644 --- a/src/pages/ProjectDetailPage/hooks/queries/useProjectDetailQuery.ts +++ b/src/pages/ProjectDetailPage/hooks/queries/useProjectDetailQuery.ts @@ -1,12 +1,45 @@ -import { useSuspenseQuery } from "@tanstack/react-query" +import { useEffect } from "react" + +import { useToast } from "@chakra-ui/react" +import { isAxiosError } from "axios" + +import { useQuery } from "@tanstack/react-query" import { getProjectDetail } from "@apis/project/getProjectDetail" +import { GET_PROJECT_MESSAGES } from "@pages/ProjectDetailPage/constants/toastMessage" +import { toastOptions } from "@pages/SignUpPage/constants/toastOptions" + export const QUERY_KEY_GET_PROJECT_DETAIL = "GET_PROJECT_DETAIL_1389471984712" export const useProjectDetailQuery = (projectId: number) => { - const { data: projectDetailInfo } = useSuspenseQuery({ + const toast = useToast(toastOptions) + const { data: projectDetailInfo, error } = useQuery({ queryKey: [QUERY_KEY_GET_PROJECT_DETAIL, projectId], queryFn: () => getProjectDetail({ projectId }), }) + + useEffect(() => { + if (isAxiosError(error)) { + let message = "" + switch (error.response?.status) { + case 500: { + message = GET_PROJECT_MESSAGES.ERROR.SERVER + break + } + case 404: { + message = GET_PROJECT_MESSAGES.ERROR.FAIL + break + } + default: { + message = GET_PROJECT_MESSAGES.ERROR.UNCAUGHT + } + } + toast({ + status: "error", + title: message, + }) + } + }, [error, toast]) + return { projectDetailInfo } } From 052e03e13c9135100eb6d87066a6140613e9c9d7 Mon Sep 17 00:00:00 2001 From: Whoknow77 Date: Mon, 18 Mar 2024 00:56:58 +0900 Subject: [PATCH 10/16] =?UTF-8?q?[Feat=20=E2=9C=8F=EF=B8=8F]=20=EB=8C=93?= =?UTF-8?q?=EA=B8=80=20=EC=9A=94=EC=B2=AD=EC=97=90=20=EB=8C=80=ED=95=9C=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=EC=B2=98=EB=A6=AC=20=ED=86=A0=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=A9=94=EC=8B=9C=EC=A7=80=EB=A1=9C=20=EC=B6=9C?= =?UTF-8?q?=EB=A0=A5=ED=95=98=EB=8F=84=EB=A1=9D=20=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Comments/CommentsForm/CommentsForm.tsx | 2 +- .../constants/toastMessage.ts | 29 ++++++++--- .../mutations/useDeleteCommentMutation.ts | 44 ++++++++++++++--- .../hooks/mutations/useEditCommentMutation.ts | 44 ++++++++++++++++- .../hooks/mutations/usePostCommentMutation.ts | 48 ++++++++++++++++++- .../store/CommentContext.tsx | 4 +- 6 files changed, 153 insertions(+), 18 deletions(-) diff --git a/src/pages/ProjectDetailPage/components/Comments/CommentsForm/CommentsForm.tsx b/src/pages/ProjectDetailPage/components/Comments/CommentsForm/CommentsForm.tsx index 2c69d1d3..9d7f9922 100644 --- a/src/pages/ProjectDetailPage/components/Comments/CommentsForm/CommentsForm.tsx +++ b/src/pages/ProjectDetailPage/components/Comments/CommentsForm/CommentsForm.tsx @@ -31,7 +31,7 @@ const CommentsForm = ({ parentId: parentId ? parentId : null, content: text.content, } - sendCommentMutation.mutate(commentRequestValue) + sendCommentMutation(commentRequestValue) reset() } diff --git a/src/pages/ProjectDetailPage/constants/toastMessage.ts b/src/pages/ProjectDetailPage/constants/toastMessage.ts index 2ea15623..f7dd90b3 100644 --- a/src/pages/ProjectDetailPage/constants/toastMessage.ts +++ b/src/pages/ProjectDetailPage/constants/toastMessage.ts @@ -1,17 +1,32 @@ +export const COMMON_MESSAGES = { + SERVER: "서버 오류", +} + export const GET_PROJECT_MESSAGES = { ERROR: { - SERVER: "서버 오류", // 500 FAIL: "프로젝트 정보를 불러 오는데 실패했습니다", // 404 - UNCAUGHT: "일시적인 오류로 프로젝트 정보를 불러올 수 없습니다.", + UNCAUGHT: "일시적인 오류가 발생하였습니다.", }, } export const COMMENT_MESSAGES = { - SUCCESS: "댓글이 등록되었습니다", + SUCCESS: { + POST: "댓글이 등록되었습니다", + DELETE: "댓글이 삭제되었습니다", + EDIT: "댓글이 수정되었습니다", + }, + ERROR: { + UNVALIDATE: "요청 정보가 유효하지 않습니다.", // 400 + UNAUTHORIZED: "해당 요청에 대한 권한이 없습니다.", // 403 + UNDEFINED: "존재하지 않는 댓글입니다.", // 404 + UNCAUGHT: "일시적인 오류가 발생하였습니다.", + }, +} + +export const LIKE_MESSAGES = { ERROR: { - 500: "서버 오류", //500 - 400: "댓글 생성 정보가 유효하지 않습니다.", // 400 - 403: "비회원은 댓글을 작성할 수 없습니다.", // 403 - 404: "존재하지 않는 댓글입니다.", // 404 + FAIL: "좋아요 요청에 실패했습니다.", // 400, 404 + DUPLICATE: "이미 좋아요를 눌렀습니다.", // 409 + UNCAUGHT: "일시적인 오류가 발생하였습니다.", }, } diff --git a/src/pages/ProjectDetailPage/hooks/mutations/useDeleteCommentMutation.ts b/src/pages/ProjectDetailPage/hooks/mutations/useDeleteCommentMutation.ts index 11d4a01d..0cdb8103 100644 --- a/src/pages/ProjectDetailPage/hooks/mutations/useDeleteCommentMutation.ts +++ b/src/pages/ProjectDetailPage/hooks/mutations/useDeleteCommentMutation.ts @@ -1,10 +1,16 @@ +import { useEffect } from "react" + import { useToast } from "@chakra-ui/react" +import { isAxiosError } from "axios" import { useMutation, useQueryClient } from "@tanstack/react-query" import { deleteComment } from "@apis/comment/deleteComment" -import { COMMENT_MESSAGES } from "@pages/ProjectDetailPage/constants/toastMessage" +import { + COMMENT_MESSAGES, + COMMON_MESSAGES, +} from "@pages/ProjectDetailPage/constants/toastMessage" import { toastOptions } from "@pages/SignUpPage/constants/toastOptions" import { QUERY_KEY_GET_PROJECT_DETAIL } from "../queries/useProjectDetailQuery" @@ -15,20 +21,46 @@ export const useDeleteCommentMutation = () => { const queryClient = useQueryClient() const toast = useToast(toastOptions) - const deleteCommentMutation = useMutation({ + const { mutate: deleteCommentMutation, error } = useMutation({ mutationKey: [QUERY_KEY_DELETE_COMMENT], mutationFn: (commentId: number) => deleteComment({ commentId }), onSuccess: () => { queryClient.invalidateQueries({ queryKey: [QUERY_KEY_GET_PROJECT_DETAIL], }) + }, + }) + useEffect(() => { + if (isAxiosError(error)) { + let message = "" + switch (error.response?.status) { + case 500: { + message = COMMON_MESSAGES.SERVER + break + } + case 400: { + message = COMMENT_MESSAGES.ERROR.UNVALIDATE + break + } + case 403: { + message = COMMENT_MESSAGES.ERROR.UNAUTHORIZED + break + } + case 404: { + message = COMMENT_MESSAGES.ERROR.UNDEFINED + break + } + default: { + message = COMMENT_MESSAGES.ERROR.UNCAUGHT + } + } toast({ - status: "success", - title: COMMENT_MESSAGES.SUCCESS, + status: "error", + title: message, }) - }, - }) + } + }, [error, toast]) return { deleteCommentMutation } } diff --git a/src/pages/ProjectDetailPage/hooks/mutations/useEditCommentMutation.ts b/src/pages/ProjectDetailPage/hooks/mutations/useEditCommentMutation.ts index 4a2b8c7d..45826e09 100644 --- a/src/pages/ProjectDetailPage/hooks/mutations/useEditCommentMutation.ts +++ b/src/pages/ProjectDetailPage/hooks/mutations/useEditCommentMutation.ts @@ -1,17 +1,28 @@ +import { useEffect } from "react" + +import { useToast } from "@chakra-ui/react" import { editCommentPayload } from "api-models" +import { isAxiosError } from "axios" import { useMutation, useQueryClient } from "@tanstack/react-query" import { editComment } from "@apis/comment/editComment" +import { + COMMENT_MESSAGES, + COMMON_MESSAGES, +} from "@pages/ProjectDetailPage/constants/toastMessage" +import { toastOptions } from "@pages/SignUpPage/constants/toastOptions" + import { QUERY_KEY_GET_PROJECT_DETAIL } from "../queries/useProjectDetailQuery" const QUERY_KEY_EDIT_COMMENT = "EDIT_COMMENT_234893204832" export const useEditCommentMutation = () => { const queryClient = useQueryClient() + const toast = useToast(toastOptions) - const editCommentMutation = useMutation({ + const { mutate: editCommentMutation, error } = useMutation({ mutationKey: [QUERY_KEY_EDIT_COMMENT], mutationFn: (data: editCommentPayload) => editComment(data), onSuccess: () => { @@ -21,5 +32,36 @@ export const useEditCommentMutation = () => { }, }) + useEffect(() => { + if (isAxiosError(error)) { + let message = "" + switch (error.response?.status) { + case 500: { + message = COMMON_MESSAGES.SERVER + break + } + case 400: { + message = COMMENT_MESSAGES.ERROR.UNVALIDATE + break + } + case 403: { + message = COMMENT_MESSAGES.ERROR.UNAUTHORIZED + break + } + case 404: { + message = COMMENT_MESSAGES.ERROR.UNDEFINED + break + } + default: { + message = COMMENT_MESSAGES.ERROR.UNCAUGHT + } + } + toast({ + status: "error", + title: message, + }) + } + }, [error, toast]) + return { editCommentMutation } } diff --git a/src/pages/ProjectDetailPage/hooks/mutations/usePostCommentMutation.ts b/src/pages/ProjectDetailPage/hooks/mutations/usePostCommentMutation.ts index 0d72323e..9cabb2cf 100644 --- a/src/pages/ProjectDetailPage/hooks/mutations/usePostCommentMutation.ts +++ b/src/pages/ProjectDetailPage/hooks/mutations/usePostCommentMutation.ts @@ -1,25 +1,71 @@ +import { useEffect } from "react" + +import { useToast } from "@chakra-ui/react" import { postCommentPayload } from "api-models" +import { isAxiosError } from "axios" import { useMutation, useQueryClient } from "@tanstack/react-query" import { postComment } from "@apis/comment/postComment" +import { + COMMENT_MESSAGES, + COMMON_MESSAGES, +} from "@pages/ProjectDetailPage/constants/toastMessage" +import { toastOptions } from "@pages/SignUpPage/constants/toastOptions" + import { QUERY_KEY_GET_PROJECT_DETAIL } from "../queries/useProjectDetailQuery" const QUERY_KEY_POST_COMMENT = "POST_COMMENT_2384902384" export const usePostCommentMutation = () => { const queryClient = useQueryClient() + const toast = useToast(toastOptions) - const sendCommentMutation = useMutation({ + const { mutate: sendCommentMutation, error } = useMutation({ mutationKey: [QUERY_KEY_POST_COMMENT], mutationFn: (data: postCommentPayload) => postComment(data), onSuccess: () => { queryClient.invalidateQueries({ queryKey: [QUERY_KEY_GET_PROJECT_DETAIL], }) + toast({ + status: "success", + title: COMMENT_MESSAGES.SUCCESS.POST, + }) }, }) + useEffect(() => { + if (isAxiosError(error)) { + let message = "" + switch (error.response?.status) { + case 500: { + message = COMMON_MESSAGES.SERVER + break + } + case 400: { + message = COMMENT_MESSAGES.ERROR.UNVALIDATE + break + } + case 403: { + message = COMMENT_MESSAGES.ERROR.UNAUTHORIZED + break + } + case 404: { + message = COMMENT_MESSAGES.ERROR.UNDEFINED + break + } + default: { + message = COMMENT_MESSAGES.ERROR.UNCAUGHT + } + } + toast({ + status: "error", + title: message, + }) + } + }, [error, toast]) + return { sendCommentMutation } } diff --git a/src/pages/ProjectDetailPage/store/CommentContext.tsx b/src/pages/ProjectDetailPage/store/CommentContext.tsx index 5b8c00e6..c7339853 100644 --- a/src/pages/ProjectDetailPage/store/CommentContext.tsx +++ b/src/pages/ProjectDetailPage/store/CommentContext.tsx @@ -66,13 +66,13 @@ export const CommentProvider = ({ children }: CommentProviderProps) => { } const handleDelete = (commentId: number) => { - deleteCommentMutation.mutate(commentId) + deleteCommentMutation(commentId) handleOffEdit() handleOffReply() } const onSubmitEdit: SubmitHandler = (commentValues) => { - editCommentMutation.mutate(commentValues) + editCommentMutation(commentValues) handleOffEdit() handleOffReply() } From 0413ad59e02b006e3ddef7d160cf94849e41c95d Mon Sep 17 00:00:00 2001 From: Whoknow77 Date: Mon, 18 Mar 2024 01:06:22 +0900 Subject: [PATCH 11/16] =?UTF-8?q?[Feat=20=E2=9C=8F=EF=B8=8F]=20=EC=A2=8B?= =?UTF-8?q?=EC=95=84=EC=9A=94=20=EA=B4=80=EB=A0=A8=20=EC=9A=94=EC=B2=AD?= =?UTF-8?q?=EC=97=90=20=EB=8C=80=ED=95=9C=20=EC=97=90=EB=9F=AC=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constants/toastMessage.ts | 2 +- .../hooks/mutations/useDeleteLikeMutation.ts | 37 ++++++++++++++++- .../hooks/mutations/usePostLikeMutation.ts | 41 ++++++++++++++++++- 3 files changed, 77 insertions(+), 3 deletions(-) diff --git a/src/pages/ProjectDetailPage/constants/toastMessage.ts b/src/pages/ProjectDetailPage/constants/toastMessage.ts index f7dd90b3..4e294628 100644 --- a/src/pages/ProjectDetailPage/constants/toastMessage.ts +++ b/src/pages/ProjectDetailPage/constants/toastMessage.ts @@ -25,7 +25,7 @@ export const COMMENT_MESSAGES = { export const LIKE_MESSAGES = { ERROR: { - FAIL: "좋아요 요청에 실패했습니다.", // 400, 404 + UNVALIDATE: "좋아요 요청에 실패했습니다.", // 400, 404 DUPLICATE: "이미 좋아요를 눌렀습니다.", // 409 UNCAUGHT: "일시적인 오류가 발생하였습니다.", }, diff --git a/src/pages/ProjectDetailPage/hooks/mutations/useDeleteLikeMutation.ts b/src/pages/ProjectDetailPage/hooks/mutations/useDeleteLikeMutation.ts index 981065b0..0e5ecd5e 100644 --- a/src/pages/ProjectDetailPage/hooks/mutations/useDeleteLikeMutation.ts +++ b/src/pages/ProjectDetailPage/hooks/mutations/useDeleteLikeMutation.ts @@ -1,17 +1,28 @@ +import { useEffect } from "react" + +import { useToast } from "@chakra-ui/react" import { deleteLikePayload } from "api-models" +import { isAxiosError } from "axios" import { useMutation, useQueryClient } from "@tanstack/react-query" import { deleteLike } from "@apis/like/deleteLike" +import { + COMMON_MESSAGES, + LIKE_MESSAGES, +} from "@pages/ProjectDetailPage/constants/toastMessage" +import { toastOptions } from "@pages/SignUpPage/constants/toastOptions" + import { QUERY_KEY_GET_PROJECT_DETAIL } from "../queries/useProjectDetailQuery" const QUERY_KEY_POST_LIKE = "DELETE_LIKE_1328940382182" export const useDeleteLikeMutation = () => { const queryClient = useQueryClient() + const toast = useToast(toastOptions) - const deleteLikeMutation = useMutation({ + const { mutate: deleteLikeMutation, error } = useMutation({ mutationKey: [QUERY_KEY_POST_LIKE], mutationFn: (data: deleteLikePayload) => deleteLike(data), onSuccess: () => { @@ -20,5 +31,29 @@ export const useDeleteLikeMutation = () => { }) }, }) + + useEffect(() => { + if (isAxiosError(error)) { + let message = "" + switch (error.response?.status) { + case 500: { + message = COMMON_MESSAGES.SERVER + break + } + case 400: + case 404: { + message = LIKE_MESSAGES.ERROR.UNVALIDATE + break + } + default: { + message = LIKE_MESSAGES.ERROR.UNCAUGHT + } + } + toast({ + status: "error", + title: message, + }) + } + }, [error, toast]) return { deleteLikeMutation } } diff --git a/src/pages/ProjectDetailPage/hooks/mutations/usePostLikeMutation.ts b/src/pages/ProjectDetailPage/hooks/mutations/usePostLikeMutation.ts index cb59ed53..29b3c028 100644 --- a/src/pages/ProjectDetailPage/hooks/mutations/usePostLikeMutation.ts +++ b/src/pages/ProjectDetailPage/hooks/mutations/usePostLikeMutation.ts @@ -1,17 +1,28 @@ +import { useEffect } from "react" + +import { useToast } from "@chakra-ui/react" import { postLikePayload } from "api-models" +import { isAxiosError } from "axios" import { useMutation, useQueryClient } from "@tanstack/react-query" import { postLike } from "@apis/like/postLike" +import { + COMMON_MESSAGES, + LIKE_MESSAGES, +} from "@pages/ProjectDetailPage/constants/toastMessage" +import { toastOptions } from "@pages/SignUpPage/constants/toastOptions" + import { QUERY_KEY_GET_PROJECT_DETAIL } from "../queries/useProjectDetailQuery" const QUERY_KEY_POST_LIKE = "POST_LIKE_234893204832" export const usePostLikeMutation = () => { const queryClient = useQueryClient() + const toast = useToast(toastOptions) - const postLikeMutation = useMutation({ + const { mutate: postLikeMutation, error } = useMutation({ mutationKey: [QUERY_KEY_POST_LIKE], mutationFn: (data: postLikePayload) => postLike(data), onSuccess: () => { @@ -21,5 +32,33 @@ export const usePostLikeMutation = () => { }, }) + useEffect(() => { + if (isAxiosError(error)) { + let message = "" + switch (error.response?.status) { + case 500: { + message = COMMON_MESSAGES.SERVER + break + } + case 400: + case 404: { + message = LIKE_MESSAGES.ERROR.UNVALIDATE + break + } + case 409: { + message = LIKE_MESSAGES.ERROR.DUPLICATE + break + } + default: { + message = LIKE_MESSAGES.ERROR.UNCAUGHT + } + } + toast({ + status: "error", + title: message, + }) + } + }, [error, toast]) + return { postLikeMutation } } From e4c6d3d06f3ff8c1a23843471fee917aae94a3e9 Mon Sep 17 00:00:00 2001 From: Whoknow77 Date: Mon, 18 Mar 2024 01:08:00 +0900 Subject: [PATCH 12/16] =?UTF-8?q?[Refactoring=20=E2=9A=99=EF=B8=8F]=20?= =?UTF-8?q?=EC=A2=8B=EC=95=84=EC=9A=94=20mutation=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Summary/SummaryTop/SummaryTopIcon.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/ProjectDetailPage/components/Summary/SummaryTop/SummaryTopIcon.tsx b/src/pages/ProjectDetailPage/components/Summary/SummaryTop/SummaryTopIcon.tsx index 3edcac84..4d43e232 100644 --- a/src/pages/ProjectDetailPage/components/Summary/SummaryTop/SummaryTopIcon.tsx +++ b/src/pages/ProjectDetailPage/components/Summary/SummaryTop/SummaryTopIcon.tsx @@ -35,8 +35,8 @@ const SummaryTopIcon = ({ {isLike ? ( { - postLikeMutation.mutate({ projectId: Number(projectId) }) - deleteLikeMutation.mutate({ likeId: 12 }) + postLikeMutation({ projectId: Number(projectId) }) + deleteLikeMutation({ likeId: 12 }) }} {...props} /> From 4b4adbb0fa222d0c902d71b868f1dc1e111bb270 Mon Sep 17 00:00:00 2001 From: Whoknow77 Date: Mon, 18 Mar 2024 10:14:04 +0900 Subject: [PATCH 13/16] =?UTF-8?q?[Fix=20=F0=9F=AA=9B]=20mutate=EC=98=A4?= =?UTF-8?q?=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 --- .../components/Summary/SummaryTop/SummaryTop.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/ProjectDetailPage/components/Summary/SummaryTop/SummaryTop.tsx b/src/pages/ProjectDetailPage/components/Summary/SummaryTop/SummaryTop.tsx index 5656f022..388fd4ac 100644 --- a/src/pages/ProjectDetailPage/components/Summary/SummaryTop/SummaryTop.tsx +++ b/src/pages/ProjectDetailPage/components/Summary/SummaryTop/SummaryTop.tsx @@ -60,9 +60,9 @@ const SummaryTop = ({ fontSize={isLargerThan1200 ? "2.7rem" : "2rem"} onClick={(likeId: number | null) => { if (likeId) { - deleteLikeMutation.mutate({ likeId }) + deleteLikeMutation({ likeId }) } else { - postLikeMutation.mutate({ projectId: Number(projectId) }) + postLikeMutation({ projectId: Number(projectId) }) } }} /> From cf6175b8969bf46e28ee412a07e1456e372f1ec1 Mon Sep 17 00:00:00 2001 From: Whoknow77 Date: Mon, 18 Mar 2024 10:50:04 +0900 Subject: [PATCH 14/16] =?UTF-8?q?[Refactoring=20=E2=9A=99=EF=B8=8F]=20?= =?UTF-8?q?=EB=8C=93=EA=B8=80=20=EC=9E=91=EC=84=B1=20shift+enter=20/=20ent?= =?UTF-8?q?er=20=EA=B5=AC=EB=B6=84=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/constants/endPoints.ts | 2 +- .../Comments/CommentsForm/CommentsForm.tsx | 11 ----------- .../CommentsItem/components/CommentsEditFormText.tsx | 12 ------------ 3 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/constants/endPoints.ts b/src/constants/endPoints.ts index fba81501..7f7e8e82 100644 --- a/src/constants/endPoints.ts +++ b/src/constants/endPoints.ts @@ -5,7 +5,7 @@ export const ENDPOINTS = { EMAIL_LOGIN: `${VARIABLE_URL}/auth/login`, EMAIL_REFRESH: `${VARIABLE_URL}/auth/reissue`, EMAIL_AUTH: `${VARIABLE_URL}/auth/me`, - EMAIL_SIGNUP: `${VARIABLE_URL}/users/signup`, + EMAIL_SIGNUP: `${VARIABLE_URL}/users`, GET_USER_NICKNAME: `${VARIABLE_URL}/users?keyword=`, GET_USER_PROFILE: (userId: number) => `${VARIABLE_URL}/users/${userId}`, PUT_USER_PROFILE: (userId: number) => `${VARIABLE_URL}/users/${userId}`, diff --git a/src/pages/ProjectDetailPage/components/Comments/CommentsForm/CommentsForm.tsx b/src/pages/ProjectDetailPage/components/Comments/CommentsForm/CommentsForm.tsx index c1a4b0f1..e35e45fa 100644 --- a/src/pages/ProjectDetailPage/components/Comments/CommentsForm/CommentsForm.tsx +++ b/src/pages/ProjectDetailPage/components/Comments/CommentsForm/CommentsForm.tsx @@ -45,16 +45,6 @@ const CommentsForm = ({ [parentId, projectId, reset, user, sendCommentMutation], ) - const handleKeyDown = useCallback( - (e: React.KeyboardEvent) => { - if (e.key === "Enter" && !e.shiftKey && handleSubmit) { - e.preventDefault() - handleSubmit(onSubmit)() - } - }, - [handleSubmit, onSubmit], - ) - return (
@@ -76,7 +66,6 @@ const CommentsForm = ({ _hover={{ boxShadow: "none", borderColor: "grey.400" }} _focus={{ boxShadow: "none", borderColor: "grey.400" }} {...register("content", { required: true })} - onKeyDown={handleKeyDown} />