Skip to content

Commit

Permalink
[Change ๐Ÿšœ ] ๋Œ“๊ธ€ ๊ด€๋ จ ์ปดํฌ๋„ŒํŠธ ๋ถ„๋ฆฌ
Browse files Browse the repository at this point in the history
  • Loading branch information
Whoknow77 committed Mar 11, 2024
1 parent d3f5ff3 commit 5a11eec
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 58 deletions.
4 changes: 2 additions & 2 deletions src/pages/ProjectDetailPage/components/Comments/Comments.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Comment } from "api-models"

import CommentsForm from "./CommentsForm"
import CommentsList from "./CommentsList"
import CommentsForm from "./CommentsForm/CommentsForm"
import CommentsList from "./CommentsList/CommentsList"
import CommentsLayout from "./Layout/CommentsLayout"

export interface CommentsProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
// TODO: 1. ๋นˆ ๊ฐ’์ผ๋•Œ ์ฒ˜๋ฆฌ(Toast๋กœ ๊ตฌํ˜„)
// 2. ์ผ์ • ๋†’์ด ์ด์ƒ์ผ๋•Œ ๋†’์ด๊ฐ€ ๋Š˜์–ด๋‚˜์ง€ ์•Š๊ณ  ์Šคํฌ๋กค๋ฐ”
// 3. ownerId๋Š” userInfo์—์„œ
// 3. ๋Œ€๋Œ“๊ธ€์ผ๋•Œ parentId๋ฅผ ๋™์ ์œผ๋กœ ๋ฐ›์•„์•ผ ํ•˜๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ
// 4. isAnonymous ์ฒ˜๋ฆฌ
// TODO: ์ต๋ช… ์ฒ˜๋ฆฌ
import { SubmitHandler, useForm } from "react-hook-form"
import ResizeTextarea from "react-textarea-autosize"

Expand All @@ -11,8 +7,8 @@ import { useUserInfoData } from "@services/caches/useUserInfoData"

import { usePostCommentMutation } from "@pages/ProjectDetailPage/hooks/mutations/usePostCommentMutation"

import { CommentFormValues } from "../../types/commentFormValues"
import { ProjectIdProps, withProjectId } from "./Hoc/withProjectId"
import { CommentFormValues } from "../../../types/commentFormValues"
import { ProjectIdProps, withProjectId } from "../Hoc/withProjectId"

interface CommentsFormProps extends ProjectIdProps {
parentId?: number | null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// TODO: ์ „์—ญ์œผ๋กœ ๋นผ๊ธฐ
import { Avatar, AvatarProps } from "@chakra-ui/react"
import { CommentUser } from "api-models"

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import ResizeTextarea from "react-textarea-autosize"

import { Box, HStack, Text, Textarea } from "@chakra-ui/react"

import { CommentsItemProps } from "@pages/ProjectDetailPage/types/commentItem"

import CommentsButton from "./CommentsButton"

interface CommentsEditFormTextProps
extends Omit<
CommentsItemProps,
| "handleOnReply"
| "handleOffReply"
| "replyTargetCommentId"
| "handleNavigateProfile"
| "isReply"
> {}

const CommentsEditFormText = ({
comment,
handleOnEdit,
handleOffEdit,
handleDelete,
handleSubmit,
onSubmitEdit,
editTargetCommentId,
isEditing,
register,
}: CommentsEditFormTextProps) => {
return (
<Box w="100%">
<form onSubmit={handleSubmit(onSubmitEdit)}>
<HStack
justify="space-between"
w="100%">
{editTargetCommentId === comment.id && isEditing ? (
<Textarea
rows={1}
w="100%"
fontSize="lg"
p="0.2rem"
as={ResizeTextarea}
isRequired={false}
resize="none"
{...register}
/>
) : (
<Text
fontSize="lg"
p="0.2rem">
{comment.content}
</Text>
)}
<HStack gap="1rem">
<CommentsButton
{...{
editTargetCommentId,
comment,
isEditing,
handleDelete,
handleOnEdit,
handleOffEdit,
}}
/>
</HStack>
</HStack>
</form>
</Box>
)
}

export default CommentsEditFormText
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
// TODO: 1. ํฌ์ปค์Šค ์ž๋™ ์กฐ์ •(register commentId ์‚ฌ์šฉ)
// 2. ๊ธ€์ž์ˆ˜ ์ œํ•œ
import ResizeTextarea from "react-textarea-autosize"
import { Box, Button, HStack, Stack } from "@chakra-ui/react"

import { Box, Button, HStack, Stack, Text } from "@chakra-ui/react"
import { Textarea } from "@chakra-ui/react"

import { CommentsItemProps } from "../../types/commentItem"
import { CommentsItemProps } from "../../../types/commentItem"
import CommentsForm from "../CommentsForm/CommentsForm"
import CommentTitle from "./CommentTitle"
import CommentsAvatar from "./CommentsAvatar"
import CommentsButton from "./CommentsButton"
import CommentsForm from "./CommentsForm"
import CommentsEditFormText from "./CommentsEditFormText"
import ReplyComment from "./ReplyComment"

const CommentsItem = ({
Expand Down Expand Up @@ -57,45 +54,19 @@ const CommentsItem = ({
user={comment.user}
createdAt={comment.createdAt}
/>
<Box w="100%">
<form onSubmit={handleSubmit(onSubmitEdit)}>
<HStack
justify="space-between"
w="100%">
{editTargetCommentId === comment.id && isEditing ? (
<Textarea
rows={1}
w="100%"
fontSize="lg"
p="0.2rem"
as={ResizeTextarea}
isRequired={false}
resize="none"
{...register}
/>
) : (
<Text
fontSize="lg"
p="0.2rem">
{comment.content}
</Text>
)}
<HStack gap="1rem">
<CommentsButton
{...{
editTargetCommentId,
comment,
isEditing,
handleDelete,
handleOnEdit,
handleOffEdit,
}}
/>
</HStack>
</HStack>
</form>
</Box>

<CommentsEditFormText
{...{
handleSubmit,
onSubmitEdit,
editTargetCommentId,
comment,
isEditing,
register,
handleDelete,
handleOnEdit,
handleOffEdit,
}}
/>
{!comment.parentId &&
(isReply ? (
comment.id === replyTargetCommentId && (
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box, Flex } from "@chakra-ui/react"
import { Comment } from "api-models"

import { CommentsItemProps } from "../../types/commentItem"
import { CommentsItemProps } from "../../../types/commentItem"
import CommentsItem from "./CommentsItem"

interface ReplyCommentProps extends Omit<CommentsItemProps, "comment"> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Comment } from "api-models"

import { useComment } from "@pages/ProjectDetailPage/hooks/useComment"

import CommentsItem from "./CommentsItem"
import CommentsItem from "../CommentsItem/CommentsItem"

interface CommentsListProps {
comments: Comment[]
Expand Down

0 comments on commit 5a11eec

Please sign in to comment.