Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature/#121/ProjectDetail/error] 댓글/좋아요 요청에 대한 에러처리 / 엣지 케이스 처리 / 반응형 수정 #132

Merged
merged 18 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
03eb809
[Design 🎨] 프로젝트 상세정봇 섹션 폰트 크기 증가
Whoknow77 Mar 17, 2024
43cba3a
[Refactoring ⚙️] overimageUrl이 없을때 기본 이미지 보여주도록 설정
Whoknow77 Mar 17, 2024
a31dec4
[Design 🎨] Summary 반응형 수정
Whoknow77 Mar 17, 2024
fdff068
[Feat ✏️] 댓글이 비어있을때 처리
Whoknow77 Mar 17, 2024
8ca72c7
[Refactoring ⚙️] 기능/트러블 슈팅 없을때 처리
Whoknow77 Mar 17, 2024
5b78b42
[Feat ✏️] 기술스택이 없을때 처리
Whoknow77 Mar 17, 2024
a8c447f
[Design 🎨] 요소가 없을때는 가로로 없다고 처리
Whoknow77 Mar 17, 2024
3b81932
[Feat ✏️] 멤버가 없을때 문구 처리
Whoknow77 Mar 17, 2024
b9b9c06
[Feat ✏️] 프로젝트 정보를 받아올때의 에러처리 구현(토스트))
Whoknow77 Mar 17, 2024
052e03e
[Feat ✏️] 댓글 요청에 대한 에러처리 토스트 메시지로 출력하도록 하는 기능 추가
Whoknow77 Mar 17, 2024
0413ad5
[Feat ✏️] 좋아요 관련 요청에 대한 에러처리 추가
Whoknow77 Mar 17, 2024
e4c6d3d
[Refactoring ⚙️] 좋아요 mutation 오류 수정
Whoknow77 Mar 17, 2024
da77f24
WIP: 41b281e [Refactor ⚙️] 콘솔 제거
Whoknow77 Mar 18, 2024
4b4adbb
[Fix 🪛] mutate오류 수정
Whoknow77 Mar 18, 2024
b328fb4
Merge branch 'dev' of https://github.com/side-peek/sidepeek_frontend …
Whoknow77 Mar 18, 2024
cf6175b
[Refactoring ⚙️] 댓글 작성 shift+enter / enter 구분 삭제
Whoknow77 Mar 18, 2024
87ee1a6
[Feat ✏️] 익명 기능 추가
Whoknow77 Mar 18, 2024
5177fdb
[Refactoring ⚙️] toast 메시지 오류 수정
Whoknow77 Mar 18, 2024
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 src/constants/endPoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down
6 changes: 4 additions & 2 deletions src/pages/ProjectDetailPage/ProjectDetailPage.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -12,7 +14,7 @@ const ProjectDetailPage = ({ projectId }: ProjectIdProps) => {
const [isLargerThan768] = useMediaQuery(["(min-width: 768px)"])

if (!projectDetailInfo) {
return <Center>Loading...</Center>
return <FullScreenSpinner />
}

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
// TODO: 익명 처리
import { useCallback } from "react"
import { useCallback, useState } from "react"
import { SubmitHandler, useForm } from "react-hook-form"
import ResizeTextarea from "react-textarea-autosize"

import { Box, Button, Flex, FormControl, Textarea } from "@chakra-ui/react"
import {
Box,
Button,
Checkbox,
Flex,
FormControl,
Textarea,
} from "@chakra-ui/react"
import { Stack } from "@chakra-ui/react"
import { useUserInfoData } from "@services/caches/useUserInfoData"

import { usePostCommentMutation } from "@pages/ProjectDetailPage/hooks/mutations/usePostCommentMutation"
Expand All @@ -24,6 +32,8 @@ const CommentsForm = ({
const { register, reset, handleSubmit } = useForm<CommentFormValues>()

const { sendCommentMutation } = usePostCommentMutation()
const [isAnonymous, setIsAnonymous] = useState(false)

const user = useUserInfoData()

const onSubmit: SubmitHandler<CommentFormValues> = useCallback(
Expand All @@ -35,49 +45,65 @@ const CommentsForm = ({
const commentRequestValue = {
ownerId: user.id,
projectId: Number(projectId),
isAnonymous: false,
isAnonymous: isAnonymous,
parentId: parentId ? parentId : null,
content: text.content,
}
sendCommentMutation.mutate(commentRequestValue)
sendCommentMutation(commentRequestValue)
reset()
},
[parentId, projectId, reset, user, sendCommentMutation],
[parentId, projectId, reset, user, sendCommentMutation, isAnonymous],
)

const handleKeyDown = useCallback(
(e: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (e.key === "Enter" && !e.shiftKey && handleSubmit) {
e.preventDefault()
handleSubmit(onSubmit)()
}
},
[handleSubmit, onSubmit],
)
const handleAnonymous = () => {
setIsAnonymous(!isAnonymous)
}

return (
<Box w="100%">
<form onSubmit={handleSubmit(onSubmit)}>
<FormControl>
<Flex w="100%">
<Textarea
size="xs"
rows={1}
minH="1rem"
maxH="10rem"
borderTopLeftRadius="0.9rem"
borderBottomRadius={isReplyComment ? "0.9rem" : 0}
fontSize="lg"
p={isReplyComment ? "1rem" : "2rem"}
as={ResizeTextarea}
placeholder={isReplyComment ? "" : "댓글을 입력하세요"}
isRequired={false}
resize="none"
_hover={{ boxShadow: "none", borderColor: "grey.400" }}
_focus={{ boxShadow: "none", borderColor: "grey.400" }}
{...register("content", { required: true })}
onKeyDown={handleKeyDown}
/>
<Flex
w="100%"
position="relative">
<Box
w="100%"
border="1px solid #ECECEC"
borderTopLeftRadius="0.9rem"
borderBottomRadius={isReplyComment ? "0.9rem" : 0}>
<Textarea
w="93%"
size="xs"
rows={1}
minH="1rem"
maxH="10rem"
fontSize="lg"
p={isReplyComment ? "1rem" : "2rem"}
as={ResizeTextarea}
placeholder={isReplyComment ? "" : "댓글을 입력하세요"}
isRequired={false}
resize="none"
border="none"
_hover={{ boxShadow: "none", borderColor: "grey.400" }}
_focus={{ boxShadow: "none", borderColor: "grey.400" }}
{...register("content", { required: true })}
/>
</Box>
<Stack
position="absolute"
right="1.5rem"
top="30%"
direction="row">
<Checkbox
isChecked={isAnonymous}
size="lg"
onChange={handleAnonymous}
colorScheme="red">
익명
</Checkbox>
</Stack>
</Flex>

<Button
p="0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useCallback } from "react"
import { UseFormRegisterReturn } from "react-hook-form"
import ResizeTextarea from "react-textarea-autosize"

Expand All @@ -19,16 +18,6 @@ const CommentsEditFormText = ({
const { handleSubmit, onSubmitEdit, editTargetCommentId, isEditing } =
useCommentContext()

const handleKeyDown = useCallback(
(e: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (e.key === "Enter" && !e.shiftKey && handleSubmit) {
e.preventDefault()
handleSubmit(onSubmitEdit)()
}
},
[handleSubmit, onSubmitEdit],
)

if (!handleSubmit) {
return
}
Expand All @@ -48,7 +37,6 @@ const CommentsEditFormText = ({
as={ResizeTextarea}
isRequired={false}
resize="none"
onKeyDown={handleKeyDown}
{...register}
/>
) : (
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -20,17 +20,27 @@ const CommentsList = ({ comments }: CommentsListProps) => {
w="100%"
gap="4rem"
p="2rem">
{comments.map((comment) => {
return (
<CommentsItem
register={register("content", { required: true })}
key={comment.id}
{...{
comment,
}}
/>
)
})}
{comments.length > 0 ? (
comments.map((comment) => {
return (
<CommentsItem
register={register("content", { required: true })}
key={comment.id}
{...{
comment,
}}
/>
)
})
) : (
<Center>
<Text
fontSize="2xl"
color="grey.500">
댓글을 남겨보세요
</Text>
</Center>
)}
</Stack>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ProjectDetailPage/components/Content/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Content = ({ projectDetailInfo }: getProjectDetailResponseType) => {
<VStack
alignItems="flex-start"
divider={<StackDivider borderColor="grey.300" />}
spacing={10}
spacing={30}
w="100%"
margin="0 auto">
<TechStacks techStacks={techStacks} />
Expand Down
14 changes: 10 additions & 4 deletions src/pages/ProjectDetailPage/components/Content/Date/Date.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ interface DateProps {

const Date = ({ startDate, endDate }: DateProps) => {
return (
<HStack
spacing="6rem"
h="10rem">
<HStack spacing="3rem">
<Text
fontSize="2xl"
fontFamily="SCDream_Bold">
프로젝트 기간
</Text>
<Text fontSize="xl">{changeDateForm(startDate, endDate)}</Text>
{startDate && endDate ? (
<Text fontSize="xl">{changeDateForm(startDate, endDate)}</Text>
) : (
<Text
color="grey.500"
fontSize="lg">
등록된 프로젝트 기간이 존재하지 않습니다.
</Text>
)}
</HStack>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
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",
fontFamily: "SCDream_Regular",
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 (
<Box data-color-mode="light">
<MDEditor.Markdown
source={processedText}
style={{ ...ViewStyleParams }}
/>
{processedText ? (
<MDEditor.Markdown
source={processedText}
style={{ ...ViewOptions }}
/>
) : (
<MDEditor.Markdown
source={notContentText}
style={{ ...ViewNotContentOptions }}
/>
)}
</Box>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -12,26 +12,34 @@ interface MemberInfoProps {
const MemberInfo = ({ members }: MemberInfoProps) => {
const groupedByCategory = membersCategory(members)
return (
<Flex
direction="column"
gap="2rem">
<Stack
direction={groupedByCategory.length > 0 ? "column" : "row"}
spacing="2rem">
<Text
fontSize="2xl"
fontFamily="SCDream_Bold">
팀원
</Text>
<Flex
gap="1rem"
<HStack
spacing="1rem"
flexWrap="wrap">
{groupedByCategory.map(([category, members]) => (
<MemberList
key={category}
category={category}
members={members}
/>
))}
</Flex>
</Flex>
{groupedByCategory.length > 0 ? (
groupedByCategory.map(([category, members]) => (
<MemberList
key={category}
category={category}
members={members}
/>
))
) : (
<Text
color="grey.500"
fontSize="lg">
등록된 멤버가 존재하지 않습니다.
</Text>
)}
</HStack>
</Stack>
)
}

Expand Down
Loading
Loading