From 808d5d29e593774e7002a989699d9abdb4294aed Mon Sep 17 00:00:00 2001 From: Jungu Lee <1zzangjun@gmail.com> Date: Sun, 19 Nov 2023 20:42:20 +0900 Subject: [PATCH 1/9] =?UTF-8?q?New=20:=20=ED=8C=94=EB=A1=9C=EC=9E=89=20?= =?UTF-8?q?=ED=95=98=EA=B3=A0=EC=9E=88=EB=8A=94=20=EC=9C=A0=EC=A0=80?= =?UTF-8?q?=EC=9D=98=20=EC=88=98=20=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/user/info/UserInfoCard.tsx | 5 ++++- client/src/types/auth/myInfo.ts | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/client/src/components/user/info/UserInfoCard.tsx b/client/src/components/user/info/UserInfoCard.tsx index 21b951d..a247a11 100644 --- a/client/src/components/user/info/UserInfoCard.tsx +++ b/client/src/components/user/info/UserInfoCard.tsx @@ -4,7 +4,7 @@ import UserAvatar from "@/components/user/info/UserAvatar"; import { Box, Button, Typography } from "@mui/material"; type Props = { - data: MyInfoInterface & { isFollowing: boolean }; + data: MyInfoInterface; }; const UserInfo = ({ data }: Props) => { @@ -12,6 +12,7 @@ const UserInfo = ({ data }: Props) => { const { id, followerCount, + followingCount, nickname, profileImages, isFollowing, @@ -38,6 +39,8 @@ const UserInfo = ({ data }: Props) => { {followerCount} 팔로워 + {followingCount} + 팔로잉 {isFollowing ? ( + {buttonTitle && ( + + )} ); From c2c51198a1dcc7da7e007b42d792be6d642b2bca Mon Sep 17 00:00:00 2001 From: Jungu Lee <1zzangjun@gmail.com> Date: Sun, 19 Nov 2023 20:44:51 +0900 Subject: [PATCH 5/9] =?UTF-8?q?Minor=20:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=EB=AA=A8=EB=93=88=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/app/search/page.tsx | 1 - client/src/app/user/page.tsx | 9 --------- 2 files changed, 10 deletions(-) delete mode 100644 client/src/app/user/page.tsx diff --git a/client/src/app/search/page.tsx b/client/src/app/search/page.tsx index f77fa1e..e2afb6b 100644 --- a/client/src/app/search/page.tsx +++ b/client/src/app/search/page.tsx @@ -3,7 +3,6 @@ import SearchArea from "@/components/search/SearchArea"; import { getPostListQueryFn } from "@/queries/post/useGetPostListInfiniteQuery"; import getTokenFromCookies from "@/utils/getTokenFromCookies"; import { Container } from "@mui/material"; -import { cookies } from "next/headers"; const SearchPage = async ({ searchParams, diff --git a/client/src/app/user/page.tsx b/client/src/app/user/page.tsx deleted file mode 100644 index 2a127e8..0000000 --- a/client/src/app/user/page.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import DevelopingPage from "@/components/DevelopingPage"; - -const MyPage = () => { - return ( - - ) -} - -export default MyPage \ No newline at end of file From 0f5e90eea0279af4ec1ae2db37e3be302db1be7d Mon Sep 17 00:00:00 2001 From: Jungu Lee <1zzangjun@gmail.com> Date: Sun, 19 Nov 2023 20:45:14 +0900 Subject: [PATCH 6/9] =?UTF-8?q?Fix=20:=20Suspense=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/search/SearchArea.tsx | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/client/src/components/search/SearchArea.tsx b/client/src/components/search/SearchArea.tsx index 57c9fc7..1b7f445 100644 --- a/client/src/components/search/SearchArea.tsx +++ b/client/src/components/search/SearchArea.tsx @@ -41,18 +41,10 @@ const SearchArea = ({ initialData, searchKeyword }: Props) => { }} /> - - - - } - > - - + ); }; From 89325805908ea57104b30b14de36035498ca78e7 Mon Sep 17 00:00:00 2001 From: Jungu Lee <1zzangjun@gmail.com> Date: Sun, 19 Nov 2023 20:46:03 +0900 Subject: [PATCH 7/9] =?UTF-8?q?Refactor=20:=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=EC=97=90=20=EB=94=B0=EB=9D=BC=20=ED=95=B4?= =?UTF-8?q?=EB=8B=B9=20=EC=9C=A0=EC=A0=80=EC=9D=98=20=EA=B2=8C=EC=8B=9C?= =?UTF-8?q?=EA=B8=80=EC=9D=84=20=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/app/user/[userId]/page.tsx | 5 +++-- client/src/const/serverPath.ts | 8 +++++++- .../queries/post/useGetPostListInfiniteQuery.tsx | 15 +++++++++++---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/client/src/app/user/[userId]/page.tsx b/client/src/app/user/[userId]/page.tsx index 49f0d91..0536ecc 100644 --- a/client/src/app/user/[userId]/page.tsx +++ b/client/src/app/user/[userId]/page.tsx @@ -6,16 +6,17 @@ import NoResult from "@/assets/images/noResult.png"; import { Box } from "@mui/material"; import Image from "next/image"; import PostCardList from "@/components/post/PostCardList"; +import { USER_SUMMARY } from "@/const/serverPath"; const page = async ({ params }: { params: { userId: string } }) => { try { const { data } = await axios.get< MyInfoInterface & { isFollowing: boolean } - >(`/user/${params.userId}/summary`); + >(USER_SUMMARY(params.userId)); return ( <> - + ); } catch { diff --git a/client/src/const/serverPath.ts b/client/src/const/serverPath.ts index 580e5e7..fb1d9be 100644 --- a/client/src/const/serverPath.ts +++ b/client/src/const/serverPath.ts @@ -51,4 +51,10 @@ export const POST_LIKE_URL = (id:string)=>`/posts/like/${id}` as const * 포스트의 PK를 입력받아 해당 PK의 게시글의 좋아요 취소를 요청 * @param id 게시글의 PK */ -export const POST_UN_LIKE_URL = (id:string)=>`/posts/like-cancel/${id}` as const \ No newline at end of file +export const POST_UN_LIKE_URL = (id:string)=>`/posts/like-cancel/${id}` as const +/** + * 유저 ID 를 입력받아 해당 유저의 정보를 불러오는 URL + * @param id 유저 PK + * @returns + */ +export const USER_SUMMARY = (id:string)=>`/user/${id}/summary` as const \ No newline at end of file diff --git a/client/src/queries/post/useGetPostListInfiniteQuery.tsx b/client/src/queries/post/useGetPostListInfiniteQuery.tsx index 5667dbd..2d665c4 100644 --- a/client/src/queries/post/useGetPostListInfiniteQuery.tsx +++ b/client/src/queries/post/useGetPostListInfiniteQuery.tsx @@ -13,16 +13,21 @@ export const useGetPostListInfiniteQuery = ({ initialData, size, searchKeyword, + searchUserNos, headers, }: UseGetPostListQueryInterface) => { return useInfiniteQuery({ - queryKey: getPostListInfiniteQueryKey.byKeyword(searchKeyword), + queryKey: getPostListInfiniteQueryKey.byKeyword({ + keyword: searchKeyword, + userNo: searchUserNos, + }), queryFn: async ({ pageParam = 0 }) => await getPostListQueryFn({ page: pageParam, size, searchKeyword, + searchUserNos, headers: headers?.Authorization ? headers : { Authorization: getTokenFromLocalStorage() }, @@ -49,7 +54,7 @@ export interface GetPostListOptions { page?: number; size?: number; searchKeyword?: string; - searchUserNos?:string; + searchUserNos?: string; } /** * 실제 서버에서 응답해주는 값 @@ -70,13 +75,14 @@ export const getPostListQueryFn = async ({ page = 0, size = 10, searchKeyword, + searchUserNos, headers, }: GetPostListOptions & { headers?: AxiosRequestConfig["headers"]; }): Promise => { const { data } = await axios.get("/posts", { baseURL: process.env.NEXT_PUBLIC_BASE_URL, - params: { page, size, searchKeyword }, + params: { page, size, searchKeyword, searchUserNos }, headers, }); return { @@ -88,7 +94,8 @@ export const getPostListQueryFn = async ({ export const getPostListInfiniteQueryKey = { all: ["posts"] as const, - byKeyword: (keyword?: string) => ["posts", keyword ?? ""] as const, + byKeyword: ({ keyword, userNo }: { keyword?: string; userNo?: string }) => + ["posts", keyword , userNo ] as const, }; /** From 9f2e1921be508e02af25f6847d41642e623e0699 Mon Sep 17 00:00:00 2001 From: Jungu Lee <1zzangjun@gmail.com> Date: Sun, 19 Nov 2023 20:46:36 +0900 Subject: [PATCH 8/9] =?UTF-8?q?New=20:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EC=A1=B0?= =?UTF-8?q?=EA=B1=B4=EB=B6=80=20=EB=9E=9C=EB=8D=94=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/Navigation/NavigationBar.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/src/components/Navigation/NavigationBar.tsx b/client/src/components/Navigation/NavigationBar.tsx index 4ca22fe..c21d97f 100644 --- a/client/src/components/Navigation/NavigationBar.tsx +++ b/client/src/components/Navigation/NavigationBar.tsx @@ -6,14 +6,16 @@ import SearchIcon from "~/assets/icons/SearchIcon.svg"; import PostIcon from "~/assets/icons/PostIcon.svg"; import BeverageIcon from "~/assets/icons/BeverageIcon.svg"; -import HOME, { MY_PROFILE, NEW_POST, SEARCH, WIKI } from "@/const/clientPath"; +import HOME, { MY_PROFILE, NEW_POST, SEARCH, SIGNIN, WIKI } from "@/const/clientPath"; import Link from "next/link"; import { usePathname } from "next/navigation"; import NavbarUserImage from "@/components/Navigation/NavbarUserImage"; import { useMemo } from "react"; +import { useUserInfoQuery } from "@/queries/auth/useUserInfoQuery"; const NavigationBar = () => { const path = usePathname(); + const { data: userInfo } = useUserInfoQuery(); const NavbarData = useMemo( () => [ { @@ -38,10 +40,10 @@ const NavigationBar = () => { { iconComponent: , label: "내 정보", - href: MY_PROFILE, + href: userInfo ? `${MY_PROFILE}/${userInfo.userNo}` : SIGNIN, }, ], - [] + [userInfo] ); return ( From a573ecccc608018741526e3bd5e9855295a6d8df Mon Sep 17 00:00:00 2001 From: Jungu Lee <1zzangjun@gmail.com> Date: Sun, 19 Nov 2023 20:47:09 +0900 Subject: [PATCH 9/9] =?UTF-8?q?Minor=20:=20=EC=BD=94=EB=93=9C=EC=BB=A8?= =?UTF-8?q?=EB=B2=A4=EC=85=98=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Navigation/NavbarUserImage.tsx | 22 +++++++++---------- .../queries/newPost/useNewPostMutation.tsx | 10 ++++----- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/client/src/components/Navigation/NavbarUserImage.tsx b/client/src/components/Navigation/NavbarUserImage.tsx index 2101e99..73fc9bb 100644 --- a/client/src/components/Navigation/NavbarUserImage.tsx +++ b/client/src/components/Navigation/NavbarUserImage.tsx @@ -3,18 +3,16 @@ import { useUserInfoQuery } from "@/queries/auth/useUserInfoQuery"; import UserAvatar from "../user/info/UserAvatar"; import MyIcon from "~/assets/icons/MyIcon.svg"; const NavbarUserImage = () => { - try { - const { data } = useUserInfoQuery(); - return ( - - ); - } catch (err) { - return ; - } + const { data } = useUserInfoQuery(); + return data ? ( + + ) : ( + + ); }; export default NavbarUserImage; diff --git a/client/src/queries/newPost/useNewPostMutation.tsx b/client/src/queries/newPost/useNewPostMutation.tsx index 15887ef..4ef6ceb 100644 --- a/client/src/queries/newPost/useNewPostMutation.tsx +++ b/client/src/queries/newPost/useNewPostMutation.tsx @@ -1,7 +1,8 @@ import { useMutation } from "@tanstack/react-query"; -import { axiosPrivate } from "@/libs/axios"; +import axios from "@/libs/axios"; import { POST_LIST } from "@/const/serverPath"; import { NewPostRequestInterface } from "@/types/newPost/NewPostInterface"; +import getTokenFromLocalStorage from "@/utils/getTokenFromLocalStorage"; const useNewPostMutation = () => { return useMutation({ @@ -13,10 +14,9 @@ const useNewPostMutation = () => { }; const usePostNewPostFn = async (formData: NewPostRequestInterface) => { - const { data } = await axiosPrivate.post<{ postNo: number }>( - POST_LIST, - formData - ); + const { data } = await axios.post<{ postNo: number }>(POST_LIST, formData, { + headers: { Authorization: getTokenFromLocalStorage() }, + }); return data; };