From 81768a397894773609e93491a6bd4b7c0823c25b Mon Sep 17 00:00:00 2001 From: Jungu Lee <100949102+jobkaeHenry@users.noreply.github.com> Date: Wed, 13 Dec 2023 22:43:57 +0900 Subject: [PATCH] =?UTF-8?q?Revert=20"=ED=8C=94=EB=A1=9C=EC=9B=8C,=ED=8C=94?= =?UTF-8?q?=EB=A1=9C=EC=9E=89-=EC=9C=A0=EC=A0=80-=ED=99=95=EC=9D=B8?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5-=EC=B6=94=EA=B0=80=20(#83)"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit f48518049202dd3e8d46dc47865021b797041e9e. --- .../user/follow-list/layout.tsx | 22 ------ .../user/follow-list/page.tsx | 39 ---------- .../(protectedRoute)/user/setting/layout.tsx | 6 +- client/src/components/ComponentRepeater.tsx | 18 ----- .../components/CustomToggleButtonGroup.tsx | 72 ------------------- client/src/components/layout/CustomAppbar.tsx | 3 +- .../src/components/layout/CustomContainer.tsx | 6 +- client/src/components/post/PostCardList.tsx | 2 +- .../user/followList/FollowUserCard.tsx | 61 ---------------- .../user/followList/FollowerList.tsx | 43 ----------- .../user/followList/FollowingList.tsx | 45 ------------ .../followList/FollowingUserCardSkeleton.tsx | 22 ------ .../src/components/user/info/UserInfoCard.tsx | 14 +--- client/src/const/clientPath.ts | 9 +-- client/src/const/serverPath.ts | 12 +--- client/src/const/uiSizes.ts | 8 --- client/src/queries/user/useFollowMutation.ts | 3 - .../user/useFollowerUserInfiniteQuery.ts | 51 ------------- .../user/useFollowingUserInfiniteQuery.ts | 51 ------------- .../src/queries/user/useUnFollowMutation.ts | 7 +- client/src/types/Pagenated.ts | 6 -- .../src/types/user/followingUserInterface.ts | 12 ---- 22 files changed, 14 insertions(+), 498 deletions(-) delete mode 100644 client/src/app/(protectedRoute)/user/follow-list/layout.tsx delete mode 100644 client/src/app/(protectedRoute)/user/follow-list/page.tsx delete mode 100644 client/src/components/ComponentRepeater.tsx delete mode 100644 client/src/components/CustomToggleButtonGroup.tsx delete mode 100644 client/src/components/user/followList/FollowUserCard.tsx delete mode 100644 client/src/components/user/followList/FollowerList.tsx delete mode 100644 client/src/components/user/followList/FollowingList.tsx delete mode 100644 client/src/components/user/followList/FollowingUserCardSkeleton.tsx delete mode 100644 client/src/const/uiSizes.ts delete mode 100644 client/src/queries/user/useFollowerUserInfiniteQuery.ts delete mode 100644 client/src/queries/user/useFollowingUserInfiniteQuery.ts delete mode 100644 client/src/types/user/followingUserInterface.ts diff --git a/client/src/app/(protectedRoute)/user/follow-list/layout.tsx b/client/src/app/(protectedRoute)/user/follow-list/layout.tsx deleted file mode 100644 index 0c8f813..0000000 --- a/client/src/app/(protectedRoute)/user/follow-list/layout.tsx +++ /dev/null @@ -1,22 +0,0 @@ -"use client"; -import CustomAppbar from "@/components/layout/CustomAppbar"; -import CustomContainer from "@/components/layout/CustomContainer"; -import { useMyInfoQuery } from "@/queries/auth/useMyInfoQuery"; -import { ReactNode } from "react"; - -type FollowListLayoutProps = { - children: ReactNode; -}; - -const FollowListLayout = ({ children }: FollowListLayoutProps) => { - const { data: myInfo } = useMyInfoQuery(); - - return ( - <> - <CustomAppbar title={`${myInfo?.nickname??'닉네임'}의 목록`}/> - <CustomContainer>{children}</CustomContainer> - </> - ); -}; - -export default FollowListLayout; diff --git a/client/src/app/(protectedRoute)/user/follow-list/page.tsx b/client/src/app/(protectedRoute)/user/follow-list/page.tsx deleted file mode 100644 index 6028be2..0000000 --- a/client/src/app/(protectedRoute)/user/follow-list/page.tsx +++ /dev/null @@ -1,39 +0,0 @@ -"use client"; - -import { Box } from "@mui/material"; -import CustomToggleButtonGroup from "@/components/CustomToggleButtonGroup"; -import { appbarHeight } from "@/const/uiSizes"; -import { Suspense, useState } from "react"; -import FollowingList from "@/components/user/followList/FollowingList"; -import FollowingUserCardSkeleton from "@/components/user/followList/FollowingUserCardSkeleton"; -import ComponentRepeater from "@/components/ComponentRepeater"; -import FollowerList from "@/components/user/followList/FollowerList"; - -const FollowListPage = () => { - const selectableList = ["팔로잉", "팔로워"]; - const [currentView, setCurrentView] = useState(selectableList[0]); - - return ( - <> - <CustomToggleButtonGroup - value={selectableList} - onChange={setCurrentView} - sx={{ position: "fixed", top: appbarHeight, left: 0, right: 0 }} - /> - {/* Fixed로 빠진 button 위치만큼의 place holder */} - <Box height={26} /> - <Suspense - fallback={ - <ComponentRepeater count={5}> - <FollowingUserCardSkeleton /> - </ComponentRepeater> - } - > - {currentView === "팔로잉" && <FollowingList /> } - {currentView === "팔로워" && <FollowerList /> } - </Suspense> - </> - ); -}; - -export default FollowListPage; diff --git a/client/src/app/(protectedRoute)/user/setting/layout.tsx b/client/src/app/(protectedRoute)/user/setting/layout.tsx index 5d6a50d..459189a 100644 --- a/client/src/app/(protectedRoute)/user/setting/layout.tsx +++ b/client/src/app/(protectedRoute)/user/setting/layout.tsx @@ -1,7 +1,6 @@ "use client"; import CustomAppbar from "@/components/layout/CustomAppbar"; -import { appbarHeight } from "@/const/uiSizes"; import { Container, Stack } from "@mui/material"; import { ReactNode } from "react"; @@ -13,10 +12,7 @@ const UserInfoPageLayout = ({ children }: Props) => { return ( <> <CustomAppbar title="설정" /> - <Container - sx={{ px: { xs: 0, sm: 4 }, mt: appbarHeight }} - maxWidth={"lg"} - > + <Container sx={{ px: { xs: 0, sm: 4 } }} maxWidth={"lg"}> <Stack gap={2}>{children}</Stack> </Container> </> diff --git a/client/src/components/ComponentRepeater.tsx b/client/src/components/ComponentRepeater.tsx deleted file mode 100644 index 7dd0fba..0000000 --- a/client/src/components/ComponentRepeater.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { cloneElement, ReactComponentElement } from "react"; - -type Props = { - children: ReactComponentElement<any>; - count: number; -}; - -const ComponentRepeater = ({ children, count }: Props) => { - return ( - <> - {Array.from(new Array(count)).map((_e, i) => - cloneElement(children, { key: i }) - )} - </> - ); -}; - -export default ComponentRepeater; diff --git a/client/src/components/CustomToggleButtonGroup.tsx b/client/src/components/CustomToggleButtonGroup.tsx deleted file mode 100644 index e042fc2..0000000 --- a/client/src/components/CustomToggleButtonGroup.tsx +++ /dev/null @@ -1,72 +0,0 @@ -"use client"; -import { - ToggleButton, - ToggleButtonGroup, - ToggleButtonGroupProps, - Typography, -} from "@mui/material"; -import { useState } from "react"; - -interface CustomToggleButtonGroupType - extends Omit<ToggleButtonGroupProps, "onChange" | "value" | "children"> { - onChange: (val: string) => void; - value: string[]; -} - -const CustomToggleButtonGroup = ({ - onChange, - value, - sx, - ...toggleBtnGroupProps -}: CustomToggleButtonGroupType) => { - const [currentValue, setCurrentValue] = useState(value[0]); - - return ( - <ToggleButtonGroup - value={currentValue} - exclusive - fullWidth - onChange={(_e, val) => { - if (val !== null) { - setCurrentValue(val); - onChange(val); - } - }} - sx={{ backgroundColor: "background.paper",px:2, ...sx }} - {...toggleBtnGroupProps} - > - {value.map((val, i) => { - return ( - <ToggleButton - key={i} - disableRipple - value={val} - fullWidth - sx={ToggleButtonStyle} - > - <Typography fontSize="caption1" fontWeight="bold"> - {val} - </Typography> - </ToggleButton> - ); - })} - </ToggleButtonGroup> - ); -}; - -const ToggleButtonStyle = { - border: 0, - borderRadius: 0, - "&.Mui-selected": { - backgroundColor: "background.paper", - borderBottom: "1px solid", - ":hover": { - backgroundColor: "background.paper", - }, - }, - ":hover": { - backgroundColor: "background.paper", - }, -}; - -export default CustomToggleButtonGroup; diff --git a/client/src/components/layout/CustomAppbar.tsx b/client/src/components/layout/CustomAppbar.tsx index 79775a6..9fda6eb 100644 --- a/client/src/components/layout/CustomAppbar.tsx +++ b/client/src/components/layout/CustomAppbar.tsx @@ -11,7 +11,6 @@ import { import GoBackIcon from "@/assets/icons/GoBackIcon.svg"; import { MouseEventHandler, ReactNode, memo } from "react"; import { useRouter } from "next/navigation"; -import { appbarHeight } from "@/const/uiSizes"; interface CustomAppbarInterface extends AppBarProps { title?: string; @@ -35,7 +34,7 @@ const CustomAppbar = ({ const router = useRouter(); return ( - <AppBar sx={{ height: appbarHeight }} position={position ? position : "fixed"}> + <AppBar position={position ? position : "fixed"}> <Toolbar sx={{ display: "flex", justifyContent: "space-between" }}> {/* 프리팬드 버튼 */} {prependButton ? ( diff --git a/client/src/components/layout/CustomContainer.tsx b/client/src/components/layout/CustomContainer.tsx index ae95642..4544021 100644 --- a/client/src/components/layout/CustomContainer.tsx +++ b/client/src/components/layout/CustomContainer.tsx @@ -1,4 +1,3 @@ -import { appbarHeight, navbarHeight } from "@/const/uiSizes"; import { Container, ContainerProps, Paper } from "@mui/material"; interface CustomContainerInterface extends ContainerProps { @@ -10,6 +9,9 @@ const CustomContainer = ({ disableMt, children, }: CustomContainerInterface) => { + const appbarHeight = '64px' + const navbarHeight = '56px' + return ( <Container sx={{ ...sx, px: { xs: 0, sm: 4 }, mt: disableMt ? 0 : 8 }} @@ -22,7 +24,7 @@ const CustomContainer = ({ flexDirection: "column", gap: 2, p: 2, - minHeight: `calc(100vh - ${appbarHeight} - ${navbarHeight})`, + minHeight:`calc(100vh - ${appbarHeight} - ${navbarHeight})` }} > {children} diff --git a/client/src/components/post/PostCardList.tsx b/client/src/components/post/PostCardList.tsx index 01adf81..b507601 100644 --- a/client/src/components/post/PostCardList.tsx +++ b/client/src/components/post/PostCardList.tsx @@ -59,7 +59,7 @@ function PostCardList(props: UseGetPostListQueryInterface) { <PostCardSkeleton /> ) : ( // 인터섹션옵저버 - hasNextPage&&<div style={{ height: 60 }} ref={ref}></div> + <div style={{ height: 60 }} ref={ref}></div> )} </div> </postcardContext.Provider> diff --git a/client/src/components/user/followList/FollowUserCard.tsx b/client/src/components/user/followList/FollowUserCard.tsx deleted file mode 100644 index edb8be9..0000000 --- a/client/src/components/user/followList/FollowUserCard.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import { Button, Stack, Typography } from "@mui/material"; -import React from "react"; -import UserAvatar from "@/components/user/info/UserAvatar"; -import { useRouter } from "next/navigation"; -import { USER_PAGE } from "@/const/clientPath"; -import useUnFollowMutation from "@/queries/user/useUnFollowMutation"; - -type Props = { - imageUrl?: string; - nickName: string; - userId: string; - content: string; - userPk: number; -}; - -const FollowUserCard = ({ - userPk, - imageUrl, - nickName, - userId, - content, -}: Props) => { - const router = useRouter(); - const { mutate: unfollowHandler } = useUnFollowMutation(); - - return ( - <Stack direction="row" gap={1} py={1}> - <UserAvatar - src={imageUrl} - alt={`${nickName}의 프로필`} - fallback={nickName} - onClick={() => router.push(USER_PAGE(userPk))} - sx={{ cursor: "pointer" }} - /> - <Stack gap={1} flexGrow={1}> - <Stack direction="row" justifyContent={"space-between"}> - <Stack - sx={{ cursor: "pointer" }} - onClick={() => router.push(USER_PAGE(userPk))} - > - <Typography fontSize="caption1" color="text.main"> - {nickName} - </Typography> - <Typography fontSize="caption2" color="text.secondary"> - @{userId} - </Typography> - </Stack> - <Button - variant="outlined" - onClick={() => unfollowHandler(String(userPk))} - > - 언팔로우 - </Button> - </Stack> - <Typography>{content}</Typography> - </Stack> - </Stack> - ); -}; - -export default FollowUserCard; diff --git a/client/src/components/user/followList/FollowerList.tsx b/client/src/components/user/followList/FollowerList.tsx deleted file mode 100644 index ec88f26..0000000 --- a/client/src/components/user/followList/FollowerList.tsx +++ /dev/null @@ -1,43 +0,0 @@ -"use client"; - -import FollowUserCard from "@/components/user/followList/FollowUserCard"; -import { useEffect } from "react"; -import { useInView } from "react-intersection-observer"; -import FollowingUserCardSkeleton from "@/components/user/followList/FollowingUserCardSkeleton"; -import ComponentRepeater from "@/components/ComponentRepeater"; -import useFollowerUserInfiniteQuery from "@/queries/user/useFollowerUserInfiniteQuery"; - -const FollowerList = () => { - const { data, isFetchingNextPage, hasNextPage, fetchNextPage } = - useFollowerUserInfiniteQuery(); - const { ref, inView } = useInView(); - - useEffect(() => { - if (hasNextPage && inView) fetchNextPage(); - }, [inView, hasNextPage]); - - return ( - <> - {data.pages.map((page) => - page.content.map(({ nickname, id, introduction }) => ( - <FollowUserCard - key={id} - nickName={nickname} - userId={id} - content={introduction} - /> - )) - )} - {isFetchingNextPage ? ( - <ComponentRepeater count={5}> - <FollowingUserCardSkeleton /> - </ComponentRepeater> - ) : ( - // 인터섹션옵저버 - hasNextPage && <div style={{ height: 60 }} ref={ref}></div> - )} - </> - ); -}; - -export default FollowerList; diff --git a/client/src/components/user/followList/FollowingList.tsx b/client/src/components/user/followList/FollowingList.tsx deleted file mode 100644 index 7e5ab07..0000000 --- a/client/src/components/user/followList/FollowingList.tsx +++ /dev/null @@ -1,45 +0,0 @@ -"use client"; - -import FollowUserCard from "@/components/user/followList/FollowUserCard"; -import useFollowingUserInfiniteQuery from "@/queries/user/useFollowingUserInfiniteQuery"; -import { useEffect } from "react"; -import { useInView } from "react-intersection-observer"; -import FollowingUserCardSkeleton from "@/components/user/followList/FollowingUserCardSkeleton"; -import ComponentRepeater from "@/components/ComponentRepeater"; - -const FollowingList = () => { - const { data, isFetchingNextPage, hasNextPage, fetchNextPage } = - useFollowingUserInfiniteQuery(); - const { ref, inView } = useInView(); - - useEffect(() => { - if (hasNextPage && inView) fetchNextPage(); - }, [inView, hasNextPage]); - - return ( - <> - {data.pages.map((page) => - page.content.map(({ nickname, id, introduction, profileImgUrls, userNo }) => ( - <FollowUserCard - key={id} - nickName={nickname} - userId={id} - userPk={userNo} - imageUrl={profileImgUrls[0]?.attachUrl} - content={introduction} - /> - )) - )} - {isFetchingNextPage ? ( - <ComponentRepeater count={5}> - <FollowingUserCardSkeleton /> - </ComponentRepeater> - ) : ( - // 인터섹션옵저버 - hasNextPage && <div style={{ height: 60 }} ref={ref}></div> - )} - </> - ); -}; - -export default FollowingList; diff --git a/client/src/components/user/followList/FollowingUserCardSkeleton.tsx b/client/src/components/user/followList/FollowingUserCardSkeleton.tsx deleted file mode 100644 index a6b0c53..0000000 --- a/client/src/components/user/followList/FollowingUserCardSkeleton.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { Stack } from "@mui/material"; -import { Skeleton } from "@mui/material"; - -const FollowingUserCardSkeleton = () => { - return ( - <Stack direction="row" gap={1} py={1}> - <Skeleton width={40} height={40} variant="circular" /> - <Stack gap={1} flexGrow={1}> - <Stack direction="row" justifyContent={"space-between"}> - <Stack> - <Skeleton width={50} /> - <Skeleton width={60} /> - </Stack> - <Skeleton height={40} width={80} variant="rectangular" /> - </Stack> - <Skeleton width={"100%"} /> - </Stack> - </Stack> - ); -}; - -export default FollowingUserCardSkeleton; diff --git a/client/src/components/user/info/UserInfoCard.tsx b/client/src/components/user/info/UserInfoCard.tsx index b770879..4b6b363 100644 --- a/client/src/components/user/info/UserInfoCard.tsx +++ b/client/src/components/user/info/UserInfoCard.tsx @@ -9,8 +9,6 @@ import { useMyInfoQuery } from "@/queries/auth/useMyInfoQuery"; import { useContext, useMemo } from "react"; import UserPageContext from "@/store/user/UserPageContext"; import UserInfoCardSkeleton from "./UserInfoCardSkeleton"; -import { useRouter } from "next/navigation"; -import { USER_FOLLOW_LIST } from "@/const/clientPath"; type Props = { initialData?: UserInfoInterface; @@ -26,7 +24,6 @@ const UserInfo = ({ initialData, userId }: Props) => { ); const token = getTokenFromLocalStorage(); - const router = useRouter(); const { setIsEditing } = useContext(UserPageContext); const { data } = useUserInfoQuery({ @@ -36,7 +33,7 @@ const UserInfo = ({ initialData, userId }: Props) => { }); if (!data) { - return <UserInfoCardSkeleton />; + return <UserInfoCardSkeleton/>; } const { @@ -67,14 +64,7 @@ const UserInfo = ({ initialData, userId }: Props) => { {introduction ?? "자기소개가 없습니다"} </Typography> </Box> - <Stack - direction="row" - gap={1} - sx={{cursor:'pointer'}} - onClick={() => { - isMyProfile && router.push(USER_FOLLOW_LIST); - }} - > + <Stack direction="row" gap={1}> <Typography fontWeight="bold">{followerCount}</Typography> <Typography color="text.secondary">팔로워</Typography> <Typography fontWeight="bold">{followingCount}</Typography> diff --git a/client/src/const/clientPath.ts b/client/src/const/clientPath.ts index f6c329a..f920467 100644 --- a/client/src/const/clientPath.ts +++ b/client/src/const/clientPath.ts @@ -18,17 +18,12 @@ export const MY_PROFILE = "/user" as const; /** * 유저의 PK를 입력받아 해당유저의 프로필 페이지로 이동하는 URL */ -export const USER_PAGE = (pk: string | number) => `${MY_PROFILE}/${pk}`; - -/** - * 유저가 팔로잉/팔로워 리스트페이지로 이동하는 라우트 - */ -export const USER_FOLLOW_LIST = `${MY_PROFILE}/follow-list` +export const USER_PAGE = (pk: string | number) => `/user/${pk}`; /** * 유저정보 세팅 페이지로 이동하는 라우트 */ -export const SETTING_PAGE = `${MY_PROFILE}/setting` as const +export const SETTING_PAGE = '/user/setting' as const /** * 술과사전 페이지 라우트 diff --git a/client/src/const/serverPath.ts b/client/src/const/serverPath.ts index b02d8ea..852adbc 100644 --- a/client/src/const/serverPath.ts +++ b/client/src/const/serverPath.ts @@ -84,8 +84,7 @@ export const GET_ALCOHOL_LIST = "/alcohols" as const; /** * 알콜 디테일을 받아오는 URL */ -export const GET_ALCOHOL_DETAIL = (id: string) => - `${GET_ALCOHOL_LIST}/${id}` as const; +export const GET_ALCOHOL_DETAIL = (id: string) => `${GET_ALCOHOL_LIST}/${id}` as const; /** * 포스트의 PK를 입력받아 해당 PK의 게시글의 좋아요 취소를 요청 @@ -99,15 +98,6 @@ export const POST_UN_LIKE_URL = (id: string) => * @returns */ export const USER_SUMMARY = (id: string) => `/user/${id}/summary` as const; -/** - * 내가 팔로우 하고 있는 유저를 불러오는 URL - */ -export const FOLLOWING_USER = "/user/my-following-users"; - -/** - * 나를 팔로우 하고 있는 유저를 불러오는 URL - */ -export const FOLLOWER_USER = "/user/users-of-following-me"; /** * 유저 ID 를 입력받아 해당 유저를 팔로우 하는 URL diff --git a/client/src/const/uiSizes.ts b/client/src/const/uiSizes.ts deleted file mode 100644 index e09b97b..0000000 --- a/client/src/const/uiSizes.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * 최상단 앱바의 높이 - */ -export const appbarHeight = '64px' -/** - * 최하단 네비게이션바의 높이 - */ -export const navbarHeight = '56px' \ No newline at end of file diff --git a/client/src/queries/user/useFollowMutation.ts b/client/src/queries/user/useFollowMutation.ts index 6e47527..027a006 100644 --- a/client/src/queries/user/useFollowMutation.ts +++ b/client/src/queries/user/useFollowMutation.ts @@ -7,7 +7,6 @@ import { UserInfoInterface } from "@/types/user/userInfoInterface"; import { MyInfoQueryKeys } from "../auth/useMyInfoQuery"; import { MyInfoInterface } from "@/types/auth/myInfo"; import { useErrorHandler } from "@/utils/errorHandler"; -import { followerUserQueryKey } from "./useFollowerUserInfiniteQuery"; const useFollowMutation = () => { const queryClient = useQueryClient(); @@ -60,8 +59,6 @@ const useFollowMutation = () => { queryClient.invalidateQueries({ queryKey: UserInfoQueryKey.byId(userInfo?.userNo), }); - // TODO 낙관적업데이트 구현 - queryClient.invalidateQueries({ queryKey: followerUserQueryKey.all }); }, }); }; diff --git a/client/src/queries/user/useFollowerUserInfiniteQuery.ts b/client/src/queries/user/useFollowerUserInfiniteQuery.ts deleted file mode 100644 index d53b948..0000000 --- a/client/src/queries/user/useFollowerUserInfiniteQuery.ts +++ /dev/null @@ -1,51 +0,0 @@ -"use client"; -import { FOLLOWER_USER } from "@/const/serverPath"; -import useAxiosPrivate from "@/hooks/useAxiosPrivate"; -import { useSuspenseInfiniteQuery } from "@tanstack/react-query"; -import Pagenated, { PagenationParams } from "@/types/Pagenated"; -import FollowingUserInterface from "@/types/user/followingUserInterface"; - -const useFollowerUserInfiniteQuery = () => { - return useSuspenseInfiniteQuery({ - queryKey: followerUserQueryKey.all, - - queryFn: async ({ pageParam = 0 }) => - await getFollowerUserFn({ page: pageParam }), - - getNextPageParam: ({ currentPage, hasNextPage }) => - hasNextPage ? currentPage + 1 : undefined, - - getPreviousPageParam: ({ currentPage }) => - currentPage > 0 ? currentPage - 1 : undefined, - initialPageParam: 0, - }); -}; - -export const getFollowerUserFn = async ({ - page = 0, - size = 10, - sort = "desc", -}: PagenationParams) => { - const axiosPrivate = useAxiosPrivate(); - const { data } = await axiosPrivate.get<Pagenated<FollowingUserInterface>>( - FOLLOWER_USER, - { - params: { - page, - size, - sort, - }, - } - ); - return { - ...data, - currentPage: page, - hasNextPage: data.totalElements / ((page + 1) * size) > 1, - }; -}; - -export const followerUserQueryKey = { - all: ["follower"], -}; - -export default useFollowerUserInfiniteQuery; diff --git a/client/src/queries/user/useFollowingUserInfiniteQuery.ts b/client/src/queries/user/useFollowingUserInfiniteQuery.ts deleted file mode 100644 index c79bb59..0000000 --- a/client/src/queries/user/useFollowingUserInfiniteQuery.ts +++ /dev/null @@ -1,51 +0,0 @@ -"use client"; -import { FOLLOWING_USER } from "@/const/serverPath"; -import useAxiosPrivate from "@/hooks/useAxiosPrivate"; -import { useSuspenseInfiniteQuery } from "@tanstack/react-query"; -import Pagenated, { PagenationParams } from "@/types/Pagenated"; -import FollowingUserInterface from "@/types/user/followingUserInterface"; - -const useFollowingUserInfiniteQuery = () => { - return useSuspenseInfiniteQuery({ - queryKey: followingUserQueryKey.all, - - queryFn: async ({ pageParam = 0 }) => - await getFollowingUserFn({ page: pageParam }), - - getNextPageParam: ({ currentPage, hasNextPage }) => - hasNextPage ? currentPage + 1 : undefined, - - getPreviousPageParam: ({ currentPage }) => - currentPage > 0 ? currentPage - 1 : undefined, - initialPageParam: 0, - }); -}; - -export const getFollowingUserFn = async ({ - page = 0, - size = 10, - sort = "desc", -}: PagenationParams) => { - const axiosPrivate = useAxiosPrivate(); - const { data } = await axiosPrivate.get<Pagenated<FollowingUserInterface>>( - FOLLOWING_USER, - { - params: { - page, - size, - sort, - }, - } - ); - return { - ...data, - currentPage: page, - hasNextPage: data.totalElements / ((page + 1) * size) > 1, - }; -}; - -export const followingUserQueryKey = { - all: ["followingUser"], -}; - -export default useFollowingUserInfiniteQuery; diff --git a/client/src/queries/user/useUnFollowMutation.ts b/client/src/queries/user/useUnFollowMutation.ts index f73438b..36cdc89 100644 --- a/client/src/queries/user/useUnFollowMutation.ts +++ b/client/src/queries/user/useUnFollowMutation.ts @@ -7,12 +7,11 @@ import { UserInfoInterface } from "@/types/user/userInfoInterface"; import { MyInfoQueryKeys } from "../auth/useMyInfoQuery"; import { MyInfoInterface } from "@/types/auth/myInfo"; import { useErrorHandler } from "@/utils/errorHandler"; -import { followingUserQueryKey } from "./useFollowingUserInfiniteQuery"; const useUnFollowMutation = () => { const queryClient = useQueryClient(); const errorHandler = useErrorHandler(); - + return useMutation({ mutationFn: async (userNo: string) => await followUserMutationFn(userNo), /** @@ -47,7 +46,7 @@ const useUnFollowMutation = () => { * Mutation 실패시 원래 QuerySnapShot정보로 롤백 */ onError: (err, queryFnParams, context) => { - errorHandler(err); + errorHandler(err) if (!context) { return; } @@ -64,8 +63,6 @@ const useUnFollowMutation = () => { queryClient.invalidateQueries({ queryKey: UserInfoQueryKey.byId(userInfo?.userNo), }); - // TODO 낙관적업데이트 구현 - queryClient.invalidateQueries({ queryKey: followingUserQueryKey.all }); }, }); }; diff --git a/client/src/types/Pagenated.ts b/client/src/types/Pagenated.ts index 93c8f3a..513796b 100644 --- a/client/src/types/Pagenated.ts +++ b/client/src/types/Pagenated.ts @@ -33,9 +33,3 @@ interface PageableInterface { paged: boolean; unpaged: boolean; } - -export interface PagenationParams { - page?: number; - size?: number; - sort?: string; -} diff --git a/client/src/types/user/followingUserInterface.ts b/client/src/types/user/followingUserInterface.ts deleted file mode 100644 index e51e28a..0000000 --- a/client/src/types/user/followingUserInterface.ts +++ /dev/null @@ -1,12 +0,0 @@ -import AttachInterface from "../attach/attachInterface"; - -interface FollowingUserInterface { - nickname: string; - id: string; - userNo: number; - introduction: string; - createdBy: number; - profileImgUrls: AttachInterface[]; -} - -export default FollowingUserInterface;