From 1862efa920aad994b8e93a7d9fd00b87f8d5a17f Mon Sep 17 00:00:00 2001 From: a-honey Date: Thu, 29 Feb 2024 23:17:17 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=A7=84=ED=96=89=EC=A4=91=EC=9D=B8=20?= =?UTF-8?q?=EB=82=98=EB=88=94=20=EB=82=B4=EC=97=AD=20sort=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/queries/mypage/useGetMyShares.ts | 8 ++++---- src/hooks/queries/queryKeys.ts | 4 +++- src/pages/mypage/share/index.tsx | 11 ++++++----- src/types/mypage/index.d.ts | 1 + 4 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 src/types/mypage/index.d.ts diff --git a/src/hooks/queries/mypage/useGetMyShares.ts b/src/hooks/queries/mypage/useGetMyShares.ts index b4cebeb..bbd1c6a 100644 --- a/src/hooks/queries/mypage/useGetMyShares.ts +++ b/src/hooks/queries/mypage/useGetMyShares.ts @@ -1,13 +1,13 @@ -import type { ShareSortType, ShareStatusType } from '@/types/friendship'; - +import type { MySharesSortType } from '@/types/mypage'; import type { ShareData } from '@/types/share'; +import type { ShareStatusType } from '@/types/friendship'; import { queryKeys } from '../queryKeys'; import { useBaseInfiniteQuery } from '../useBaseInfiniteQuery'; -const useGetMyShares = ({ sort, status }: { sort: ShareSortType; status: ShareStatusType }) => +const useGetMyShares = ({ sort, status }: { sort: MySharesSortType; status: ShareStatusType }) => useBaseInfiniteQuery({ queryKey: queryKeys.MY_SHARES(sort, status), - url: `/users/me/shares/all`, + url: `/users/me/shares/${sort}`, params: { status, sort: 'string' }, }); diff --git a/src/hooks/queries/queryKeys.ts b/src/hooks/queries/queryKeys.ts index f0fda26..7a65efa 100644 --- a/src/hooks/queries/queryKeys.ts +++ b/src/hooks/queries/queryKeys.ts @@ -1,5 +1,7 @@ import type { FriendshipSortType, ShareSortType, ShareStatusType } from '@/types/friendship'; +import type { MySharesSortType } from '@/types/mypage'; + export const queryKeys = { COUNT: () => ['count'], MY_FRIDGE_LIST: () => ['my_fridge_list'], @@ -15,7 +17,7 @@ export const queryKeys = { KAKAO: () => ['kakao'], GOOGLE: () => ['google'], SHARES: (sort: ShareSortType, status: ShareStatusType) => ['shares', sort, status], - MY_SHARES: (sort: ShareSortType, status: ShareStatusType) => ['my-shares', sort, status], + MY_SHARES: (sort: MySharesSortType, status: ShareStatusType) => ['my-shares', sort, status], ME: () => ['my-info'], FRIENDSHIPS: (sort: FriendshipSortType) => ['friendship', sort], DELETE_FRIENDSHIP: () => ['deleteFriendship'], diff --git a/src/pages/mypage/share/index.tsx b/src/pages/mypage/share/index.tsx index 231f925..552ff01 100644 --- a/src/pages/mypage/share/index.tsx +++ b/src/pages/mypage/share/index.tsx @@ -1,6 +1,6 @@ import { Modal, ModalBody, ModalContent, ModalOverlay, useDisclosure } from '@chakra-ui/react'; import { RadioButtonField, SortButton, TabButton } from '@/components/atoms'; -import type { ShareSortType, ShareStatusType } from '@/types/friendship'; +import type { ShareStatusType } from '@/types/friendship'; import type { SortLabel, TabLabel } from '@/types/common'; import { useRef, useState } from 'react'; @@ -11,6 +11,7 @@ import ShareListItem from '@/components/organisms/ShareListItem'; import { SuspenseFallback } from '@/components/templates'; import { useObserver } from '@/hooks/useObserver'; import { useGetMyShares } from '@/hooks/queries/mypage'; +import type { MySharesSortType } from '@/types/mypage'; const TABS: TabLabel[] = [ { label: '나눔 중', value: 'SHARE_IN_PROGRESS' }, @@ -18,9 +19,9 @@ const TABS: TabLabel[] = [ ]; const SORT_TYPES: SortLabel[] = [ - { label: '전체 나눔글', value: 'registeredDate' }, - { label: '작성한 나눔글', value: 'dueDate' }, - { label: '참여한 나눔글', value: 'dueDate' }, + { label: '전체 나눔글', value: 'all' }, + { label: '작성한 나눔글', value: 'created' }, + { label: '참여한 나눔글', value: 'applied' }, ]; const MySharePage: NextPage = () => { @@ -29,7 +30,7 @@ const MySharePage: NextPage = () => { const { isOpen, onOpen, onClose } = useDisclosure(); const bottom = useRef(null); const { data, fetchNextPage, isFetchingNextPage } = useGetMyShares({ - sort: curSortType.value as ShareSortType, + sort: curSortType.value as MySharesSortType, status: curTab.value as ShareStatusType, }); diff --git a/src/types/mypage/index.d.ts b/src/types/mypage/index.d.ts new file mode 100644 index 0000000..9d597b1 --- /dev/null +++ b/src/types/mypage/index.d.ts @@ -0,0 +1 @@ +export type MySharesSortType = 'all' | 'applied' | 'created';