From 47fd258c099b23a1771f02b5d9442b1a428b8e2c Mon Sep 17 00:00:00 2001 From: dev-junseo <80705329+dev-junseo@users.noreply.github.com> Date: Wed, 29 Nov 2023 23:55:50 +0900 Subject: [PATCH 1/7] =?UTF-8?q?#161=20=EC=B9=B4=ED=85=8C=EA=B3=A0=EB=A6=AC?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1=20ui/=EA=B8=B0=EB=8A=A5=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/DND/CreateCategoryModal.tsx | 39 +------------------ .../components/GuestBook/GuestBookModal.tsx | 3 ++ 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/client/src/components/DND/CreateCategoryModal.tsx b/client/src/components/DND/CreateCategoryModal.tsx index 19ead62..f9231a7 100644 --- a/client/src/components/DND/CreateCategoryModal.tsx +++ b/client/src/components/DND/CreateCategoryModal.tsx @@ -4,17 +4,12 @@ import { ModalActions, ModalContent, ModalTitle } from '../Modal/Modal.style'; import { Stack, TextField } from '@mui/material'; import ModalButton from '../Modal/ModalButton'; import { ModalType } from '@/types/common'; -import Button from '../Button/Button'; import { useMutation, useQueryClient } from '@tanstack/react-query'; import { PostCategoryApi } from '@/api/category-api'; -import CheckIcon from '@mui/icons-material/Check'; -import CloseIcon from '@mui/icons-material/Close'; function CreateCategoryModal({ open, onClose }: ModalType) { const queryClient = useQueryClient(); const [categoryName, setCategoryName] = useState(''); - const [repositoryUrl, setRepositoryUrl] = useState(''); - const [isPrCategory, setIsPrCategory] = useState(Boolean); const postCategoryQuery = useMutation(PostCategoryApi, { onSuccess() { queryClient.invalidateQueries(['guestbook']); @@ -23,8 +18,8 @@ function CreateCategoryModal({ open, onClose }: ModalType) { const postCategoryClick = () => { const newCategoryBody = { categoryName: categoryName, - isPrCategory: isPrCategory, - repositoryUrl: repositoryUrl, + isPrCategory: false, + repositoryUrl: null, }; postCategoryQuery.mutate(newCategoryBody); onClose(); @@ -47,36 +42,6 @@ function CreateCategoryModal({ open, onClose }: ModalType) { }} /> - - 깃허브 연동 여부 : - - - - - - - - - 레포지토리 URL : - - { - setRepositoryUrl(e.target.value); - }} /> - diff --git a/client/src/components/GuestBook/GuestBookModal.tsx b/client/src/components/GuestBook/GuestBookModal.tsx index 22b5292..d644d85 100644 --- a/client/src/components/GuestBook/GuestBookModal.tsx +++ b/client/src/components/GuestBook/GuestBookModal.tsx @@ -22,6 +22,7 @@ function GuestBookModal({ open, blogId, onClose }: GuestbookType) { const postGuestbookQuery = useMutation(PostGuestbookApi, { onSuccess() { queryClient.invalidateQueries(['guestbook']); + setMessage(''); }, }); const postGuestbookClick = () => { @@ -31,6 +32,7 @@ function GuestBookModal({ open, blogId, onClose }: GuestbookType) { message: message, }; postGuestbookQuery.mutate(newPostGuestbookBody); + }; @@ -74,6 +76,7 @@ function GuestBookModal({ open, blogId, onClose }: GuestbookType) { From 696c1995615868e2e6e78e4adb20aa5465ac2e1a Mon Sep 17 00:00:00 2001 From: dev-junseo <80705329+dev-junseo@users.noreply.github.com> Date: Thu, 30 Nov 2023 00:34:25 +0900 Subject: [PATCH 2/7] =?UTF-8?q?#161=20=EB=B0=A9=EB=AA=85=EB=A1=9D=20post?= =?UTF-8?q?=EC=8B=9C=20textfield=20=EA=B3=B5=EB=B0=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/GuestBook/GuestBookModal.tsx | 5 ++--- client/src/constant/common.ts | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/client/src/components/GuestBook/GuestBookModal.tsx b/client/src/components/GuestBook/GuestBookModal.tsx index d644d85..a1a3987 100644 --- a/client/src/components/GuestBook/GuestBookModal.tsx +++ b/client/src/components/GuestBook/GuestBookModal.tsx @@ -32,7 +32,6 @@ function GuestBookModal({ open, blogId, onClose }: GuestbookType) { message: message, }; postGuestbookQuery.mutate(newPostGuestbookBody); - }; @@ -45,7 +44,7 @@ function GuestBookModal({ open, blogId, onClose }: GuestbookType) { 방명록 📮 - + {guestbook?.messageDto.map((message) => { return ( { setMessage(e.target.value); }} @@ -76,7 +76,6 @@ function GuestBookModal({ open, blogId, onClose }: GuestbookType) { diff --git a/client/src/constant/common.ts b/client/src/constant/common.ts index 4dd1b73..825fb9e 100644 --- a/client/src/constant/common.ts +++ b/client/src/constant/common.ts @@ -15,8 +15,8 @@ export const getCurrentThemeClass = ( export const API_BASE_URL = 'http://glogglogglog-env.eba-fuksumx7.ap-northeast-2.elasticbeanstalk.com'; -// export const OAUTH2_REDIRECT_URI = 'http://localhost:3000/oauth2/redirect'; -export const OAUTH2_REDIRECT_URI = 'http://15.164.221.35:3000/oauth2/redirect'; +export const OAUTH2_REDIRECT_URI = 'http://localhost:3000/oauth2/redirect'; +// export const OAUTH2_REDIRECT_URI = 'http://15.164.221.35:3000/oauth2/redirect'; export const GITHUB_AUTH_URL = API_BASE_URL + '/oauth2/authorization/github?redirect_uri=' + OAUTH2_REDIRECT_URI; From 16b177a5666cb5aba7df1fedc6667d60fbedfe15 Mon Sep 17 00:00:00 2001 From: dev-junseo <80705329+dev-junseo@users.noreply.github.com> Date: Thu, 30 Nov 2023 02:34:03 +0900 Subject: [PATCH 3/7] =?UTF-8?q?#163=20=ED=86=A0=EC=8A=A4=ED=8A=B8=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 --- client/src/api/blog-api.ts | 12 +++++++++++- client/src/app/[blogName]/page.tsx | 11 ++++++++--- client/src/app/write/Modal/SaveModal.tsx | 2 +- client/src/components/DND/CategorySettingModal.tsx | 9 +++++++-- client/src/components/DND/CreateCategoryModal.tsx | 11 +++++++++-- client/src/components/GuestBook/GuestBookModal.tsx | 2 ++ client/src/components/Layout/FullLayout.tsx | 3 ++- client/src/types/dto.ts | 5 +++++ 8 files changed, 45 insertions(+), 10 deletions(-) diff --git a/client/src/api/blog-api.ts b/client/src/api/blog-api.ts index c7bcc65..3baf1a2 100644 --- a/client/src/api/blog-api.ts +++ b/client/src/api/blog-api.ts @@ -1,4 +1,4 @@ -import { IBlog, IChangeBlogName, IPost, ISidebar } from '@/types/dto'; +import { IBlog, IBlogUrlParams, IChangeBlogName, IPost, ISidebar } from '@/types/dto'; import { defaultInstance } from '.'; import { useQuery } from '@tanstack/react-query'; @@ -54,3 +54,13 @@ export const useGetIsNewBlogQuery = () => { const { isLoading, error, data } = useQuery([`isNewBlog`], () => getIsNewBlogApi(), {}); return { data, isLoading, error }; }; + +export const getBlogUrl = async (params: IBlogUrlParams) => { + const {data} = await defaultInstance.get('blog/url', {params}); + return data; +} + +export const useGetBlogUrlQuery = (params: IBlogUrlParams) => { + const { isLoading, error, data } = useQuery([`blogUrl`, params], () => getBlogUrl(params), {}); + return { data, isLoading, error }; +} \ No newline at end of file diff --git a/client/src/app/[blogName]/page.tsx b/client/src/app/[blogName]/page.tsx index 3612afd..0d840b5 100644 --- a/client/src/app/[blogName]/page.tsx +++ b/client/src/app/[blogName]/page.tsx @@ -9,6 +9,7 @@ import { ISidebarContent } from '@/types/dto'; import { Stack, TextField } from '@mui/material'; import { useMutation, useQueryClient } from '@tanstack/react-query'; import MDEditor from '@uiw/react-md-editor'; +import { enqueueSnackbar } from 'notistack'; import { useEffect, useState } from 'react'; const Home = ({ params }: { params: { blogName: string } }) => { @@ -27,8 +28,13 @@ const Home = ({ params }: { params: { blogName: string } }) => { const putReadMeCreateQuery = useMutation(PutReadMeApi, { onSuccess: () => { queryClient.invalidateQueries(['readMe']); + enqueueSnackbar({ message: '리드미 페이지가 수정되었습니다.', variant: 'success' }); }, - }); + onError: () => { + enqueueSnackbar({ message: '리드미 페이지가 수정되지 않았습니다.', variant: 'error' }); + }, + } + ); const ReadMeOnClick = () => { const newReadMeBody = { @@ -52,8 +58,7 @@ const Home = ({ params }: { params: { blogName: string } }) => { rightContainer={ { setContent(e.target.value); diff --git a/client/src/app/write/Modal/SaveModal.tsx b/client/src/app/write/Modal/SaveModal.tsx index 09468dd..6e8128a 100644 --- a/client/src/app/write/Modal/SaveModal.tsx +++ b/client/src/app/write/Modal/SaveModal.tsx @@ -95,7 +95,7 @@ function SaveModal({ }; // FormData 생성 함수 - // [FIXME : 템플릿 수정하면서 같이한 거라 나중에 수정 예정] + // eslint-disable-next-line @typescript-eslint/no-explicit-any const createFormData = (postData: any) => { const formData = new FormData(); diff --git a/client/src/components/DND/CategorySettingModal.tsx b/client/src/components/DND/CategorySettingModal.tsx index 08ea029..b7869d0 100644 --- a/client/src/components/DND/CategorySettingModal.tsx +++ b/client/src/components/DND/CategorySettingModal.tsx @@ -8,15 +8,20 @@ import Button from '../Button/Button'; import { Dialog } from '../Dialog/Dialog'; import { useMutation, useQueryClient } from '@tanstack/react-query'; import { DeleteCategoryApi, PutCategoryApi } from '@/api/category-api'; +import { enqueueSnackbar } from 'notistack'; function CategorySettingModal({ open, categoryId, onClose }: CategorySettingModalType) { const queryClient = useQueryClient(); const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); const deleteCategoryQuery = useMutation(DeleteCategoryApi, { onSuccess() { - queryClient.invalidateQueries(['category']); + queryClient.invalidateQueries(['sidebar']); + enqueueSnackbar({ message: '카테고리가 삭제되었습니다', variant: 'success' }); }, - }); + onError() { + enqueueSnackbar({ message: '카테고리가 삭제되지 않았습니다', variant: 'error' }); + } + }); const deleteClick = () => { deleteCategoryQuery.mutate({ categoryId : categoryId }); onClose(); diff --git a/client/src/components/DND/CreateCategoryModal.tsx b/client/src/components/DND/CreateCategoryModal.tsx index f9231a7..db7b995 100644 --- a/client/src/components/DND/CreateCategoryModal.tsx +++ b/client/src/components/DND/CreateCategoryModal.tsx @@ -6,26 +6,33 @@ import ModalButton from '../Modal/ModalButton'; import { ModalType } from '@/types/common'; import { useMutation, useQueryClient } from '@tanstack/react-query'; import { PostCategoryApi } from '@/api/category-api'; +import { enqueueSnackbar } from 'notistack'; function CreateCategoryModal({ open, onClose }: ModalType) { const queryClient = useQueryClient(); const [categoryName, setCategoryName] = useState(''); const postCategoryQuery = useMutation(PostCategoryApi, { onSuccess() { - queryClient.invalidateQueries(['guestbook']); + queryClient.invalidateQueries(['sidebar']); + enqueueSnackbar({ message: '카테고리가 생성되었습니다.', variant: 'success' }); }, + onError() { + enqueueSnackbar({ message: '카테고리가 생성되지 않았습니다.', variant: 'error' }); + } }); const postCategoryClick = () => { const newCategoryBody = { categoryName: categoryName, isPrCategory: false, - repositoryUrl: null, + repositoryUrl: '', }; postCategoryQuery.mutate(newCategoryBody); onClose(); }; + + return ( diff --git a/client/src/components/GuestBook/GuestBookModal.tsx b/client/src/components/GuestBook/GuestBookModal.tsx index a1a3987..e3fb9aa 100644 --- a/client/src/components/GuestBook/GuestBookModal.tsx +++ b/client/src/components/GuestBook/GuestBookModal.tsx @@ -40,6 +40,8 @@ function GuestBookModal({ open, blogId, onClose }: GuestbookType) { setGuestBook(guestbookData); }, [guestbookData]); + + return ( 방명록 📮 diff --git a/client/src/components/Layout/FullLayout.tsx b/client/src/components/Layout/FullLayout.tsx index 5bea916..e1e453e 100644 --- a/client/src/components/Layout/FullLayout.tsx +++ b/client/src/components/Layout/FullLayout.tsx @@ -3,6 +3,7 @@ import { Stack } from '@mui/material'; import { Theme, styled } from '@mui/material/styles'; import { usePathname } from 'next/navigation'; +import { SnackbarProvider } from 'notistack'; // import { useAndroidSSR, useIphoneSSR } from '../../../hooks/useRecoilSSR'; type Children = { @@ -22,5 +23,5 @@ const MainStack = styled(Stack, { export default function FullLayout({ children }: Children) { const pathname = usePathname(); - return {children}; + return {children}; } diff --git a/client/src/types/dto.ts b/client/src/types/dto.ts index e4fa487..1e693b0 100644 --- a/client/src/types/dto.ts +++ b/client/src/types/dto.ts @@ -432,3 +432,8 @@ export interface IUserInfo { export interface IBlogInfo { newBlogName: string; } + +// categoryId -> 블로그 URL +export interface IBlogUrlParams { + categoryId: number; +} \ No newline at end of file From 440480a5c42ef951278b0dce95223f976f3a099c Mon Sep 17 00:00:00 2001 From: dev-junseo <80705329+dev-junseo@users.noreply.github.com> Date: Thu, 30 Nov 2023 04:37:36 +0900 Subject: [PATCH 4/7] =?UTF-8?q?#161=20=EB=A6=AC=EB=93=9C=EB=AF=B8=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20url=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 --- client/src/api/blog-api.ts | 1 + .../[categoryId]/[postId]/postId.style.tsx | 1 + client/src/app/write/Modal/SaveModal.tsx | 15 ++++++++-- .../HeaderFriendModal/FriendModal.style.tsx | 30 ++++++++++++++----- client/src/types/dto.ts | 7 ++++- 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/client/src/api/blog-api.ts b/client/src/api/blog-api.ts index 3baf1a2..13f4905 100644 --- a/client/src/api/blog-api.ts +++ b/client/src/api/blog-api.ts @@ -55,6 +55,7 @@ export const useGetIsNewBlogQuery = () => { return { data, isLoading, error }; }; +// 카테고리 아이디로 블로그url 불러오기 export const getBlogUrl = async (params: IBlogUrlParams) => { const {data} = await defaultInstance.get('blog/url', {params}); return data; diff --git a/client/src/app/[blogName]/home/[categoryId]/[postId]/postId.style.tsx b/client/src/app/[blogName]/home/[categoryId]/[postId]/postId.style.tsx index 0294dfa..af0bc06 100644 --- a/client/src/app/[blogName]/home/[categoryId]/[postId]/postId.style.tsx +++ b/client/src/app/[blogName]/home/[categoryId]/[postId]/postId.style.tsx @@ -47,6 +47,7 @@ export const ProfileImg = styled(Stack)(({ imageSrc }: { imageSrc: string }) => })) export const PostReply = styled(Stack)({ + marginTop: '50px', height: '100%', flexDirection: 'column', }); diff --git a/client/src/app/write/Modal/SaveModal.tsx b/client/src/app/write/Modal/SaveModal.tsx index 6e8128a..ae98ff4 100644 --- a/client/src/app/write/Modal/SaveModal.tsx +++ b/client/src/app/write/Modal/SaveModal.tsx @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import React, { useRef, useState } from 'react'; +import React, { useRef, useState, useEffect } from 'react'; import Modal from '@/components/Modal/Modal'; import { Dialog } from '@/components/Dialog/Dialog'; import { ModalType, PrivateMapType } from '@/types/common'; @@ -22,6 +22,8 @@ import { PostTemplateApi, PostTemporaryApi, PostWriteApi, UpdateWriteApi } from import { usePathname, useRouter } from 'next/navigation'; import { WriteModalType, WriteProps } from '@/util/useWriteProps'; import { enqueueSnackbar } from 'notistack'; +import { useGetBlogUrlQuery } from '@/api/blog-api'; +import { IBlogUrl } from '@/types/dto'; function SaveModal({ open, @@ -47,11 +49,16 @@ function SaveModal({ const queryClient = useQueryClient(); const isPrUpdate = pathname.startsWith('/write/pr/update'); const isPr = pathname.startsWith('/write/pr'); + const {data: blogUrlData} = useGetBlogUrlQuery({ + categoryId: categoryId, + }); + const [blogUrl, setBlogUrl] = useState(); const postWriteCreateQuery = useMutation(PostWriteApi, { onSuccess: () => { + queryClient.invalidateQueries(['post']); - router.push('/home'); + router.push(`/${blogUrl}`); enqueueSnackbar({ message: '글 작성이 완료되었습니다.', variant: 'success' }); }, onError: (e: Error) => { @@ -212,6 +219,10 @@ function SaveModal({ fileInput.current?.click(); }; + useEffect(() => { + setBlogUrl(blogUrlData); + }, [blogUrlData]); + const privateMap: PrivateMapType = { publicButton: { private: { diff --git a/client/src/components/Layout/HeaderFriendModal/FriendModal.style.tsx b/client/src/components/Layout/HeaderFriendModal/FriendModal.style.tsx index f041b2a..00c3283 100644 --- a/client/src/components/Layout/HeaderFriendModal/FriendModal.style.tsx +++ b/client/src/components/Layout/HeaderFriendModal/FriendModal.style.tsx @@ -83,6 +83,8 @@ function FriendListComponent({ const [IntroduceOpen, setIntroduceOpen] = useState(false); const [deleteConfirmOpen, setDeleteConFirmOpen] = useState(false); const [isAccept, setIsAccept] = useState(Number); + const [acceptConfirmOpen, setAcceptConfirmOpen] = useState(false); + const [refuseConfirmOpen, setRefuseConfirmOpen] = useState(false); const putAllowFriendIdCreateQuery = useMutation(PutFriendAllowApi, { onSuccess: () => { queryClient.invalidateQueries(['friend']) @@ -159,10 +161,7 @@ function FriendListComponent({ @@ -171,10 +170,7 @@ function FriendListComponent({ @@ -207,6 +203,24 @@ function FriendListComponent({ action: deleteClick, }} /> + setAcceptConfirmOpen(false)} + message="친구 추가하시겠습니까?" + action={{ + content: '확인', + action: AllowFriendOnClick, + }} + /> + setAcceptConfirmOpen(false)} + message="친구 거절하시겠습니까?" + action={{ + content: '확인', + action: AllowFriendOnClick, + }} + /> setIntroduceOpen(false)}> diff --git a/client/src/types/dto.ts b/client/src/types/dto.ts index 1e693b0..682f7dd 100644 --- a/client/src/types/dto.ts +++ b/client/src/types/dto.ts @@ -435,5 +435,10 @@ export interface IBlogInfo { // categoryId -> 블로그 URL export interface IBlogUrlParams { - categoryId: number; + categoryId?: number; +} + +// categoryId -> 블로그 URL 응답값 +export interface IBlogUrl { + blogUrl: string; } \ No newline at end of file From 7737d6ee7015ae511eb52865141ce0a9006e8faa Mon Sep 17 00:00:00 2001 From: dev-junseo <80705329+dev-junseo@users.noreply.github.com> Date: Thu, 30 Nov 2023 05:34:06 +0900 Subject: [PATCH 5/7] =?UTF-8?q?#161=20=E3=85=87=E3=85=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/app/[blogName]/home/[categoryId]/[postId]/page.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/app/[blogName]/home/[categoryId]/[postId]/page.tsx b/client/src/app/[blogName]/home/[categoryId]/[postId]/page.tsx index 726fdd2..4bf1135 100644 --- a/client/src/app/[blogName]/home/[categoryId]/[postId]/page.tsx +++ b/client/src/app/[blogName]/home/[categoryId]/[postId]/page.tsx @@ -47,7 +47,7 @@ import { usegetblogIdQuery } from '@/api/readme-api'; const page = ({ params }: { params: { blogName: string; categoryId: string; postId: string } }) => { const { data: blogIdData } = usegetblogIdQuery({ blogUrl: params.blogName }); - const [blogId, setBlogId] = useState(); + const [, setBlogId] = useState(); const { data: sidebarData } = useGetSidebarQuery({ blogId: blogIdData }); const { data: postData } = useGetPostQuery({ postId: Number(params.postId) }); const [IntroduceOpen, setIntroduceOpen] = useState(false); @@ -55,7 +55,7 @@ const page = ({ params }: { params: { blogName: string; categoryId: string; post const router = useRouter(); const theme = useTheme(); - console.log(`useState blogId : ${blogId}`); + console.log(`categoryId : ${params.categoryId}`); //[FIXME: repliese get할 때 body말고 parameter로 바뀌어졌을 때 useState() 바꿔주기] const [page, setPage] = useState(0); From 2b35dc6238f68a9cfa8c3da8ed95895daaf93da0 Mon Sep 17 00:00:00 2001 From: dev-junseo <80705329+dev-junseo@users.noreply.github.com> Date: Thu, 30 Nov 2023 06:15:13 +0900 Subject: [PATCH 6/7] =?UTF-8?q?#161=20=EB=8C=93=EA=B8=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/api/reply-api.ts | 9 +++- .../home/[categoryId]/[postId]/page.tsx | 3 +- .../[categoryId]/[postId]/postId.style.tsx | 41 +++++++++++++++++-- .../Layout/HeaderFriendModal/FriendModal.tsx | 4 +- client/src/types/dto.ts | 6 +++ 5 files changed, 53 insertions(+), 10 deletions(-) diff --git a/client/src/api/reply-api.ts b/client/src/api/reply-api.ts index 7200962..b1091ad 100644 --- a/client/src/api/reply-api.ts +++ b/client/src/api/reply-api.ts @@ -1,4 +1,4 @@ -import { IPatchReplyLike, IReply, IReplyParams } from '@/types/dto'; +import { IPatchReplyLike, IPutReply, IReply, IReplyParams } from '@/types/dto'; import { defaultInstance } from '.'; import { useQuery } from '@tanstack/react-query'; @@ -22,4 +22,9 @@ export const PostReplyApi = async (body: IReply) => { export const PatchReplyLikeApi = async (params: IPatchReplyLike) => { const {data} = await defaultInstance.patch(`/replies/like/${params.replyId}`, params) return data; -} \ No newline at end of file +} + +export const putReplyApi = async (body: IPutReply) => { + const {data} = await defaultInstance.put('/replies', body); + return data; +}; \ No newline at end of file diff --git a/client/src/app/[blogName]/home/[categoryId]/[postId]/page.tsx b/client/src/app/[blogName]/home/[categoryId]/[postId]/page.tsx index 4bf1135..292fc56 100644 --- a/client/src/app/[blogName]/home/[categoryId]/[postId]/page.tsx +++ b/client/src/app/[blogName]/home/[categoryId]/[postId]/page.tsx @@ -57,7 +57,6 @@ const page = ({ params }: { params: { blogName: string; categoryId: string; post console.log(`categoryId : ${params.categoryId}`); - //[FIXME: repliese get할 때 body말고 parameter로 바뀌어졌을 때 useState() 바꿔주기] const [page, setPage] = useState(0); const [order, setOrder] = useState('like'); const orderList = ['like', 'recent', 'oldest']; @@ -139,7 +138,7 @@ const page = ({ params }: { params: { blogName: string; categoryId: string; post const handleClose = () => { setAnchorEl(null); }; - + console.log(reply); return ( diff --git a/client/src/app/[blogName]/home/[categoryId]/[postId]/postId.style.tsx b/client/src/app/[blogName]/home/[categoryId]/[postId]/postId.style.tsx index af0bc06..b3b0137 100644 --- a/client/src/app/[blogName]/home/[categoryId]/[postId]/postId.style.tsx +++ b/client/src/app/[blogName]/home/[categoryId]/[postId]/postId.style.tsx @@ -1,5 +1,5 @@ import IconButton from '@/components/Button/IconButton'; -import { Pagination, Tooltip } from '@mui/material'; +import { Pagination, TextField, Tooltip } from '@mui/material'; import { Stack } from '@mui/material'; import { styled, useTheme } from '@mui/material/styles'; import ThumbUpOffAltIcon from '@mui/icons-material/ThumbUpOffAlt'; @@ -9,13 +9,13 @@ import { IIntroduce } from '@/types/dto'; import { useGetIntroduceQuery } from '@/api/introduce-api'; import { useInsertionEffect, useState } from 'react'; import Modal from '@/components/Modal/Modal'; -import { ModalContent } from '@/components/Modal/Modal.style'; +import { ModalContent, ModalTitle } from '@/components/Modal/Modal.style'; import PageLink from '@/components/PageLink/PageLink'; import { useMutation, useQueryClient } from '@tanstack/react-query'; import { PutFriendAllowApi, PutFriendRequestApi } from '@/api/friend-api'; import CheckIcon from '@mui/icons-material/Check'; import CloseIcon from '@mui/icons-material/Close'; -import { PatchReplyLikeApi } from '@/api/reply-api'; +import { PatchReplyLikeApi, putReplyApi } from '@/api/reply-api'; export const ThumbnailArea = styled(Stack)({ width: '100%', @@ -108,6 +108,7 @@ function RepliesComponent({ }) { const theme = useTheme(); const queryClient = useQueryClient(); + const [putReplyOpen, setPutReplyOpen] = useState(false); const [IntroduceOpen, setIntroduceOpen] = useState(false); const {data: introduceData} = useGetIntroduceQuery({ @@ -142,6 +143,20 @@ function RepliesComponent({ PutFriendRequestQuery.mutate(newRequestBody); }; + const [newReply, setNewReply] = useState(''); + const PutReplyQuery = useMutation(putReplyApi, { + onSuccess: () => { + queryClient.invalidateQueries(['replies']) + }, + }); + const PutReplyOnClick = () => { + const newReplyBody = { + repyId: replyId, + message: newReply, + } + PutReplyQuery.mutate(newReplyBody); + }; + const PatchReplyLikeQuery = useMutation(PatchReplyLikeApi, { onSuccess: () => { queryClient.invalidateQueries(['replies']) @@ -189,12 +204,30 @@ function RepliesComponent({ )} - {isEdit ? : <>} + {isEdit ? : <>} {likesCount} + setPutReplyOpen(false)}> + 수정하기 + + { + setNewReply(e.target.value); + }}> + + + + {/* 댓글 상대방 introduction */} setIntroduceOpen(false)}> diff --git a/client/src/components/Layout/HeaderFriendModal/FriendModal.tsx b/client/src/components/Layout/HeaderFriendModal/FriendModal.tsx index a2ae335..0c46410 100644 --- a/client/src/components/Layout/HeaderFriendModal/FriendModal.tsx +++ b/client/src/components/Layout/HeaderFriendModal/FriendModal.tsx @@ -100,7 +100,7 @@ function FriendModal({ open, onClose }: ModalType) { profileImg={friendInfo.nickname} relationship={friendInfo.relationship} haveNewPost={friendInfo.haveNewPost} - recentPostId={`/{blogUrl}/home/1/${friendInfo.recentPostId}`} + recentPostId={`/${userDetail?.blogUrl}`} /> ); })} @@ -139,7 +139,7 @@ function FriendModal({ open, onClose }: ModalType) { profileImg={searchInfo.nickname} relationship={searchInfo.relationship} haveNewPost={searchInfo.haveNewPost} - recentPostId={`/${userDetail?.blogUrl}/home/1/${searchInfo.recentPostId}`} + recentPostId={`/${userDetail?.blogUrl}`} /> ); })} diff --git a/client/src/types/dto.ts b/client/src/types/dto.ts index 682f7dd..b3002d4 100644 --- a/client/src/types/dto.ts +++ b/client/src/types/dto.ts @@ -89,6 +89,12 @@ export interface IReply { message: string; } +//댓글 수정 +export interface IPutReply { + repyId: number; + message: string; +} + //댓글 좋아요 patch export interface IPatchReplyLike { replyId: number; From 0e785df54eb06af2158d0b2f926a7185b81f33da Mon Sep 17 00:00:00 2001 From: dev-junseo <80705329+dev-junseo@users.noreply.github.com> Date: Thu, 30 Nov 2023 06:34:17 +0900 Subject: [PATCH 7/7] =?UTF-8?q?#161=20=E3=85=87=E3=85=87=E3=85=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/[blogName]/home/[categoryId]/[postId]/postId.style.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/app/[blogName]/home/[categoryId]/[postId]/postId.style.tsx b/client/src/app/[blogName]/home/[categoryId]/[postId]/postId.style.tsx index b3b0137..a602b71 100644 --- a/client/src/app/[blogName]/home/[categoryId]/[postId]/postId.style.tsx +++ b/client/src/app/[blogName]/home/[categoryId]/[postId]/postId.style.tsx @@ -203,10 +203,10 @@ function RepliesComponent({ )} + {likesCount} {isEdit ? : <>} - {likesCount}